-
-
Notifications
You must be signed in to change notification settings - Fork 877
Closed
Copy link
Labels
A-transformerArea - Transformer / TranspilerArea - Transformer / Transpiler
Description
When the value on the left side (foo) of import foo = bar.baz is not used, TypeScript removes the whole import ... = ... (TS playground). But Oxc does not remove them (playground).
While Babel does not implement this behavior (REPL), esbuild (esbuild try) and SWC (SWC playground) does.
The ones that implements this behavior removes import ... = ... completely, but there's an alternative way to achieve the same behavior. It is to add pure annotation to the member access.
// the behavior implemented by esbuild & SWC & TS
const a = foo.a;
const b = a.b;
const c = b.c;
export let bar = c;
// the alternative
var a = foo.a;
var b = a.b;
var c = b.c;
var x = /* #__PURE__ */ (() => foo.x)();
var y = /* #__PURE__ */ (() => x.y)();
export let bar = c;Reactions are currently unavailable
Metadata
Metadata
Labels
A-transformerArea - Transformer / TranspilerArea - Transformer / Transpiler