reactjs - Firebase library for Node.js breaks when using 'babel' loader. Specifically: "Uncaught TypeError: Cannot read property 'navigator' of undefined" -


i'm building app reactjs, webpack, babel, , firebase.

when run webpack bundle code using babel loader, see following printed out amongst many other lines:

[babel] note: code generator has deoptimised styling of "/users/.../myproject/node_modules/firebase/lib/firebase-web.js" exceeds max of "100kb".

then when try , require('firebase') in app, , run in browser... browser prints out following in console.

uncaught typeerror: cannot read property 'navigator' of undefined (anonymous function) @ firebase-web.js:12 (anonymous function) @ firebase-web.js:262 __webpack_require__ @ bootstrap da2fff1ce4ea892319dc:19 aa @ playerstore.js:3 __webpack_require__ @ bootstrap da2fff1ce4ea892319dc:19 prop @ player.js:19 __webpack_require__ @ bootstrap da2fff1ce4ea892319dc:19 (anonymous function) @ index.js:13 __webpack_require__ @ bootstrap da2fff1ce4ea892319dc:19 obj.__esmodule.default @ bootstrap da2fff1ce4ea892319dc:39 (anonymous function) @ bootstrap da2fff1ce4ea892319dc:39 

playerstore.js:3 have line:

var firebase = require('firebase'); 

does know causing error when try , load app? i'm not sure if error started because switched using jsx-loader in webpack babel, or because ran 'npm update' , new version of 1 of packages i'm using breaking things.

there seems answer: webpack + firebase: disable parsing of firebase

babel adds "use strict" causes this undefined.

solution disable babel-loader firebase, described in linked answer:

... module: {   loaders: [     {test: /\.jsx?$/, exclude: /node_modules/, loader: 'babel-loader'}   ] } ... 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -