-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix(es/transforms/cjs): Preserve order of imports for reexports #2598
Conversation
Thank you for tackling this! I suspect the test cases for my recent merge ( |
03edc8a
to
213a35e
Compare
Thanks, I tried to update test cases as well. |
213a35e
to
34d8da1
Compare
34d8da1
to
4a1cede
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
I have some concerns about changes.
This may possibly resolve #1733, too. |
5b16122
to
601aa9a
Compare
601aa9a
to
3436fff
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I found one issue, but it's not related to this PR.
I'll patch it after merging this. Thanks!
Appreciate for the review for both, @kdy1 and @JeremyGrieshop 🙇 |
This PR attempts to order of the imports / reexports in transpiled runtime codebase. #2594 itself sufficiently explains the issue itself. It could be an implementation detail but so far based on observation tsc / babel works in the same way, which makes think it'd better to align as well. As issue described normally this won't appear but if there's some sort of circular dependencies, or reexports have dependencies across each other it may reveal different behavior.
For the change itself, PR changes the order of injecting handled export_all stmt by putting it after require stmt is created. In result, export_all stmt doesn't use extra_stmt (which appends to stmt at the end). Also changed
exports_alls
to map to stmt itself - when encountering ExportAll stmt it is gauranteed we'll need stmt anyway - hashmap contains generated stmt instead of only keeping name of export. This allowed easier lookup at the end.Lastly, I noticed there is prior test cases from #133 (https://github.com/swc-project/swc/pull/133/files#diff-6d08f604fc5444313bf8d80ca76a84f5abbc95129eb4e1311592637fbb17b089R1075) , looks like it is coming from original transform impl. Test cases are updated without adding new one.