Use transformer to remove require calls and nodeSystem from typescript.js #3352
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.
This includes #3344; I would merge that in first and then I'll rebase this one as it's more complicated.
Right now, the build script uses source level hacks to remove require calls and such. But with microsoft/TypeScript#49332 on the horizon, these source level hacks are going to be unstable.
Rather than try and maintain all of these regex replacements, rewrite the code using transpileModule. This should be a sure-fire method as we can use the helper TS uses to identify require calls and replace them with no-ops.
I've removed the part of the script which complains about leftover requires, as the transformer gets all of the "real" requires; anything left is a false positive from a string, or a call to
sys.require
which the transformer will also ensure is undefined as it removes the nodeSystem from use.