HarveyD / react-component-library

A project skeleton to get your very own React Component Library up and running using Rollup, Typescript, SASS + Storybook
https://blog.harveydelaney.com/creating-your-own-react-component-library/
MIT License
790 stars 167 forks source link

[Feature] Enable code splitting in main branch #20

Open mnlbox opened 4 years ago

mnlbox commented 4 years ago

I think it's a good idea to enable code splitting and esm export together in the main branch. Then we can have esm and also split cjs version together. And use our component in both ways like this for es import:

import { Button } from 'component-library'

and like this, if we have default export:

import Button from 'component-library/src/Button'

or like this, of we have named export:

import { Button } from 'component-library/src/Button'

@HarveyD What's your idea?

HarveyD commented 4 years ago

I don't want to include code splitting in the main branch due to the issues that exist around with code splitting and bundling 3rd party dependencies. If I can sort this out, I'd consider it :).

Also, I don't believe you can have cjs and esm code split outputs in the same directory. This increases the length of our imports which I'd rather avoid.