-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Remove regex replacements from import-typescript #3356
Conversation
// ╵ ~~~~ | ||
// | ||
|
||
tsServices = tsServices.replace(/\nvar ([^ ]+) = \(this && this\.([^)]+)\) \|\|/gm, '\nvar $1 ='); |
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.
This does have an effect, but as far as I can tell esbuild doesn't complain when I run npm run release
.
This PR is now running on TypeScript-Make-Monaco-Builds and is working. |
Very cool approach! The reason we removed |
FWIW this shouldn't actually end up mattering for TypeScript internally; we detect that it's not a node system and never actually try and use those shims, if they weren't present. Of course, it's not so great that the bundle size would increase and/or warnings would appear. |
All bundlers look happy! Thank you! |
Thanks! |
Rather than modifying TS's source to try and remove require/module/debugger/etc, we can instead define those variables at the top and leave the source unmodified (which TS can handle), and then remove
debugger
atesbuild
time.This approach is a lot more flexible for TypeScript. We don't have to think about which random bits of code happen to be regex replaced here, and it could even mean that our package could be shipped minified or optimized in some way, if we end up doing that. Mainly, this means we don't have to add a whole slew of new special cases for the module-ified TS; this approach works for all modern versions of TS.
Supercedes #3352.
This includes #3344.