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

[BUG] code splitting error on build #19

Closed adnanfajlur closed 4 years ago

adnanfajlur commented 4 years ago

got incorrect build with ...args on component

image

success without ...args

image

thanks

HarveyD commented 4 years ago

Okay so after a bit of experimenting, I've found this happens because of the @rollup/plugin-node-resolve plugin.

When Rollup needs to bundle packages from node_modules, this plugin will mess up the directory structure of our output. In this case, it's bundling tslib (you can see this under node_modules in build).

To solve this, you can:

I've updated the branch without the @rollup/plugin-node-resolve plugin which has fixed the issue. The downside of removing this plugin is that our bundle won't be able to benefit from Node Resolution Algorithm

adnanfajlur commented 4 years ago

it works dude, thanks 😁👌

mnlbox commented 4 years ago

@HarveyD Can you explain this?

The downside of removing this plugin is that our bundle won't be able to benefit from Node Resolution Algorithm.

What we are exactly lost in after remove resolve() from plugins for code splitting?