Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build with firebase as import #87

Closed
jmadler opened this issue Jun 1, 2017 · 7 comments · Fixed by #92
Closed

Unable to build with firebase as import #87

jmadler opened this issue Jun 1, 2017 · 7 comments · Fixed by #92

Comments

@jmadler
Copy link

jmadler commented Jun 1, 2017

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

@rkostrzewski
Copy link
Collaborator

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 😅

@lukeed
Copy link
Member

lukeed commented Jun 1, 2017

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.

@addyosmani
Copy link
Contributor

@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.

@lukeed
Copy link
Member

lukeed commented Jun 1, 2017

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

@mbleigh
Copy link

mbleigh commented Jun 2, 2017

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

@lukeed
Copy link
Member

lukeed commented Jun 2, 2017

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

@lukeed lukeed mentioned this issue Jun 4, 2017
developit pushed a commit that referenced this issue Jun 7, 2017
* replace: replace-bundle-webpack-plugin --> webpack-plugin-replace

* update config for new plugin

* update webpack-plugin-replace

* update value to function; match length
@developit
Copy link
Member

Fix released in 1.1.1! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants