-
-
Notifications
You must be signed in to change notification settings - Fork 6.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
fix: disable keepNames in vite:esbuild
(fixes #9164)
#9166
fix: disable keepNames in vite:esbuild
(fixes #9164)
#9166
Conversation
✅ Deploy Preview for vite-docs-main canceled.
|
Great find. For deps optimization, the user should never set keep names then as we don't minify, no? I'm a bit confused as to why |
I think we still need it because, |
Would you explain a bit more why |
esbuild says it renames symbols to avoid collisions.
That's a good point. Yeah I think so. BTW maybe we don't have vite/packages/vite/src/node/optimizer/index.ts Lines 585 to 617 in e6f3b02
|
We don't
But I think this shouldn't affect the result because it is applied to library code that if the library is well packaged it should be already tree shaked. Or maybe I'm missing something here. I would imagine that if the keepNames is applied to an internal non-treeshakeable branch then we still have the issue after the post-minify. |
Ah, yes. It will be a problem if a code is not tree-shakable in optimize phase and is tree-shakable in minify phase. For example, when |
…itejs#9166)" This reverts commit e6f3b02.
Description
Transforming a function by esbuild with
keepNames
enabled multiple times will break tree-shaking.Example:
This PR disables
keepNames
invite:esbuild
becausekeepNames
is only needed when minify is enabled.fixes #9164
Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).