Steeve Cannon
Steeve Cannon

Reputation: 3682

In Meteor how can I include a js file in another js file server side?

In Meteor is there a way to include a js file in another js file.

Specifically, server side and most importantly at start up.

The use case I am running into is for complicated Meteor.startups where I need to load quite a bit of data to the mongodb into a variety of collections.

In order to have different test scripts I have to have more than one file each with duplicate data.

So, is there anyway to have say a boostrap.js file that calls Meteor.startup and then is able to load different files in order to load up the test data?

Or can this be done in a different way through some kind of object?

Upvotes: 0

Views: 1822

Answers (2)

matb33
matb33

Reputation: 2830

Try using my module loader made for use with Meteor. It's very similar to AMD: https://github.com/matb33/meteor-smd

Upvotes: 0

Tarang
Tarang

Reputation: 75965

By design Meteor will automatically include all the javascript files in the the entire project (except in the public folder) but only segregate them between the server and client.

You could create objects in separate files and just use the functions or objects whenever you please, they should all be available at startup.

Upvotes: 2

Related Questions