-
-
Notifications
You must be signed in to change notification settings - Fork 720
refactor(napi/parser): use minifier to generate JS/TS raw transfer deserializers from single source #14312
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
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 #14312 will not alter performanceComparing Summary
Footnotes |
0b616e8 to
1fbda58
Compare
8dea470 to
066f4a5
Compare
1fbda58 to
77bc09c
Compare
Merge activity
|
…serializers from single source (#14312) Pure refactor. Makes only minor cosmetic changes to the generated raw transfer deserializer code, mainly just alters *how* that code is generated. Previously we generated the source for the 2 different deserializers (JS and TS) separately, with the JS deserializer leaving out some fields e.g. `typeAnnotation`. Instead, generate only 1 base implementation, with TS-only fields gated by `IS_TS`. `IS_TS` is defined as a `const` at top of the file. ```js const IS_TS = true; function deserializeFunction(pos) { const params = deserializeBoxFormalParameters(pos + 56); if (IS_TS) { const thisParam = deserializeOptionBoxTSThisParameter(pos + 48); if (thisParam !== null) params.unshift(thisParam); } return { type: deserializeFunctionType(pos + 84), params, ...(IS_TS && { declare: deserializeBool(pos + 87), typeParameters: deserializeOptionBoxTSTypeParameterDeclaration(pos + 40), }), // ... etc ... }; } ``` Then we generate both the JS and TS deserializers from this same file, by setting the `IS_TS` const to `true` or `false`, and using minifier to shake out the dead code. This: 1. Simplifies custom deserializers. 2. Opens the door to add more `const` flags, e.g. `RANGES` to switch on/off including `range` field in AST nodes.
066f4a5 to
a98757a
Compare
77bc09c to
34e1c0b
Compare
…4372) Pure refactor. Codegen for raw transfer contains logic for generating multiple deserializer variants from a single base implementation, using feature flags to gate certain code, and minifier to shake out dead code in each (#14312). Abstract this functionality into a `VariantGenerator` trait, and move it into the `output` module. This allows reusing the same functionality for other generators.

Pure refactor. Makes only minor cosmetic changes to the generated raw transfer deserializer code, mainly just alters how that code is generated.
Previously we generated the source for the 2 different deserializers (JS and TS) separately, with the JS deserializer leaving out some fields e.g.
typeAnnotation.Instead, generate only 1 base implementation, with TS-only fields gated by
IS_TS.IS_TSis defined as aconstat top of the file.Then we generate both the JS and TS deserializers from this same file, by setting the
IS_TSconst totrueorfalse, and using minifier to shake out the dead code.This:
constflags, e.g.RANGESto switch on/off includingrangefield in AST nodes.