Skip to content

Comments

refactor(ast)!: remove ExportDefaultDeclaration exported field#12808

Merged
graphite-app[bot] merged 1 commit intomainfrom
08-04-refactor_ast_remove_exportdefaultdeclaration_exported_field
Aug 5, 2025
Merged

refactor(ast)!: remove ExportDefaultDeclaration exported field#12808
graphite-app[bot] merged 1 commit intomainfrom
08-04-refactor_ast_remove_exportdefaultdeclaration_exported_field

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Aug 4, 2025

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)

@github-actions github-actions bot added A-parser Area - Parser A-semantic Area - Semantic A-ast Area - AST A-transformer Area - Transformer / Transpiler A-isolated-declarations Isolated Declarations A-formatter Area - Formatter C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Aug 4, 2025
Copy link
Member Author

overlookmotel commented Aug 4, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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-hq
Copy link

codspeed-hq bot commented Aug 4, 2025

CodSpeed Instrumentation Performance Report

Merging #12808 will not alter performance

Comparing 08-04-refactor_ast_remove_exportdefaultdeclaration_exported_field (2cc1001) with main (e8ac1a5)1

Summary

✅ 34 untouched benchmarks

Footnotes

  1. No successful run was found on main (2cc1001) during the generation of this report, so e8ac1a5 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Copy link
Member

Boshen commented Aug 5, 2025

Merge activity

  • Aug 5, 6:50 AM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Aug 5, 6:50 AM UTC: Boshen added this pull request to the Graphite merge queue.
  • Aug 5, 7:02 AM UTC: The Graphite merge queue couldn't merge this PR because it had merge conflicts.
  • Aug 5, 7:25 AM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Aug 5, 7:26 AM UTC: This pull request can not be added to the Graphite merge queue. Please try rebasing and resubmitting to merge when ready.
  • Aug 5, 7:26 AM UTC: Graphite disabled "merge when ready" on this PR due to: a merge conflict with the target branch; resolve the conflict and try again..
  • Aug 5, 7:26 AM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Aug 5, 8:09 AM UTC: Graphite rebased this pull request, because this pull request is set to merge when ready.
  • Aug 5, 8:20 AM UTC: Merged by the Graphite merge queue.

@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Aug 5, 2025
@graphite-app graphite-app bot changed the base branch from 08-04-perf_parser_register_import___export_statements_in_module_record_directly to graphite-base/12808 August 5, 2025 07:02
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Aug 5, 2025
@camc314 camc314 force-pushed the graphite-base/12808 branch from b9c79b6 to e8ac1a5 Compare August 5, 2025 08:09
@camc314 camc314 force-pushed the 08-04-refactor_ast_remove_exportdefaultdeclaration_exported_field branch from 425b278 to a7a3afb Compare August 5, 2025 08:09
@camc314 camc314 changed the base branch from graphite-base/12808 to main August 5, 2025 08:09
…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)
@graphite-app graphite-app bot force-pushed the 08-04-refactor_ast_remove_exportdefaultdeclaration_exported_field branch from a7a3afb to 2cc1001 Compare August 5, 2025 08:14
@graphite-app graphite-app bot merged commit 2cc1001 into main Aug 5, 2025
28 checks passed
@graphite-app graphite-app bot deleted the 08-04-refactor_ast_remove_exportdefaultdeclaration_exported_field branch August 5, 2025 08:20
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Aug 5, 2025
This was referenced Aug 6, 2025
taearls pushed a commit to taearls/oxc that referenced this pull request Aug 12, 2025
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast Area - AST A-formatter Area - Formatter A-isolated-declarations Isolated Declarations A-parser Area - Parser A-semantic Area - Semantic A-transformer Area - Transformer / Transpiler C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants