refactor(transformer/react): don't follow the Babel's imports order#6176
refactor(transformer/react): don't follow the Babel's imports order#6176
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. |
This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Performance ReportMerging #6176 will not alter performanceComparing Summary
|
5b5aad8 to
5908859
Compare
5908859 to
73cfb59
Compare
|
Personally I am not keen on diverging from Babel at this stage. My feeling is that Babel's transformer tests which we are using for conformance are not enough. To really test the transformer, we need to throw a lot more code at it. The best way I can see to do that is something like this:
When we have no mismatches all all, we can have high confidence that our transformer is bug-free (or at least has no more bugs than Babel). But to run those tests without spurious differences in the diffs, we need our transformer's output to match Babel's exactly - even in cosmetic aspects like statement order. I'll look into this further and try to find if we can achieve what we're trying to do (move |
|
@overlookmotel Feel free to take over this stack, I am on holiday now. 🏖️ |
|
#6183 negates the need for this. |

The
ImportDeclarationorders are not matter, they are always hoisted. Previously to 100% match Babel's output to pass the tests, we did some weird logic in our implementation. In this PR I removed them, and always inserted the imports at the top of the statements. The reason for doing this is I am movingModuleImportsto https://github.com/oxc-project/oxc/blob/5b5aad856213df18f09bf1972f6e3a13a5302a15/crates/oxc_transformer/src/common/mod.rs#L14-16After being moved to
common, theNamedImportswill only insert imports once incommoninstead of inserting in each plugin that used it.