防止 Meteor 将脚本包装在立即调用的函数表达式中

Prevent Meteor from wrapping scripts in an immediately-invoked function expression

Meteor 将在任何 JS 文件的内容周围包装一个立即调用的函数表达式 (IFFE),以确保文件之间没有命名空间冲突。

我正处于一个使用 beta npm 模块的项目的早期阶段。我希望能够 运行 直接从具有全局范围的浏览器控制台编写代码。

有没有办法让 Meteor 很好地不要将我所有的脚本包装在一个 IFFE 中,这样我就可以创建全局函数和访问全局变量,从而更容易地理解 beta npm 模块在做什么(以及什么它做错了)?

提前致谢。

如果你的代码在客户端是运行,你可以直接把它放到client/compatibility文件夹中。来自流星文档 (http://docs.meteor.com/#/full/structuringyourapp):

client/compatibility

This folder is for compatibility JavaScript libraries that rely on variables declared with var at the top level being exported as globals. Files in this directory are executed without being wrapped in a new variable scope. These files are executed before other client-side JavaScript files.