-
-
Notifications
You must be signed in to change notification settings - Fork 723
refactor(ast)!: replace ExportDefaultDeclaration exported field with default_span
#12803
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 #12803 will not alter performanceComparing Summary
|
…ith `default_span`
4af75b4 to
9ceca68
Compare
…12808) We currently store the `default` keyword for `ExportDefaultDeclaration` as a `ModuleExportName`. This is overkill because the name is always, by definition, `default`. The only place the `Span` of `default` keyword is used is in `ModuleRecordBuilder`. So essentially storing the span in AST is using the AST as temporary storage - it's only put there so that `ModuleRecordBuilder` can pull it out again. After #12807, we can just pass the span direct to `ModuleRecordBuilder`, and so remove the need for it to be in the AST at all. So we can remove the whole field. This reduces size of `ExportDefaultDeclaration` from 80 bytes to 24. That has very limited impact, because each file can only have 1 `export default` statement. But still... less is more! It also removes erroneous code in both isolated declarations and transformer, which both just gave the keyword an empty span. I think the fact that everywhere that does use this field uses it wrongly is good justification for its removal! (alternative to #12803)
|
Superceded by #12808. |
…xc-project#12808) We currently store the `default` keyword for `ExportDefaultDeclaration` as a `ModuleExportName`. This is overkill because the name is always, by definition, `default`. The only place the `Span` of `default` keyword is used is in `ModuleRecordBuilder`. So essentially storing the span in AST is using the AST as temporary storage - it's only put there so that `ModuleRecordBuilder` can pull it out again. After oxc-project#12807, we can just pass the span direct to `ModuleRecordBuilder`, and so remove the need for it to be in the AST at all. So we can remove the whole field. This reduces size of `ExportDefaultDeclaration` from 80 bytes to 24. That has very limited impact, because each file can only have 1 `export default` statement. But still... less is more! It also removes erroneous code in both isolated declarations and transformer, which both just gave the keyword an empty span. I think the fact that everywhere that does use this field uses it wrongly is good justification for its removal! (alternative to oxc-project#12803)

We currently store the
defaultkeyword forExportDefaultDeclarationas aModuleExportName. This is overkill because the name is always, by definition,default.Replace this field with
default_span: Spanwhich is enough to provides the only useful information.This reduces size of
ExportDefaultDeclarationfrom 80 bytes to 32. That has very limited impact, because each file can only have 1export defaultstatement. But still... less is more!Ideally we'd get rid of this field entirely. Span of
defaultkeyword doesn't appear in ESTree AST, is not used in linter, and is ignored in codegen.Only reason this span is present in AST is: parser records it temporarily in AST, so that
ModuleRecordBuildercan pull it out again later to add it to module record. There is probably a way to achieve the same thing without using AST as a temporary storage location.UPDATE: I found a way to remove the field entirely: #12808.