-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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: can we get list of tree-shaken modules (which were marked as external?) #1939
Comments
You can use plugins to track every import expression and mark some of them as external and collect them. In fact, I had the same requirement months ago to help me find out unused dependencies in package.json, and I quickly written one: |
Cheers. We do actually have a plugin that collects these however resolve appears to happen before tree-shaking meaning that you will collect modules that may never actually be used (as indicated by the fact the tree-shaking algorithm removes them from the bundle later). |
We are reparsing bundle with Typescript (as we had that available in CDK, but you may use any other, including esbuild itself) like that https://gist.github.com/tinovyatkin/727ddbf7e7e10831a1eca9e4ff2fc32e. As as reporting in #1933 the |
Thank you @evanw |
This would be useful for building up minimal package.json dependencies of lambda functions. We track modules marked as external to create and install the minimal production dependencies for a given entry point however we currently (without a second parse) know if any of these external modules were dead-code anyway (which tree-shaking encapsulates the logic of).
Is it possible to expose this if it's not available already?
The text was updated successfully, but these errors were encountered: