morajabi / styled-media-query

💅💍 Better media queries for styled-component
MIT License
1.32k stars 53 forks source link

Library fails to get "uglified" by webpack 2. #6

Closed geraldyeo closed 7 years ago

geraldyeo commented 7 years ago

My npm run build, using webpack 2, code splitting and uglify js, fails with an exit status of 2. Reason being Uglify js doesn't support es6 yet (https://github.com/mishoo/UglifyJS2/issues/448)

You might want to distribute this library with a compiled es5 version for npm (see https://github.com/rollup/rollup/wiki/pkg.module).

morajabi commented 7 years ago

Thanks, I'll fix it as soon as I can. I made an issue #5 before for adding rollup. Also we have this https://www.npmjs.com/package/uglify-es too.

Can you represent a minimal repo producing this error?

morajabi commented 7 years ago

@geraldyeo I added Rollup and umd build. Just published to npm the version 1.0.2.

Can you please check if it solves your problem? Because it's important for me to everyone can use it regardless of their tooling.

nataze commented 7 years ago

@morajabi I'm not sure it was fixed, I'm using version 2.0.0-rc.2 and still get the UglifyJS error for es6 :(

morajabi commented 7 years ago

@nataze Sorry, can you give me an example how are you using Uglify JS so I can reproduce the issue?

Also if you could make a minimal repo reproducing the issue, it would be great.

morajabi commented 7 years ago

I saw the problem with create-react-app build and I'm working on it.

morajabi commented 7 years ago

I released version 2.0.0-rc.3 in NPM and I think this issue is fixed. Now you can install it like this:

npm install styled-media-query@beta
nataze commented 7 years ago

Ok, awesome! Thanks alot :) I'll try it out now. The error had to with the fact that default parameters (which is an ES6 feature) was being used in the npm module and React-Storybook which uses UglifyJS doesn't understand ES6 yet. I worked around it by adding a custom webpack config file which does the job of transpiling to ES6 to ES5

morajabi commented 7 years ago

@nataze I see. I hope it has solved the issue. Update the issue when you tested, please. Thanks for reporting!

I added a section in README regarding this issue: https://github.com/morajabi/styled-media-query#️-troubleshoot

P.S. Don't forget to install styled-media-query@beta.

morajabi commented 7 years ago

Version 2 is released with a fix for this issue.

Can you update the issue if we still have the problem with v2? I just want to know whether it is fixed or not.

nataze commented 7 years ago

It fixes it!! Thanks a lot, you the man!! @morajabi

morajabi commented 7 years ago

Great! I'm going to close this issue now (fixed by #9)