HenrikJoreteg / redux-bundler

Compose a Redux store out of smaller bundles of functionality.
https://reduxbundler.com
583 stars 46 forks source link

Compile npm package to ES5 #5

Closed MarttiR closed 6 years ago

MarttiR commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

MarttiR commented 6 years ago

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 https://github.com/facebook/create-react-app/issues/3889 for more.

HenrikJoreteg commented 6 years ago

Cool, makes sense.

HenrikJoreteg commented 6 years ago

@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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

@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 commented 6 years ago

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

greggb commented 6 years ago

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 commented 6 years ago

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