Skip to content
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

refactor(transformer): re-implement ModuleImports #6177

Conversation

Dunqing
Copy link
Member

@Dunqing Dunqing commented Sep 30, 2024

This implementation refers to #6170.

Copy link

graphite-app bot commented Sep 30, 2024

Your org has enabled the Graphite merge queue for merging into main

Add the label “0-merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

@Dunqing Dunqing marked this pull request as ready for review September 30, 2024 07:31
@github-actions github-actions bot added the A-transformer Area - Transformer / Transpiler label Sep 30, 2024
Copy link
Member Author

Dunqing commented Sep 30, 2024

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @Dunqing and the rest of your teammates on Graphite Graphite

@Dunqing Dunqing changed the title refactor(transformer): re-implemment ModuleImports refactor(transformer): re-implement ModuleImports Sep 30, 2024
Copy link

codspeed-hq bot commented Sep 30, 2024

CodSpeed Performance Report

Merging #6177 will not alter performance

Comparing 09-30-refactor_transformer_re-implemment_moduleimports (9b3c3e0) with 09-30-refactor_transformer_react_don_t_follow_the_babel_s_imports_order (73cfb59)

Summary

✅ 29 untouched benchmarks

@overlookmotel
Copy link
Contributor

overlookmotel commented Sep 30, 2024

@Dunqing I've copied and amended the content of this PR to make an alternative version: #6183. That version controls insertion order, and so manages to pass Babel's tests.

If you're happy with my version, can we merge that one instead of this and #6176? Maintaining exact same output as Babel is a real pain, but for the reasons mentioned on #6176, I think it's ideal to do that if we can.

Boshen pushed a commit that referenced this pull request Oct 1, 2024
…6186)

An alternative version of #6177.

Convert `ModuleImports` into a common transform. Works much as before, but it inserts `import` / `require` statements by passing them to `TopLevelStatements` common transform, so they get inserted in one go with any other inserted top-level statements. This avoids shuffling up the `Vec<Statement>` multiple times, which can be slow with large files.

`VarDeclarations` also inserts any declarations via `TopLevelStatements` but runs after `ModuleImports`, so can control whether a `var` statement is inserted before or after `import` statements by inserting it via `VarDeclarations` (to appear after `import` statements) or directly into `TopLevelStatements` (to appear before `import` statements). Insertion order is not actually important, but allows us to match Babel's output and pass its tests.
@overlookmotel
Copy link
Contributor

Merged #6183 instead of this.

@overlookmotel overlookmotel deleted the 09-30-refactor_transformer_re-implemment_moduleimports branch October 1, 2024 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-transformer Area - Transformer / Transpiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants