Backbone app with CommonJS and Browserify

心已入冬 提交于 2019-12-04 19:28:53

The "very obvious thing" you're missing is that you can create globals in Node.js, and in the Browserify environment just the same. Either do it explicitly by using global.Backbone = require('/backbone'), or less explicit by just doing Backbone = require('/backbone') (without var in front).

Note that in the browser, the global object is in fact the window object. However, attaching to the window object would mean you lose compatibility with Node.js, because that typically doesn't have a global variable window defined.

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