-
Notifications
You must be signed in to change notification settings - Fork 12.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
Use ESM for our executables (tsc, tsserver, typingsInstaller) #51440
Comments
Isn't Node 14 the earliest version that supports ESM without a command-line flag? |
Nope, it's enabled by default in Node 12.17+. But, I would want to target Node 12.20+ as that's when the experimental warning was removed. Technically, Node 12.22 is when it's "stable", but AFAICT 12.20 works fine. |
Another totally radical idea would be to just ship ESM now with separate endpoints. It wouldn't behave how people want, as in no tree shaking, but it wouldn't be that much code. tsserver already pulls pretty much everything in anyway, so this wouldn't be all that much extra. We'd just still have the dual package hazard, and have to get the weirdness of export mappings and self references. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
With #51699 merged, That being said, I still haven't quite been able to get the codebase to run in esbuild's code splitting mode, probably due to ordering problems thanks to our codebase's continued circularity. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Mostly related, but I've successfully gotten the TS API itself to run as ESM while being required from CJS: nodejs/node#52599 (comment)
|
Our libraries are all UMD-ish, because they can be used in Node or in the browser. I didn't change this for the module transform.
However, most of our executables are CJS, as they are only intended to be run within Node. This includes tsc, typingsInstaller, and watchGuard. An exception is tsserver, which contains web code for vscode.dev.
tsc and typingsInstaller both share a lot of code; if they only run on Node anyway, we could potentially raise our minimum Node version to node 12, and ship them as ESM via esbuild's split ESM bundling. If we get vscode.dev off of tsserver (and onto tsserverlibrary), then all three can share code.
In my testing, this reduces our package size by an additional 7 MB, which is a great win.
See also #27891, #32949.
The text was updated successfully, but these errors were encountered: