brunch / brunch-guide

A comprehensive guide to Brunch
http://brunch.io
MIT License
559 stars 61 forks source link

add comments on using ES6 modules with babel #38

Closed SteveALee closed 8 years ago

SteveALee commented 8 years ago

firstly let me say what excellent documentation this is. Almost all questions I had were clearly answered and I could easily figure how to apply to my existing code.

If only webpack docs were as good. I literally spent several days getting a pretty basic build and dev server setup. And my requirements were similar to brunch conventions with several html files and HMR.

So the one unanswered question is that like I suspect many these days I use Es6 modules via babel. It's not clear how I should configue brunch in this case. I quess we turn modules off but as babel transpiles to commonJS I'm not sure.

goshacmd commented 8 years ago

Nope, babel won't wrap files into modules — brunch still has that covered, no special setup needed.

You can use one of our official skeletons, https://github.com/brunch/with-react maybe, as a reference.

Additionally, https://github.com/brunch/with-redux features HMR use.

SteveALee commented 8 years ago

Oh, I think I get it. Brunch wraps each module in a IEFE to isolate them?

Thanks for the links

goshacmd commented 8 years ago

A bit more than that — by default brunch wraps each file into a CommonJS module. It's configurable (and can be amd or something custom; but npm integration only works with CommonJS for obvious reasons).

http://brunch.io/docs/js-modules-npm.html