-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Reduce element decorator temp variables #16280
Reduce element decorator temp variables #16280
Conversation
Due to #16218 (comment) , I suspect this will need to wait until tc39/proposal-decorators#524 is implemented. |
* @param {DecoratorInfo[]} info | ||
* @returns {DecoratorInfo[]} Sorted decoration info | ||
*/ | ||
function toSortedDecoratorInfo(info: DecoratorInfo[]): DecoratorInfo[] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this PR is not depending on tc39/proposal-decorators#524, since any normative change of decorator application ordering should be implemented within toSortedDecoratorInfo
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just saw the latest PR description and thought it was good.
862f427
to
f984a7d
Compare
e9fd071
to
ff2288d
Compare
Also improve decoratorThis storage. It turns out we don't have to maintain the map from decorator to its this value.
f984a7d
to
0977e10
Compare
version, | ||
); | ||
const { decs } = decorationList; | ||
decoratorsHaveThis = decorationList.hasThis; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: we should unify haveThis
and hasThis
.
let _Foo; | ||
class Foo { | ||
static { | ||
({ | ||
e: [_initProto], | ||
c: [_Foo, _initClass] | ||
} = babelHelpers.applyDecs2311(this, [[[void 0, dec, void 0, _dec, void 0, _dec2, void 0, _dec3, _obj2, _dec4], 18, "method"]], _classDecs, 1)); | ||
} = babelHelpers.applyDecs2311(this, [[_methodDecs, 18, "method"]], _classDecs, 1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm missing something onvious, byt why do we need the temporary variable at all? This code behaves identically to
_classDecs = [void 0, dec, void 0, call(), void 0, chain.expr(), void 0, arbitrary + expr, _obj, _obj[expr]];
_obj2 = array;
class Foo {
static {
({
e: [_initProto],
c: [_Foo, _initClass]
} = babelHelpers.applyDecs2311(this, [[[void 0, dec, void 0, call(), void 0, chain.expr(), void 0, arbitrary + expr, _obj2, _obj2[expr]], 18, "method"]], _classDecs, 1));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need the temporary variable at all?
Because computed keys have to be interleaved with decorator evaluations and the static block is evaluated after a method with computed key is defined.
If there aren't computed keys, we could move element decorators into the static block with the following caveat:
- If there is
super()
within the decorator, we should capture and replace the super call first before moving to the static block. There is even a testpackages/babel-plugin-transform-class-properties/test/fixtures/nested-class/super-call-in-decorator/exec.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see. Let's merge this as-is for now, I'll experiment to see how much complex supporting it would be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: The current proposal has a discussion about order, which would be much simpler if the changes were accepted.
tc39/proposal-decorators#524
Also I have an idea about a bindDecs
helper.
Similar to the behavior of ts, call fn.bind(obj)
directly or use a closure to save it. This way we can simplify the logic and reduce some void 0
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there are computed keys, eventually the element decorator evaluations should be pushed to the computed key to ensure that they have proper private element (The last opening ticket in #16117).
When the class is decorated, the situation become more complicated because some keys are moved further inside to the non-statics class. The inside class has more complete private environment access but it is defined later than the other method elements in the outside statics class. We may have to capture private access (even potentially reuse those passed to the applyDecs
) as well.
* optimize: allocate temp variable for every decorated element * update test fixtures * refactor: sort decorator info once * refactor: simplify maybeExtractDecorators interface Also improve decoratorThis storage. It turns out we don't have to maintain the map from decorator to its this value. * refactor: rename maybeExtractDecorators to handleDecoratorExpressions * unify haveThis and hasThis
* optimize: allocate temp variable for every decorated element * update test fixtures * refactor: sort decorator info once * refactor: simplify maybeExtractDecorators interface Also improve decoratorThis storage. It turns out we don't have to maintain the map from decorator to its this value. * refactor: rename maybeExtractDecorators to handleDecoratorExpressions * unify haveThis and hasThis
* optimize: allocate temp variable for every decorated element * update test fixtures * refactor: sort decorator info once * refactor: simplify maybeExtractDecorators interface Also improve decoratorThis storage. It turns out we don't have to maintain the map from decorator to its this value. * refactor: rename maybeExtractDecorators to handleDecoratorExpressions * unify haveThis and hasThis
* optimize: allocate temp variable for every decorated element * update test fixtures * refactor: sort decorator info once * refactor: simplify maybeExtractDecorators interface Also improve decoratorThis storage. It turns out we don't have to maintain the map from decorator to its this value. * refactor: rename maybeExtractDecorators to handleDecoratorExpressions * unify haveThis and hasThis
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@babel/traverse](https://babel.dev/docs/en/next/babel-traverse) ([source](https://github.com/babel/babel)) | resolutions | minor | [`7.23.9` -> `7.24.1`](https://renovatebot.com/diffs/npm/@babel%2ftraverse/7.23.9/7.24.1) | --- ### Release Notes <details> <summary>babel/babel (@​babel/traverse)</summary> ### [`v7.24.1`](https://github.com/babel/babel/blob/HEAD/CHANGELOG.md#v7241-2024-03-19) [Compare Source](babel/babel@v7.24.0...v7.24.1) ##### 🐛 Bug Fix - `babel-helper-create-class-features-plugin`, `babel-plugin-proposal-decorators` - [#​16350](babel/babel#16350) Fix decorated class computed keys ordering ([@​JLHwung](https://github.com/JLHwung)) - [#​16344](babel/babel#16344) Fix decorated class static field private access ([@​JLHwung](https://github.com/JLHwung)) - `babel-plugin-proposal-decorators`, `babel-plugin-proposal-json-modules`, `babel-plugin-transform-async-generator-functions`, `babel-plugin-transform-regenerator`, `babel-plugin-transform-runtime`, `babel-preset-env` - [#​16329](babel/babel#16329) Respect `moduleName` for `@babel/runtime/regenerator` imports ([@​nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - `babel-helper-create-class-features-plugin`, `babel-plugin-proposal-decorators`, `babel-plugin-proposal-pipeline-operator`, `babel-plugin-transform-class-properties` - [#​16331](babel/babel#16331) Fix decorator memoiser binding kind ([@​JLHwung](https://github.com/JLHwung)) - `babel-helper-create-class-features-plugin`, `babel-helper-replace-supers`, `babel-plugin-proposal-decorators`, `babel-plugin-transform-class-properties` - [#​16325](babel/babel#16325) Fix decorator evaluation private environment ([@​JLHwung](https://github.com/JLHwung)) ##### 📝 Documentation - [#​16319](babel/babel#16319) Update SECURITY.md ([@​nicolo-ribaudo](https://github.com/nicolo-ribaudo)) ##### 🏠 Internal - `babel-code-frame`, `babel-highlight` - [#​16359](babel/babel#16359) Replace `chalk` with `picocolors` ([@​nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - `babel-helper-fixtures`, `babel-helpers`, `babel-plugin-bugfix-safari-id-destructuring-collision-in-function-expression`, `babel-plugin-proposal-pipeline-operator`, `babel-plugin-transform-unicode-sets-regex`, `babel-preset-env`, `babel-preset-flow` - [#​16352](babel/babel#16352) Run Babel transform tests on old node if possible ([@​JLHwung](https://github.com/JLHwung)) - `babel-helpers`, `babel-plugin-transform-async-generator-functions`, `babel-plugin-transform-class-properties`, `babel-plugin-transform-class-static-block`, `babel-plugin-transform-modules-commonjs`, `babel-plugin-transform-modules-systemjs`, `babel-plugin-transform-regenerator`, `babel-plugin-transform-runtime`, `babel-preset-env`, `babel-runtime-corejs3`, `babel-runtime`, `babel-standalone` - [#​16323](babel/babel#16323) Allow separate helpers to be excluded in Babel 8 ([@​liuxingbaoyu](https://github.com/liuxingbaoyu)) - `babel-helper-module-imports`, `babel-plugin-proposal-import-wasm-source`, `babel-plugin-proposal-json-modules`, `babel-plugin-proposal-record-and-tuple`, `babel-plugin-transform-react-jsx-development`, `babel-plugin-transform-react-jsx` - [#​16349](babel/babel#16349) Support merging imports in import injector ([@​nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - `babel-helper-create-class-features-plugin`, `babel-plugin-bugfix-safari-id-destructuring-collision-in-function-expression`, `babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining`, `babel-plugin-bugfix-v8-static-class-fields-redefine-readonly`, `babel-plugin-external-helpers`, `babel-plugin-proposal-async-do-expressions`, `babel-plugin-proposal-decorators`, `babel-plugin-proposal-destructuring-private`, `babel-plugin-proposal-do-expressions`, `babel-plugin-proposal-duplicate-named-capturing-groups-regex`, `babel-plugin-proposal-explicit-resource-management`, `babel-plugin-proposal-export-default-from`, `babel-plugin-proposal-function-bind`, `babel-plugin-proposal-function-sent`, `babel-plugin-proposal-import-attributes-to-assertions`, `babel-plugin-proposal-import-defer`, `babel-plugin-proposal-import-wasm-source`, `babel-plugin-proposal-json-modules`, `babel-plugin-proposal-optional-chaining-assign`, `babel-plugin-proposal-partial-application`, `babel-plugin-proposal-pipeline-operator`, `babel-plugin-proposal-record-and-tuple`, `babel-plugin-proposal-regexp-modifiers`, `babel-plugin-proposal-throw-expressions`, `babel-plugin-syntax-async-do-expressions`, `babel-plugin-syntax-decimal`, `babel-plugin-syntax-decorators`, `babel-plugin-syntax-destructuring-private`, `babel-plugin-syntax-do-expressions`, `babel-plugin-syntax-explicit-resource-management`, `babel-plugin-syntax-export-default-from`, `babel-plugin-syntax-flow`, `babel-plugin-syntax-function-bind`, `babel-plugin-syntax-function-sent`, `babel-plugin-syntax-import-assertions`, `babel-plugin-syntax-import-attributes`, `babel-plugin-syntax-import-defer`, `babel-plugin-syntax-import-reflection`, `babel-plugin-syntax-import-source`, `babel-plugin-syntax-jsx`, `babel-plugin-syntax-module-blocks`, `babel-plugin-syntax-optional-chaining-assign`, `babel-plugin-syntax-partial-application`, `babel-plugin-syntax-pipeline-operator`, `babel-plugin-syntax-record-and-tuple`, `babel-plugin-syntax-throw-expressions`, `babel-plugin-syntax-typescript`, `babel-plugin-transform-arrow-functions`, `babel-plugin-transform-async-generator-functions`, `babel-plugin-transform-async-to-generator`, `babel-plugin-transform-block-scoped-functions`, `babel-plugin-transform-block-scoping`, `babel-plugin-transform-class-properties`, `babel-plugin-transform-class-static-block`, `babel-plugin-transform-classes`, `babel-plugin-transform-computed-properties`, `babel-plugin-transform-destructuring`, `babel-plugin-transform-dotall-regex`, `babel-plugin-transform-duplicate-keys`, `babel-plugin-transform-dynamic-import`, `babel-plugin-transform-exponentiation-operator`, `babel-plugin-transform-export-namespace-from`, `babel-plugin-transform-flow-comments`, `babel-plugin-transform-flow-strip-types`, `babel-plugin-transform-for-of`, `babel-plugin-transform-function-name`, `babel-plugin-transform-instanceof`, `babel-plugin-transform-jscript`, `babel-plugin-transform-json-strings`, `babel-plugin-transform-literals`, `babel-plugin-transform-logical-assignment-operators`, `babel-plugin-transform-member-expression-literals`, `babel-plugin-transform-modules-amd`, `babel-plugin-transform-modules-commonjs`, `babel-plugin-transform-modules-systemjs`, `babel-plugin-transform-modules-umd`, `babel-plugin-transform-new-target`, `babel-plugin-transform-nullish-coalescing-operator`, `babel-plugin-transform-numeric-separator`, `babel-plugin-transform-object-assign`, `babel-plugin-transform-object-rest-spread`, `babel-plugin-transform-object-set-prototype-of-to-assign`, `babel-plugin-transform-object-super`, `babel-plugin-transform-optional-catch-binding`, `babel-plugin-transform-optional-chaining`, `babel-plugin-transform-parameters`, `babel-plugin-transform-private-methods`, `babel-plugin-transform-private-property-in-object`, `babel-plugin-transform-property-literals`, `babel-plugin-transform-property-mutators`, `babel-plugin-transform-proto-to-assign`, `babel-plugin-transform-react-constant-elements`, `babel-plugin-transform-react-display-name`, `babel-plugin-transform-react-inline-elements`, `babel-plugin-transform-react-jsx-compat`, `babel-plugin-transform-react-jsx-self`, `babel-plugin-transform-react-jsx-source`, `babel-plugin-transform-react-pure-annotations`, `babel-plugin-transform-regenerator`, `babel-plugin-transform-reserved-words`, `babel-plugin-transform-runtime`, `babel-plugin-transform-shorthand-properties`, `babel-plugin-transform-spread`, `babel-plugin-transform-sticky-regex`, `babel-plugin-transform-strict-mode`, `babel-plugin-transform-template-literals`, `babel-plugin-transform-typeof-symbol`, `babel-plugin-transform-typescript`, `babel-plugin-transform-unicode-escapes`, `babel-plugin-transform-unicode-property-regex`, `babel-plugin-transform-unicode-regex`, `babel-plugin-transform-unicode-sets-regex`, `babel-preset-env`, `babel-preset-flow`, `babel-preset-react`, `babel-preset-typescript` - [#​16332](babel/babel#16332) Test Babel 7 plugins compatibility with Babel 8 core ([@​nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - `babel-compat-data`, `babel-plugin-transform-object-rest-spread`, `babel-preset-env` - [#​16318](babel/babel#16318) \[babel 8] Fix `@babel/compat-data` package.json ([@​nicolo-ribaudo](https://github.com/nicolo-ribaudo)) ##### 🔬 Output optimization - `babel-helper-replace-supers`, `babel-plugin-transform-class-properties`, `babel-plugin-transform-classes`, `babel-plugin-transform-parameters`, `babel-plugin-transform-runtime` - [#​16345](babel/babel#16345) Optimize the use of `assertThisInitialized` after `super()` ([@​liuxingbaoyu](https://github.com/liuxingbaoyu)) - `babel-plugin-transform-class-properties`, `babel-plugin-transform-classes` - [#​16343](babel/babel#16343) Use simpler `assertThisInitialized` more often ([@​liuxingbaoyu](https://github.com/liuxingbaoyu)) - `babel-plugin-proposal-decorators`, `babel-plugin-transform-class-properties`, `babel-plugin-transform-object-rest-spread`, `babel-traverse` - [#​16342](babel/babel#16342) Consider well-known and registered symbols as literals ([@​nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - `babel-core`, `babel-plugin-external-helpers`, `babel-plugin-proposal-decorators`, `babel-plugin-proposal-function-bind`, `babel-plugin-transform-class-properties`, `babel-plugin-transform-classes`, `babel-plugin-transform-flow-comments`, `babel-plugin-transform-flow-strip-types`, `babel-plugin-transform-function-name`, `babel-plugin-transform-modules-systemjs`, `babel-plugin-transform-parameters`, `babel-plugin-transform-private-property-in-object`, `babel-plugin-transform-react-jsx`, `babel-plugin-transform-runtime`, `babel-plugin-transform-spread`, `babel-plugin-transform-typescript`, `babel-preset-env` - [#​16326](babel/babel#16326) Reduce the use of class names ([@​liuxingbaoyu](https://github.com/liuxingbaoyu)) ### [`v7.24.0`](https://github.com/babel/babel/blob/HEAD/CHANGELOG.md#v7240-2024-02-28) [Compare Source](babel/babel@v7.23.9...v7.24.0) ##### 🚀 New Feature - `babel-standalone` - [#​11696](babel/babel#11696) Export babel tooling packages in `@babel/standalone` ([@​ajihyf](https://github.com/ajihyf)) - `babel-core`, `babel-helper-create-class-features-plugin`, `babel-helpers`, `babel-plugin-transform-class-properties` - [#​16267](babel/babel#16267) Implement `noUninitializedPrivateFieldAccess` assumption ([@​nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - `babel-helper-create-class-features-plugin`, `babel-helpers`, `babel-plugin-proposal-decorators`, `babel-plugin-proposal-pipeline-operator`, `babel-plugin-syntax-decorators`, `babel-plugin-transform-class-properties`, `babel-runtime-corejs2`, `babel-runtime-corejs3`, `babel-runtime` - [#​16242](babel/babel#16242) Support decorator 2023-11 normative updates ([@​JLHwung](https://github.com/JLHwung)) - `babel-preset-flow` - [#​16309](babel/babel#16309) \[babel 7] Allow setting `ignoreExtensions` in Flow preset ([@​nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - [#​16284](babel/babel#16284) Add `experimental_useHermesParser` option in `preset-flow` ([@​liuxingbaoyu](https://github.com/liuxingbaoyu)) - `babel-helper-import-to-platform-api`, `babel-plugin-proposal-import-wasm-source`, `babel-plugin-proposal-json-modules`, `babel-standalone` - [#​16172](babel/babel#16172) Add transform support for JSON modules imports ([@​nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - `babel-plugin-transform-runtime` - [#​16241](babel/babel#16241) Add back `moduleName` option to `@babel/plugin-transform-runtime` ([@​nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - `babel-parser`, `babel-types` - [#​16277](babel/babel#16277) Allow import attributes for `TSImportType` ([@​sosukesuzuki](https://github.com/sosukesuzuki)) ##### 🐛 Bug Fix - `babel-plugin-proposal-do-expressions`, `babel-traverse` - [#​16305](babel/babel#16305) fix: avoid `popContext` on unvisited node paths ([@​JLHwung](https://github.com/JLHwung)) - `babel-helper-create-class-features-plugin`, `babel-plugin-transform-private-methods`, `babel-plugin-transform-private-property-in-object` - [#​16312](babel/babel#16312) Fix class private properties when `privateFieldsAsSymbols` ([@​liuxingbaoyu](https://github.com/liuxingbaoyu)) - `babel-helper-create-class-features-plugin`, `babel-plugin-transform-private-methods` - [#​16307](babel/babel#16307) Fix the support of `arguments` in private `get/set` method ([@​liuxingbaoyu](https://github.com/liuxingbaoyu)) - `babel-helper-create-class-features-plugin`, `babel-helpers`, `babel-plugin-proposal-decorators` - [#​16287](babel/babel#16287) Reduce decorator static property size ([@​liuxingbaoyu](https://github.com/liuxingbaoyu)) - `babel-helper-create-class-features-plugin`, `babel-plugin-proposal-decorators` - [#​16281](babel/babel#16281) Fix evaluation order of decorators with cached receiver ([@​nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - [#​16279](babel/babel#16279) Fix decorator this memoization ([@​JLHwung](https://github.com/JLHwung)) - [#​16266](babel/babel#16266) Preserve `static` on decorated private `accessor` ([@​nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - [#​16258](babel/babel#16258) fix: handle decorated async private method and generator ([@​JLHwung](https://github.com/JLHwung)) - `babel-helper-create-class-features-plugin`, `babel-plugin-proposal-decorators`, `babel-plugin-transform-async-generator-functions`, `babel-plugin-transform-private-methods`, `babel-plugin-transform-private-property-in-object`, `babel-plugin-transform-typescript`, `babel-preset-env` - [#​16275](babel/babel#16275) Fix class private properties when `privateFieldsAsProperties` ([@​liuxingbaoyu](https://github.com/liuxingbaoyu)) - `babel-helpers` - [#​16268](babel/babel#16268) Do not consider `arguments` in a helper as a global reference ([@​nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - `babel-helpers`, `babel-plugin-proposal-decorators` - [#​16270](babel/babel#16270) Handle symbol key class elements decoration ([@​JLHwung](https://github.com/JLHwung)) - [#​16265](babel/babel#16265) Do not define `access.get` for public setter decorators ([@​nicolo-ribaudo](https://github.com/nicolo-ribaudo)) ##### 💅 Polish - `babel-core`, `babel-helper-create-class-features-plugin`, `babel-preset-env` - [#​12428](babel/babel#12428) Suggest using `BABEL_SHOW_CONFIG_FOR` for config problems ([@​nicolo-ribaudo](https://github.com/nicolo-ribaudo)) ##### 🏠 Internal - `babel-helper-transform-fixture-test-runner` - [#​16278](babel/babel#16278) Continue writing `output.js` when `exec.js` throws ([@​liuxingbaoyu](https://github.com/liuxingbaoyu)) ##### 🔬 Output optimization - `babel-helper-create-class-features-plugin`, `babel-plugin-proposal-decorators` - [#​16306](babel/babel#16306) Avoid intermediate functions for private accessors with decs ([@​nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - `babel-helper-create-class-features-plugin`, `babel-helpers`, `babel-plugin-proposal-decorators`, `babel-plugin-proposal-pipeline-operator`, `babel-plugin-transform-class-properties` - [#​16294](babel/babel#16294) More aggressively inline decorators in the static block ([@​nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - `babel-helper-create-class-features-plugin`, `babel-helpers`, `babel-plugin-transform-private-methods` - [#​16283](babel/babel#16283) Do not use `classPrivateMethodGet` ([@​liuxingbaoyu](https://github.com/liuxingbaoyu)) - `babel-helper-create-class-features-plugin`, `babel-helpers`, `babel-plugin-proposal-decorators` - [#​16287](babel/babel#16287) Reduce decorator static property size ([@​liuxingbaoyu](https://github.com/liuxingbaoyu)) - `babel-helper-create-class-features-plugin`, `babel-plugin-proposal-decorators`, `babel-plugin-transform-class-properties` - [#​16280](babel/babel#16280) Reduce element decorator temp variables ([@​JLHwung](https://github.com/JLHwung)) - `babel-helper-create-class-features-plugin`, `babel-helper-fixtures`, `babel-helpers`, `babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining`, `babel-plugin-proposal-decorators`, `babel-plugin-proposal-destructuring-private`, `babel-plugin-proposal-optional-chaining-assign`, `babel-plugin-transform-class-properties`, `babel-plugin-transform-class-static-block`, `babel-plugin-transform-private-methods`, `babel-plugin-transform-private-property-in-object`, `babel-preset-env`, `babel-runtime-corejs2`, `babel-runtime-corejs3`, `babel-runtime` - [#​16261](babel/babel#16261) Do not use descriptors for private class elements ([@​nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - `babel-helpers`, `babel-plugin-proposal-decorators` - [#​16263](babel/babel#16263) Reduce helper size for decorator 2023-11 ([@​liuxingbaoyu](https://github.com/liuxingbaoyu)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjAiLCJ0YXJnZXRCcmFuY2giOiJkZXZlbG9wIn0=--> Reviewed-on: https://gitea.vylpes.xyz/RabbitLabs/random-bunny/pulls/156 Co-authored-by: Renovate Bot <renovate@vylpes.com> Co-committed-by: Renovate Bot <renovate@vylpes.com>
This PR is inspired from #16218.
Previously Babel memoises each individual decorator expressions, combines them into an array and passes it to the
applyDecs
helper. In this PR we memoise the combined decorators + decoratorThis array, so we allocate atmost 1 temporary variable for each decorated class fields.Code Example
Input
Output on main
Output on this PR
While the example above shows the output of
2023-11
decorator versions, this optimization is available for other decorator versions later than2021-12
as well.Note that this PR does not seek to memoise all element decorator expressions into one memoiser, since computed keys have to be interleaved with decorator evaluations.
This PR contains commits from #16279. It also contains small memory tweaks.