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

Compile npm package to ES5 #5

Closed
MarttiR opened this issue Jan 29, 2018 · 11 comments
Closed

Compile npm package to ES5 #5

MarttiR opened this issue Jan 29, 2018 · 11 comments

Comments

@MarttiR
Copy link

MarttiR commented Jan 29, 2018

The npm package should be compiled to ES5, because ES6 dependencies are not supported by create-react-app:

$ yarn build
yarn run v1.3.2
$ react-scripts build
Creating an optimized production build...
Failed to compile.

Failed to minify the code from this file:

 	./node_modules/redux-bundler/src/utils.js:1

Read more here: http://bit.ly/2tRViJ9

error Command failed with exit code 1.
@HenrikJoreteg
Copy link
Owner

Hey @MarttiR!

Looking at that, it seems your build is grabbing src/utils.js which is the uncompiled source instead of "main" as specified in package.json which is index.js. There could be something wrong in redux-bundler too, but if you require stuff from index.js it should all be es5.

@HenrikJoreteg
Copy link
Owner

Feel free to re-open if this is still an issue, but I'll close this for now.

@MarttiR
Copy link
Author

MarttiR commented Feb 5, 2018

Now that I had some more time to dig around: it seems that the reason for this error is that the module keyword in package.json should point to an ES6 module, but it should not contain any ES6 code.

So yeah, this is still an issue.

See facebook/create-react-app#3889 for more.

@HenrikJoreteg
Copy link
Owner

Cool, makes sense.

@HenrikJoreteg
Copy link
Owner

@MarttiR thanks again. I've published a new version 17.0.1 that should fix this for you.

It's now built using microbundle and the module field now points to a compiled version in /dist instead of the main (uncompiled) entry point. This should resolve things, hopefully. Thanks again and please let me know if it doesn't. Cheers!

@MarttiR
Copy link
Author

MarttiR commented Feb 22, 2018

Thanks a lot for this! I've used redux-bundler for the past few weeks and the developer experience has been fantastic compared to plain redux.

It's awesome. You're awesome. Thank you.

@greggb
Copy link
Contributor

greggb commented Apr 6, 2018

Possibly related, Bundler gives me the redux 'minified' warning in development - You are currently using minified code outside of NODE_ENV === 'production'. And it is in fact giving me minified console errors. Any ideas?

@HenrikJoreteg
Copy link
Owner

@greggb what you're seeing is a separate issue from what these folks were talking about. It's due to the fact that microbundle which we use to compile redux-bundler minifies code by default, we need to change it to build without minification, this error is rather annoying (I'll open a ticket for this).

@HenrikJoreteg
Copy link
Owner

@greggb if you install latest 21.0.1 you should no longer see the warning

@greggb
Copy link
Contributor

greggb commented Apr 7, 2018

Sorry for the mis-categorization @HenrikJoreteg - wanted to avoid opening a new issue if something already existed. That did the trick! Thanks very much for looking into it. Having a blast moving from sagas to bundler (especially now that I can see the actual errors 😄).

@HenrikJoreteg
Copy link
Owner

@greggb sweet! Glad you're enjoying it :) Don't hesitate to file issues and send PRs though, if you have any trouble.

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

No branches or pull requests

3 participants