Preact-cli: Unable to build with firebase as import

Created on 1 Jun 2017  Â·  7Comments  Â·  Source: preactjs/preact-cli

I'm unable to build a project that has firebase as an import. It looks like some of the build steps are preprocessing imported modules in a way that's breaking uglify.

Environment:

  • macOS Sierra
  • firebase 4.1.1
  • node v7.10.0
  • npm 4.6.1
  • yarn 0.24.5
  • preact-cli 1.1.0
  • preact 8.1.0
  • uglify-js 3.0.14

Reproduction steps:

$ preact create sample
$ cd sample
$ yarn add firebase
$ edit src/index.js # Add: import firebase from 'firebase';
$ yarn run build
  yarn run v0.24.5
  $ preact build
  bundle.js from UglifyJs
  Unexpected token: punc ()) [bundle.js:5468,33]
  ✨  Done in 6.07s.

Here's a copy of the bundle.js. Note the () on line 5470 around char 33.

CC @addyosmani @jshcrowthe

Most helpful comment

I see I'm not the only Googler running into this. Hi @addyosmani, hi @jmadler :wink:

All 7 comments

function ka(a,b,c){if(!a)throw Error(); get's transformed to function ka(a,b,c){if(!a)return;(); because of ReplacePlugin in webpack config.

@developit is there a way to actually limit it to babel-helpers? I don't think it's a good idea to remove all errors - I mean we all like to throw some errors around when things go south 😅

Oh, nice catch! Went through the plugin source, and there's no option for specifying a file or dir-specific replacement. If anything is possible, it'd have to be thru a webpack context loader...maybe? That, or fork the plugin. It's been idle for a while anyway.

@lukeed is correct in that plugin doesn't appear to have been active for over a year (no replies to the open PR in that timespan either). If we go down the direction of forking it to address this that doesn't sound like the worst idea :)

Perhaps there's a cleaner way to limit this to babel-helpers though without needing to do that.

This is something I can take on, and better yet, can justify spending time on it with work.

I see I'm not the only Googler running into this. Hi @addyosmani, hi @jmadler :wink:

I have time set aside for this tomorrow. New plugin out shortly folks.

Fix released in 1.1.1! :)

Was this page helpful?
0 / 5 - 0 ratings