babel / generator-babel-boilerplate

A Yeoman generator to author libraries in ES2015 (and beyond!) for Node and the browser.
MIT License
380 stars 57 forks source link

Add Rollup option to the CLI #319

Open jamesplease opened 8 years ago

jamesplease commented 8 years ago

Should we move from Webpack to Rollup? Part of the motivation to Webpack originally had to do with lack of support in Rollup, though this now seems to largely be fixed.

@paulfalgout , I know you prefer Rollup. What are you thinking of the pros/cons?

@megawac, do you have any thoughts?


Another option would be/could be to switch back to Browserify.

This issue supersedes #310


Pros to switching to Rollup

Cons to switching to Rollup

paulfalgout commented 8 years ago

The more I use rollup the more I like it for libraries.

It is focused on building libraries over other concerns, and it is pretty simplistic in what it is doing, which I think is good for libraries as well. It's also fast and lightweight, which for any library testing for multiple environments can be important. And while it isn't hugely important, the output is very readable and not littered with _interopRequireDefault statements and other loader stuff.

And recently https://github.com/eventualbuddha/rollup-plugin-multi-entry was added so I think this could potentially be used for compiling the tests as well. Pretty ideal.

jamesplease commented 8 years ago

Gonna try to do this this week.

Note to self: this PR, https://github.com/marionettejs/backbone.radio/pull/247 , can be used as a reference. Thanks for doing the hard work, @megawac!

jamesplease commented 8 years ago

Note to self: here's the rollup API stuff that's relevant to me: https://github.com/rollup/rollup/wiki/JavaScript-API

jamesplease commented 8 years ago

One difference between webpack and Rollup is that webpack tends to "Just Work" when it comes to importing, whereas Rollup tends to "Just Break." I'll prob. need to add a specific piece of information to the README that explains Rollup's out-of-the-box-behavior and its plugin ecosystem.

jamesplease commented 8 years ago

Another thing to consider is that Rollup lacks incremental builds.

https://github.com/rollup/rollup/issues/191

There will be some early adoption costs for switching to Rollup at this stage, but so far it seems like things I'm OK dealing with for the time being.

jamesplease commented 8 years ago

I converted a lib of mine to Rollup to see how it'd go. That work is here:

https://github.com/jmeas/bizniz.js/pull/10

Next up is upstreaming it to this boilerplate.

Another issue with Rollup is that the plugin for Babel excludes modules. This sucks for ES2015 gulpfiles, because it makes .babelrc ONLY describe the Gulpfile. The library's Babel config will need to be specified in the Gulpfile directly. That's a real bummer.

paulfalgout commented 8 years ago

I dunno that webpack does that much more out of the box that is useful to libraries. It does bake in some plugins.. consequently.. if we stick with uglify, webpack has it baked in and we could use that. but you still have to load a json loader and a babel loader. Most of the added plugins for rollup are to support browser testing.

Additionally if you're making very small libraries, webpack adds the loader.. where as rollup adds so very little.

Also rollup is much smaller than webpack.. not a huge deal, but if you're running tests across a matrix (as you might want to do for a library) that install time can add up quick.

I use webpack at the day job.. in many ways it is superior to rollup, but I think rollup is uniquely positioned for building libraries and I suspect that will only improve with time. I'm also not sure that the cons of rollup will be felt by the end user of the boilerplate

jamesplease commented 8 years ago

Thanks for the feedback, @paulfalgout ! I agree with a lot of that :v: Definitely leaning toward Rollup atm.

megawac commented 8 years ago

Both definitely have pros and cons. As you mentioned, its harder to goof up when bundling with webpack (except for accidentally bundling dependencies I suppose), whereas several issues can crop up with rollup. I think it probably makes sense to create a package.json and gulp configuration for both webpack and rollup and let the user select the bundler they prefer. Personally I will pretty much always go with rollup but webpack will generally be the more flexible option (and I'd say it should be the default).

paulfalgout commented 8 years ago

saw this today: https://github.com/kriasoft/babel-starter-kit

jamesplease commented 8 years ago

Interesting idea to set it behind a flag, @megawac.

Do you think it should be a prompt, as in:

Would you like to use Webpack or Rollup?

or a flag, as in yo babel-boilerplate --rollup?

megawac commented 8 years ago

Yeah, or as one of the options (in a select menu) for yo babel-boilerplate

jamesplease commented 8 years ago

Cool, cool. I like that idea. What do you think, @paulfalgout ?