Skip to content

refactor(es/module): Align module transform records with spec terms - #11992

Merged
Donny/강동윤 (kdy1) merged 1 commit into
mainfrom
refactor/es-module-records
Jul 6, 2026
Merged

refactor(es/module): Align module transform records with spec terms#11992
Donny/강동윤 (kdy1) merged 1 commit into
mainfrom
refactor/es-module-records

Conversation

@magic-akari

Copy link
Copy Markdown
Member

Description:

This PR refactors the shared CommonJS/AMD/UMD module-lowering collection layer to use terminology and boundaries closer to ECMAScript module records.

The old ModuleDeclStrip abstraction mixed declaration stripping, module request collection, export collection, and emitter-facing naming. This change renames and reshapes that layer into module_record.rs with clearer concepts:

  • ModuleRecordCollector
  • RequestedModules / RequestedModule
  • ModuleRecordEntry
  • ModuleRequestUsage
  • LocalExportEntries
  • ModuleRecordEntryReducer
  • ExportBinding

CJS, AMD, and UMD now consume the same module-record-oriented data model while preserving their existing emit behavior. The format-specific passes still own wrapper shape, dependency emission, interop helper application, export = handling, and import-reference rewriting.

This is intended to be a behavior-preserving refactor. The main goal is to make the transform pipeline easier to reason about and maintain before future module interop work.

The README was also expanded with diagrams and a short walkthrough of the transform flow.

Verification:

  • cargo fmt --all
  • cargo test -p swc_ecma_transforms_module
  • cargo clippy --all --all-targets -- -D warnings

BREAKING CHANGE:

None.

Related issue (if exists):

N/A

@changeset-bot

changeset-bot Bot commented Jul 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5b7f556

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@magic-akari
magic-akari marked this pull request as ready for review July 5, 2026 17:59
@magic-akari
magic-akari requested a review from a team as a code owner July 5, 2026 17:59
@codspeed-hq

codspeed-hq Bot commented Jul 5, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 189 untouched benchmarks
⏩ 61 skipped benchmarks1


Comparing refactor/es-module-records (5b7f556) with main (ab4ce67)2

Open in CodSpeed

Footnotes

  1. 61 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

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

@kdy1
Donny/강동윤 (kdy1) requested a review from a team as a code owner July 5, 2026 22:45

@kdy1 Donny/강동윤 (kdy1) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@kdy1
Donny/강동윤 (kdy1) merged commit f680df5 into main Jul 6, 2026
70 of 72 checks passed
@kdy1
Donny/강동윤 (kdy1) deleted the refactor/es-module-records branch July 6, 2026 23:17
@github-actions github-actions Bot added this to the Planned milestone Jul 6, 2026
Donny/강동윤 (kdy1) pushed a commit that referenced this pull request Jul 9, 2026
**Description:**

<!-- Explain the **motivation** for making this change. What existing
problem does the pull request solve? -->
Rewrites the SystemJS module transform around a structured
lowering/emission pipeline.

This preserves SystemJS live bindings across imported re-exports,
exported local mutations, destructuring assignments, update expressions,
and `for-in` / `for-of` heads. It also keeps `export default class`
evaluation order inside `execute` and emits import attribute metadata
for System.register dependencies.

Note: this PR is currently stacked on #11992, a related refactor PR. The
SystemJS changes here do not semantically depend on it, but the branch
is based on that work for now.

**Related issue:**

- Closes: #4895
- Closes: #5288
- Closes: #5649
- Closes: #6986
- Closes: #8122
- Closes: #8123
@github-actions github-actions Bot modified the milestones: Planned, v1.15.46 Jul 19, 2026
@swc-project swc (swc-project) locked as resolved and limited conversation to collaborators Aug 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants