Hello,
I'm copying the comment from @sapphi-red found in this vite issue: vitejs/vite#8339 (comment)
Repro
import { type Map } from 'mapbox-gl';
let MyMap:Map
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
import {} from "mapbox-gl";
let MyMap;
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 is false, no discrepancies, it becomes:
"preserveValueImports":false (esbuild repl) "preserveValueImports":false (ts playground)