-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
Generate UMD build with Rollup #964
Conversation
@gaearon What do you think about this? One of the nice side benefits is a more readable UMD output, and a removal of the ugly Webpack bootstrap code. The tradeoff being you now have two build tools in the same project. But for the UMD end user, it's a win. |
I want to wait for Lodash 4 to come out and then revisit, per #928 (comment) |
var replace = require( 'rollup-plugin-replace' ); | ||
|
||
var env = process.argv[2] === '--prod' ? 'production' : 'development'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about process.argv.indexOf('--prod') >= 0
, then it can be on any argument.
I'd love to use redux in a project where we rollup everything. As far as I know, it is not possible to rollup an application that imports redux, neither with redux's main, jsnext:main nor the dist/redux.js. :( |
Redux has UMD build in dist folder. |
Can you please explain why Redux currently cannot be used with Rollup? |
@gaearon Hi, sorry for my delay. I finally succeeded building a simple redux example (yes!!!) using some of @Rich-Harris PR's ideas. The main issue that it did not work in the first place was that I was missing I setup a gist with 2 builds, one using es6 import and one commonjs require. Download https://gist.github.com/thisconnect/af9c83ed56e9d554f63b Thanks btw for the video's I love them! :) |
@gaearon EDIT: #1042 |
I'm happy to fix it but I can't figure out how to create a Rollup project reproducing the issue with Redux. Can you help me by pointing me at one? |
@gaearon via cli import npm from 'rollup-plugin-npm';
export default {
entry: 'src/index.js',
dest: 'dist/index.js',
format: 'iife',
plugins: [
npm({ jsnext: true })
]
}; |
The best way I've found to use Redux with Rollup is by building it separately: https://github.com/Rich-Harris/rollup-redux-debug. Lil' bit hacky but it works, and is very space-efficient! #1042 would render the custom build unnecessary. |
Thanks, looks great! Updated gist to use Redux 3.3.1 and removed commonjs plugin. main.iife.min.js shrank from 2,972 bytes (with Redux 3.2.1) to 2,202 bytes (with Redux 3.3.1) |
I’m still up for adding this, but it currently doesn’t merge cleanly. |
This PR generates a UMD build with Rollup, per @gaearon's suggestion on #928. The goal is to produce more compact, readable output.
It doesn't change the
build:lib
task, as Rollup only bundles modules rather than doing 1:1 transpilation, but I could amend the PR to create a CommonJS bundle inlib
if that's desirable.Zipped size is 14.5% smaller than the current build: