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

Not tree shaking with webpack 4 #814

Closed
carrickjason opened this issue Apr 13, 2018 · 3 comments · Fixed by #1015
Closed

Not tree shaking with webpack 4 #814

carrickjason opened this issue Apr 13, 2018 · 3 comments · Fixed by #1015

Comments

@carrickjason
Copy link

When I import { isEmail } from 'validator', It still shows the entire lib with no tree shaking when using webpack 4 for my production build. Could this be solved by adding "sideEffects": false to the package.json as per webpacks docs?

@chriso
Copy link
Collaborator

chriso commented May 3, 2018

I'm not sure, but happy to accept a PR with a fix.

@RobertFischer
Copy link

@chriso -- Are there any files you're aware of which cause side effects (eg: assign to global variables, etc.)? I'm not seeing anything, but I can look again.

If the modules really are all pure, then we can do what the original user suggested and enable tree shaking by adding "sideEffects": false to the package.json, and I'll submit a PR.

@banjankri
Copy link
Contributor

We are also facing this issue, unused validators are not tree-shaken away. As per the docs I can see two problems here:

  1. as said previously the sideEffects not being set
  2. webpack documentation requires original import/export statements to be preserved for the tree-shaking and it seems they are transpiled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants