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

安稳与你 提交于 2019-12-25 03:45:29

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/15178015/in-meteor-how-can-i-include-a-js-file-in-another-js-file-server-side

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!