简体   繁体   中英

Meteor.js serve javascript files without (function() { … }).call(this)

The title should be self explanatory, but is there a way to get Meteor to serve up a javascript file without stuffing it into (function() { <<code>> }).call(this) ?

I wrote an app that relies on javascript objects each stored in their own file and then instantiated when they are ready to be used. However, because of the aforementioned problem, they are isolated and unable to be viewed from outside files.

The only option I have come up with is to store them as plaintext and then load them using an HTTP request and then store them into the main file. Hopefully I am missing a much easier way.

If you need any code, let me know, but I think this is general enough to not warrant any.

--EDIT--

I originally wrote this to be a standalone html page, but then decided to go all out and use meteor to make it a full-blown web app.

Its probably not a good idea to try and get the javascript file this way because when you deploy the app or set production mode on, all the javascript files and html files will be minified into a single js file & they wouldn't exist the normal locations during development anymore:

If you want the javascript file to be untouched by meteor you would need to put it in a folder called /public in your projects root directory.

If you are more interested in whats inside the javascript files as opposed to getting them by filename you might want to switch to the devel branch of meteor, or wait for the never version after 0.6.2.1 and put your javascript files in /client/compatibility/ as these files are not variable scoped & will still be automatically referenced unlike the /public dir.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM