Remove regex replacements from import-typescript#3356
Remove regex replacements from import-typescript#3356alexdima merged 4 commits intomicrosoft:mainfrom
Conversation
| // ╵ ~~~~ | ||
| // | ||
|
|
||
| tsServices = tsServices.replace(/\nvar ([^ ]+) = \(this && this\.([^)]+)\) \|\|/gm, '\nvar $1 ='); |
There was a problem hiding this comment.
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
debuggeratesbuildtime.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.