-
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
Tree-shaking broken. Erroneous [ignored-bare-import]
warning. import type
statements possible culprit.
#2334
Comments
I have read your post several times but I can't figure out what your problem is exactly. Can you provide a code example that demonstrates the problem? If |
It's a two-sided problem. Part of the problem is that I'm importing a library that has rogue import statements into an The other part of the problem is that the library includes these rogue import statements. I'm using I'm not doing anything strange in the repo either. There's a large, obvious tree of pure config that can be shaken that simply isn't getting removed. Anyway, I've been able to reproduce the problem in a stripped down version of my monorepo, but it's still fairly large, so I'll try to whittle it down some more tomorrow before posting it. |
Marking as unactionable until a demonstration of the issue is provided. |
Closing the issue for now. I was able to prevent the library bundle from sprouting those bare imports. Tree shaking in the app is still not working, but it may be due to args passed in by the AWS CDK. |
I'm using esbuild in a monorepo to bundle a library, then rebundle it in a second package (specifically, a serverless func). However, I'm getting a series of errors that completely breaks tree-shaking, resulting in a 5MB bundle instead of about 300kb.
The problem seems to be that during the initial bundling process, many of the imports are tree-shaken, but the bare import statements remain:
Those files shouldn't be included at all. The package is marked
"sideEffects": false
. For reference, I'm not directly importing these files into this entry point. They're within animport type {}
statement. The types get dropped, but the web of imports remain. (This seems to be a known issue. #1794 #1435).Some of the apps in this monorepo still use webpack, which shakes away those useless imports just fine. The problem arises when using
esbuild
to bundle a package that depends on the library with the bunk imports.When I do that, I get this warning, 44 times:
Is there workaround for handling this issue? For this particular use-case, the size difference has a big impact on performance.
Thanks.
The text was updated successfully, but these errors were encountered: