refactor(transformer): re-implement ModuleImports#6177
Conversation
Your org has enabled the Graphite merge queue for merging into mainAdd 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. |
|
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.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
ModuleImports
CodSpeed Performance ReportMerging #6177 will not alter performanceComparing Summary
|
|
@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. |
…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.
|
Merged #6183 instead of this. |

This implementation refers to #6170.