fix(transformer/decorator): do not lose WeakMap when decorator and class properties transforms combined#9952
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Instrumentation Performance ReportMerging #9952 will create unknown performance changesComparing Summary
Benchmarks breakdown
|
|
Your esbuild configuration is wrong, the decorator is treated as ES Decorator, you should set |
Shame on me! Thanks for pointing that out. Odd that ESBuild produces less optimal output for legacy decorators. But, regardless of what ESBuild does, I think retaining the |
Merge activity
|
…class properties transforms combined (#9952) Closes #9171. Prevent injected statements attached to the `Class` statement getting lost when `class C {}` is replaced with `let C = class C {};` by moving them to be attached to the new `let C` statement. --- I'm actually unclear why we have to transform `class C {}` to `let C = class C {};` anyway. `class C {}` already creates a binding `C` which behaves like a `let` binding, so it can be reassigned. Input: ```js @dec export class C {} ``` Current output: ```js let C = class C {}; C = babelHelpers.decorate([dec], C); export { C }; ``` Could just be: ```js export class C {} C = babelHelpers.decorate([dec], C); ``` [ESBuild does this](https://esbuild.github.io/try/#dAAwLjI0LjAALS10YXJnZXQ9ZXMyMDIwAEBkZWMoKQpjbGFzcyBGb28gewogICNiYXIgPSAiYmFyIjsKICB0ZXN0KCkgeyByZXR1cm4gdGhpcy4jYmFyOyB9Cn0K) - it keeps the class declaration.
9bdd489 to
af78acb
Compare
03051ae to
c7fc700
Compare

Closes #9171.
Prevent injected statements attached to the
Classstatement getting lost whenclass C {}is replaced withlet C = class C {};by moving them to be attached to the newlet Cstatement.I'm actually unclear why we have to transform
class C {}tolet C = class C {};anyway.class C {}already creates a bindingCwhich behaves like aletbinding, so it can be reassigned.Input:
Current output:
Could just be:
ESBuild does this - it keeps the class declaration.