Skip to content

Optimize CommonJS and module build#477

Merged
eddywashere merged 4 commits intoreactstrap:masterfrom
balloob:optimize-commonjs-build
Jun 28, 2017
Merged

Optimize CommonJS and module build#477
eddywashere merged 4 commits intoreactstrap:masterfrom
balloob:optimize-commonjs-build

Conversation

@balloob
Copy link
Copy Markdown
Contributor

@balloob balloob commented Jun 26, 2017

This PR will split our Rollup config in two: one for the CJS/ES build and one for UMD. This is a backwards compatible change. It will also address the minimized name issue that people experienced in Storybook.

Bundled output (names link to the actual output):

image

The CJS/ES builds will not include any dependency and will not be minimized. These builds are going to be consumed by other bundlers and thus will be minimized when bundled for production (if the user chooses so). These bundles will be returned when require('reactstrap') or import Reactstrap from 'reactstrap';.

If you want to cherry pick only specific components:

With CommonJS: const Card = require('reactstrap/lib/Card');
With modules: import { Card } from 'reactstrap';

The UMD build is meant to be included directly on a webpage and will include the dependencies but not the peer dependencies. I've added a check so that when people add a peer dependency but not add it to the UMD globals object, it will fail the build.

This PR includes #474 as it was needed to generate correct builds.

CC @TheSharpieOne

Testing

To update source to run tests against the CommonJS build:

sed -i "" "s/\.\.\/\'/\.\.\/\.\.\/dist\/reactstrap.cjs'/" src/__tests__/*.spec.js

To update source to run tests against the module build:

sed -i "" "s/\.\.\/\'/\.\.\/\.\.\/dist\/reactstrap.es'/" src/__tests__/*.spec.js

To update source to run tests against the UMD build:

sed -i "" "s/\.\.\/\'/\.\.\/\.\.\/dist\/reactstrap.min'/" src/__tests__/*.spec.js

@eddywashere
Copy link
Copy Markdown
Member

@balloob thanks! can you fix conflicts?

@balloob
Copy link
Copy Markdown
Contributor Author

balloob commented Jun 27, 2017

@eddywashere done.

@eddywashere eddywashere merged commit 4e54609 into reactstrap:master Jun 28, 2017
@balloob balloob deleted the optimize-commonjs-build branch June 28, 2017 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants