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

Find a way to automatically test against Webpack's tree-shaking #9

Open
lukastaegert opened this issue Aug 27, 2017 · 1 comment
Open

Comments

@lukastaegert
Copy link
Owner

Currently, eslint-plugin-tree-shaking features a test suite of > 350 code snippets which are also automatically run against rollup. These tests check that if code is not tree-shaken, then there needs to be an ESLint error. That is, you can be fairly certain that if there are no ESLint errors, you do not have any hidden side-effects in rollup. Unfortunately, the same cannot be said for Webpack. This is particularly bad since Webpack is the final bundler for most Webapps and those would benefit most from tree-shaking.
What I am looking for is a way to run a code snippet through Webpack and reliably determine if tree-shaking would remove this snippet. Main problems:

  • Webpack always adds a lot of boilerplate code which is always present
  • Tree-shaking is realized via comments. In order for the code to be actually removed, Uglify needs to be run
  • After minification, it is even more difficult to determine which code is boilerplate and which is not
    If anyone has some good ideas here, this would be greatly appreciated.
@bluepnume
Copy link

bluepnume commented Oct 25, 2018

What about running webpack+uglify twice for a given code snippet, once with tree-shaking enabled, once without, and diffing the two outputs? If they're the same, tree shaking has failed, and that can be used to either pass or fail the test.

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

No branches or pull requests

2 participants