Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES decorators bug with inheritance and --bundle #3768

Closed
markandrus opened this issue May 15, 2024 · 0 comments
Closed

ES decorators bug with inheritance and --bundle #3768

markandrus opened this issue May 15, 2024 · 0 comments

Comments

@markandrus
Copy link

With esbuild 0.21.2, given the following file

// test.ts
class Foo {}

const bar = x => x

class Baz extends Foo {
  @bar
  baz() { return Baz }
}

console.log(new Baz().baz())

transforming without the --bundle flag works:

$ esbuild --target=es2022 test.ts >test.js
$ node test.js
[Function: Baz]

Specifying the --bundle flag fails:

$ esbuild --bundle --target=es2022 test.ts >test.js
$ node test.js
/private/tmp/decorator-issue/test.js:60
  __decorateElement(_init, 1, "baz", _baz_dec, _Baz);
                                               ^

ReferenceError: _Baz is not defined
    at /private/tmp/decorator-issue/test.js:60:48
    at Object.<anonymous> (/private/tmp/decorator-issue/test.js:62:3)
    at Module._compile (node:internal/modules/cjs/loader:1369:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
    at Module.load (node:internal/modules/cjs/loader:1206:32)
    at Module._load (node:internal/modules/cjs/loader:1022:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49

Node.js v20.12.2

Here is a repro on esbuild.github.io/try.

@evanw evanw closed this as completed in 66b7c6d May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant