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

DCE unused modules #12

Open
3 of 5 tasks
divmain opened this issue Mar 29, 2016 · 0 comments
Open
3 of 5 tasks

DCE unused modules #12

divmain opened this issue Mar 29, 2016 · 0 comments
Labels

Comments

@divmain
Copy link
Member

divmain commented Mar 29, 2016

360d7b3 added basic tree-shaking functionality. However, as implemented, modules that come away completely unused (and their dependencies) are still included in the module bundles.

  • detect which modules exclusively use ES6 exports
  • of those, detect which modules have ZERO used exports, and mark these for removal
  • for all other modules (which aren't removed, or which use non-ES6 exports), track its dependencies and mark these to keep
  • after all modules have been examined, check for any deep dependencies that aren't marked as keep, and remove them also
  • determine what to do for bundles whose entry points have been DCE'd

Edit: Took a simpler approach to this:

  1. Detect all ES^ imports/exports for all modules.
  2. Go through all modules and mark any imports as used.
  3. For any unused exports, transform exports.foo = foo... into foo... so that it can be removed by a minifier.

This succeeds in removing unused exports from modules. However, this doesn't help determine which sub-dependencies are no longer needed. Need to take another pass at this to come up with a clever way to detect and remove the unused modules from the build.

@divmain divmain added the next label Mar 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant