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

[Question] Tree Shaking howto? #2999

Closed
1 task done
brikou opened this issue Sep 26, 2017 · 5 comments
Closed
1 task done

[Question] Tree Shaking howto? #2999

brikou opened this issue Sep 26, 2017 · 5 comments

Comments

@brikou
Copy link
Contributor

brikou commented Sep 26, 2017

Because code is run on browser and server, we cannot take full advantage of webpack tree shaking. The code is transformed to commonjs before anything.

How is it possible to take full advantage of tree shaking? (I've tried webpack-common-shake without success)

ESM is landing in node 8.5 with --experimental-module and also available with @std/esm package. Do you have any plan about this?

  • I have searched the issues of this repository and believe that this is not x duplicate.
@lfades
Copy link
Member

lfades commented Sep 26, 2017

Tree Shaking si enabled by default in next as long as you're not using a babel preset that transforms imports in commonjs, also next is using babel-preset-env but without transforming the modules.

@brikou
Copy link
Contributor Author

brikou commented Sep 26, 2017

Are you sure?, because in webpack.js there is a plugin to get it back to commonjs https://github.com/arunoda/next.js/blob/68738d1c904476e9c99989ae5ee12a90c184fbc1/server/build/webpack.js#L228

@lfades
Copy link
Member

lfades commented Sep 26, 2017

Yes, I already asked something similar some days ago
d909c7ac5ca479266459da4447077cb8

Edit: the source is slack

@goldensunliu
Copy link
Contributor

goldensunliu commented Oct 27, 2017

We can either close this issue. Or submit a simple PR to verify the tree shaking output for the people to believe in.

@lock
Copy link

lock bot commented May 10, 2018

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators May 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants