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

Enable better tree-shaking in builds #408

Closed
FredKSchott opened this issue Jun 1, 2020 · 2 comments · Fixed by #421
Closed

Enable better tree-shaking in builds #408

FredKSchott opened this issue Jun 1, 2020 · 2 comments · Fixed by #421
Assignees

Comments

@FredKSchott
Copy link
Owner

Original Discussion: https://www.pika.dev/npm/snowpack/discuss/274
/cc @Ciantic, @FredKSchott

Currently, Snowpack installs every package into a single JS file. As a result, any non-treeshakable code in one package file infects the rest of the package. This means that large packages like fluentui end up not being tree-shakable when you go and build for production.

I can think of two solutions:

  1. Add back our tree-shaking install support, which tree-shakes as a part of installing your web_modules/ dependencies. This was removed since we thought we didn't need it anymore, but it may make sense to add back. This would force us to re-install dependencies on every build, which is a safer move as well but will slow down production builds a bit more than they are now.

  2. Stop using web_modules/ when you build with a bundler. This would give bundlers the highest-fidelity package code to bundle from, but at the expense of complicating how much bundler plugins now need to support. Different bundlers would handle dependencies differently, leading to confusion and complexity.

I'm leaning towards #1 to start, but open to feedback/thoughts.

@FredKSchott FredKSchott added the bug Something isn't working label Jun 1, 2020
@lessless
Copy link

lessless commented Jun 2, 2020

As a person who bangs his head against the wall everytime when I have to deal with Webpack I plead for keeping it simple on configuration side. Please :)

@Ciantic
Copy link

Ciantic commented Jun 2, 2020

If the internal installer uses Rollup, I would think that using Rollup's tree-shaker would be the right choice when doing a build? Then we don't need webpack or other bundlers to do it again.

Edit Also I want to note that tree-shaking should be standardized, it's bad that there are multiple algorithms for it. It's difficult to test if any given package have broken the tree-shaking rules if it's algorithm is not set in stone.

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 a pull request may close this issue.

3 participants