简体   繁体   中英

Meteor: why certain js files are not automatically loaded?

For example (even trying to use the library from console after X seconds or with a setTimeout):

client/kiwi.mini.js (from https://github.com/gamelab/kiwi.js )

Exception from Tracker afterFlush function: debug.js:41 ReferenceError: Kiwi is not defined

When kiwi is loaded standalone with

<script src

within a normal HTML page, it just works (new Kiwi...)

The last little bit of the huge unminified JS file is minified, so it's hard to tell for sure, but it doesn't look like Kiwi is being added to the window object in their code. Since Meteor compiles all JS files and makes any variable that has a var in front of it local to that JS file, the Kiwi object is not available globally.

Simply add one line of code to the end of the minified file:

window.Kiwi = Kiwi;

I've tested it in a sample Meteor app and was able to create a new Kiwi.Game object.

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