Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: The package is not compatible for tree-shaking #109

Open
savutsang opened this issue Feb 12, 2020 · 1 comment
Open

[BUG]: The package is not compatible for tree-shaking #109

savutsang opened this issue Feb 12, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@savutsang
Copy link
Contributor

savutsang commented Feb 12, 2020

Current behaviour

Projects using webpack that consume this library cannot tree-shake it, it will always import the whole library even if I import only the Button.

Expected behaviour

Only the Button component should be imported.

Steps to reproduce

  1. Add the package in a project, import a Button component
  2. Use Webpack to build (in production mode)
  3. Analyse the built files (the whole package are imported)

Context (version, environment, browser)

Node 12.13.0
Webpack 4.41.2
Typescript 3.7.2

Screenshots (optional)

Additional details (optional)

Webpack can only do tree-shaking on npm packages that are built in a way compatible for tree-shaking (https://webpack.js.org/guides/tree-shaking/#conclusion).
In short, no bundling, keep native import/export, and define sideEffects

In perspective, at Equisoft/analyze, we have different apps working in different scenarios, like some are loaded within the client website or integrated in a already huge apps, so each byte do matter for us. Same as this library, we also like having our npm packages fat too (one package that contains lot of things instead of multiple micro separated packages). For that matter, we make all our npm tree-shakable. Our setup is to use only tsc to compile each file individually instead of webpack.

@savutsang savutsang added the bug Something isn't working label Feb 12, 2020
@christian-roy
Copy link
Contributor

Hi! Thanks for reporting this issue.

This is definitively something that we want to look at as soon as we have some time to work on the core library. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants