You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When preserveValueImports is true, the output behavior differs from TypeScript compiler. I thought a bit strange about the TS compiler's behavior at first, but it seems intended.
Esbuild should probably behave like TS compiler in this case and remove the whole unused import line, otherwise it is keeping an empty import line which breaks tree-shaking/code-splitting in bundlers using esbuild like vite
When preserveValueImports is false, no discrepancies, it becomes:
Hello,
I'm copying the comment from @sapphi-red found in this vite issue: vitejs/vite#8339 (comment)
Repro
When
preserveValueImports
istrue
, the output behavior differs from TypeScript compiler. I thought a bit strange about the TS compiler's behavior at first, but it seems intended.Esbuild
TS compiler remove the import line
"preserveValueImports":true
(esbuild repl)"preserveValueImports":true
(ts playground)Expected behaviour
Esbuild should probably behave like TS compiler in this case and remove the whole unused import line, otherwise it is keeping an empty import line which breaks tree-shaking/code-splitting in bundlers using esbuild like vite
When
preserveValueImports
isfalse
, no discrepancies, it becomes:"preserveValueImports":false
(esbuild repl)"preserveValueImports":false
(ts playground)The text was updated successfully, but these errors were encountered: