egoist / tsup

The simplest and fastest way to bundle your TypeScript libraries.
https://tsup.egoist.dev
MIT License
9.11k stars 218 forks source link

Question: How to keep `class X {}`, avoid `var X = class {}`? #616

Open loynoir opened 2 years ago

loynoir commented 2 years ago

Input

class Foo {}
export { Foo }

Actual Output

var Foo = class {
};
export {
  Foo
};

Expected Output

class Foo {}
export { Foo }

Upvote & Fund

Fund with Polar

sidwebworks commented 2 years ago

@loynoir I think this has to do with making modifications to the actual AST (abstract syntax tree) of the code, and as far as I know, Esbuild does not export expose the internal AST so there isn't really a straightforward way to modify code inside the plugins.

https://esbuild.github.io/plugins/#plugin-api-limitations