firebase js 版本 > 3.6.3 中断了与 aurelia-cli 的捆绑
firebase js version > 3.6.3 breaks bundling with the aurelia-cli
我使用 aurelia-cli 来捆绑我的资产。需要模块由 requirejs 处理。
为了使用 firebase,我专门捆绑了文件 firebase-browser.js:
// aurelia.json
[...]
{
"name": "firebase",
"path": "../node_modules/firebase/",
"main": "firebase-browser"
}
直到 3.6.2 版本的 firebase npm 包一切都按预期工作。但是从3.6.3版本开始,浏览器出现如下错误:
ReferenceError: global is not defined
导致问题的包部分:
define('firebase/app',['require','exports','module'],function (require, exports, module) {var firebase = (function(){
// minified stuff
firebase.SDK_VERSION = "3.6.3";
return firebase;}).call(global); // <--- ERROR
module.exports = firebase;
firebase 的发行说明说
3.6.3: Changed the packaging of browser npm modules to fix an issue that occurred when using Firebase Storage with the Browserify and webpack module bundlers.
有什么解决办法吗?
为了与 Node 兼容,Browserify 将 global
定义为 window
。
您应该能够通过在加载 Firebase 之前在某个地方定义它来解决您的问题:
window.global = window;
它不是很漂亮,但它应该可以解决问题。
我使用 aurelia-cli 来捆绑我的资产。需要模块由 requirejs 处理。
为了使用 firebase,我专门捆绑了文件 firebase-browser.js:
// aurelia.json
[...]
{
"name": "firebase",
"path": "../node_modules/firebase/",
"main": "firebase-browser"
}
直到 3.6.2 版本的 firebase npm 包一切都按预期工作。但是从3.6.3版本开始,浏览器出现如下错误:
ReferenceError: global is not defined
导致问题的包部分:
define('firebase/app',['require','exports','module'],function (require, exports, module) {var firebase = (function(){
// minified stuff
firebase.SDK_VERSION = "3.6.3";
return firebase;}).call(global); // <--- ERROR
module.exports = firebase;
firebase 的发行说明说
3.6.3: Changed the packaging of browser npm modules to fix an issue that occurred when using Firebase Storage with the Browserify and webpack module bundlers.
有什么解决办法吗?
为了与 Node 兼容,Browserify 将 global
定义为 window
。
您应该能够通过在加载 Firebase 之前在某个地方定义它来解决您的问题:
window.global = window;
它不是很漂亮,但它应该可以解决问题。