-
Notifications
You must be signed in to change notification settings - Fork 23
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
Ship a module build #58
Comments
Am I correct in thinking there would be 2 libraries in the repo. One using import syntax, the other running that import syntax and creating a webpack library? |
There would be 2 libraries shipped to NPM. One with require syntax, and one with import. Otherwise, the two versions would be exactly the same (in terms of their transpilation to ES5). You can make both the commonjs and and module builds using babel (it's the modules config option in You can do it with babel (no webpack needed). I'd propose having two build commands in package.json, for example, Here's an example babel config and build commands from a project I manage. |
I would prefer having one NPM package and using something like You could go ahead and develop on PR for this if you want to. It sounds worthwhile. |
Everything will still ship as one NPM module. I meant two libraries within the existing It's best to use the For example, suppose in source code you were require If the package author declares defines I'll do a PR for it soon. Since it's totally backwards compatible and won't break anyone, I think you'll be happy to accept it. |
@petermikitsh Just wondering if this ever happened? |
If you look at the latest commonJS build, you'll see this require statement:
This imports all of redux-actions -- which doesn't sound like a lot, but they depend a lot of utilities, for example,
lodash.curry
-- which is 33kb. Only createAction and handleActions are imported. (A different function in the redux-actions library imports lodash.curry).I propose we ship a module build. Module builds are just like commonjs builds, except they use ES Module import syntax -- which is important for tree-shaking.
It's 100% backwards-compatible. You'd add a "module" property to package.json to point to the ES module build. Then people using tools like rollup and webpack will get the benefits of treeshaking awesomeness.
The text was updated successfully, but these errors were encountered: