Skip to content
This repository has been archived by the owner. It is now read-only.

Consider using rollup to compile the dist files #2

Open
lucasmotta opened this issue Mar 5, 2016 · 3 comments
Open

Consider using rollup to compile the dist files #2

lucasmotta opened this issue Mar 5, 2016 · 3 comments

Comments

@lucasmotta
Copy link

If you don't know about rollup, I highly recommend having a look into it.
It can output a much smaller distribution file than using babel directly.

I've released a simple react library and I did a lot of tests before deciding to stick with Rollup - it's a big difference, you should give it a try too. The config would be something like this:

import babel from 'rollup-plugin-babel';
import replace from 'rollup-plugin-replace';
import commonjs from 'rollup-plugin-commonjs';
import nodeResolve from 'rollup-plugin-node-resolve';

export default {
  moduleName: 'NameOfYourModuleForAMD',
  entry: './src/index.js',
  dest: './dist/index.js',
  format: 'umd',
  plugins: [babel(), commonjs()],
  globals: {
    react: 'React' // because you don't want to include React on the bundled js
  }
};

Plus you have the benefit of having a UMD package.

And just one smaller thing, I would add "react" as a peerDependency so people can choose the React version they want to use.

@juliancwirko
Copy link
Owner

Hi, I'll take a closer look at rollup.

With current configuration you can also produce UMD modules. By changing babel plugin here you can use http://babeljs.io/docs/plugins/transform-es2015-modules-umd/

@vladshcherbin
Copy link

You can create umd modules, but tree-shaking won't work with webpack.

@juliancwirko
Copy link
Owner

... just info ;) after a long time I plan to rebuild the boilerplate to use rollup

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants