fix: disable keepNames in vite:esbuild (fixes #9164)#9166
fix: disable keepNames in vite:esbuild (fixes #9164)#9166patak-cat merged 1 commit intovitejs:mainfrom
vite:esbuild (fixes #9164)#9166Conversation
✅ 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
keepNamesenabled multiple times will break tree-shaking.Example:
This PR disables
keepNamesinvite:esbuildbecausekeepNamesis 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).