Move traverse logic to Program exit #27
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm apologize for issuing this PR, because it's tailored to the use case
I have of running CommonJS modules in the browser. I've written a
plugin: https://github.com/tbranyen/babel-plugin-transform-commonjs
which converts CommonJS to browser-compatible ESM. I could only think of
two ways to use the two togther: 1) this change (or something similar to
it) is made, 2) we wait until Babel implements a plugin ordering
system. I believe they are working on the latter.
My CommonJS plugin must run after all other transforms so that dead code
elimination can work properly. What this effectively does is halt the
traversal till the Program exit consistently. This will work reliably
for every plugin that does this, and ensures that all transforms have
run (and may run again) prior to running this plugin.
Thanks in advance!