esbuild
esbuild copied to clipboard
Tree-shaking doesn't work for ES decorators
A dead simple example:
Source code:
// a.js
/* @__PURE__ */
function dec() {
}
@dec
export class A1 {
}
export class A2 {
}
export class A3 {
}
// b.js
import { A2 } from './a';
export class B extends A2 {
}
Build command:
esbuild --bundle ./temp/b.js
The output:
// temp/a.js
function dec() {
}
var A1 = @dec class {
};
var A2 = class {
};
// temp/b.js
var B = class extends A2 {
};
export {
B
};
The expected behavior is dec and A1 are erased.
I'm not sure if I've misunderstood, but I've searched for a long time and haven't found the answer.