FormidableLabs / radium-component-library

Temporary repository to nail down design principles for Radium Components.
0 stars 0 forks source link

ES6 Modules / Publishing an ES6 Version #3

Open ianobermiller opened 8 years ago

ianobermiller commented 8 years ago

Since radium (née radium-ui) will become an aggregator module, it would be really cool if we could figure out a way to publish an ES6 version of the code (that only requires babel's es2015 preset) so that users don't have to import individual modules to avoid code bloat. As long as they use tooling like rollup or webpack2, tree-shaking or dead-code elimination will happen automatically.

coopy commented 8 years ago

I'd appreciate if someone could look into the correct webpack configuration + tooling to make this happen!

tptee commented 8 years ago

Some info on getting Babel to export ES6 modules rather than CommonJS: http://www.2ality.com/2015/12/webpack-tree-shaking.html https://www.npmjs.com/package/babel-preset-es2015-webpack2

ianobermiller commented 8 years ago

What if we publish as a tag on NPM? radium@es6 could provide the pure ES6 modules, requiring babel-preset-es2015 at minimum.

tptee commented 8 years ago

I've got tree-shaking working in the Radium archetype: https://github.com/FormidableLabs/builder-radium-component/commit/8b68ee930cf3ab48f32969f5a20d5e70b6f9bf60

What would be a good convention for which folder the ES6 modules go in? Is it equivalent to what's in src/? Maybe an es6 folder with a package.json tagged as radium@0,17.0-es6?

tptee commented 8 years ago

Maybe lib-es6?

coopy commented 8 years ago

If we publish an es6-specific tag and npm module, I think we could just replace lib/ with the es6 modules.