-
Notifications
You must be signed in to change notification settings - Fork 28.9k
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
Enable consuming of ES modules in extensions #130367
Comments
(Experimental duplicate detection) |
Closing after 15 days of no reply. |
cc @jrieken |
Sounds like a duplicate of #116056. Is it possible to reopen that issue? The VS Code extension host currently only accepts CJS module, as shown in the (trimmed) error message below:
However, I think ES module will be more convenient in future. Besides, TypeScript can transpile dynamic |
For what it's worth, I ran into this trying to update |
FYI @TylerLeonhardt one of the Code issues I'd love to see fixed 😃 |
Includes module import workaround for microsoft/vscode#130367 and microsoft/TypeScript#43329 🤯
TypeScript 4.5 will perhaps have a new See |
Excuse me, @TylerLeonhardt, do you know why my comment above was marked as spam? I have to assume that was a mistake. |
@andschwa I'm sorry, it might have been me that marked the comment as spam, but I don't remember doing it. I personally tend to hide comments that do not bring any value to the underlying discussion or distract from it. |
There has ever been no one mentioning a concrete error message. An extension using Pyodide: Prettier (v10.0.0):
|
In VS Code Exploration available from #160416 (comment), the error message is changed:
Update: a newer build is available: #226399 (comment) Update: ESM will be enabled since 1.94 (Insiders since early next month) |
If the update in the next month or in the current Insiders (1.94) doesn't help, we need to wait for |
For SEO, here is a similar error message I've received for an LSP extension after packaging and installing VSIX. It appeared in the Output view > Extension Host channel
|
VS Code 1.94 now ships the ESM build in the stable channel: I tested using ESM in extensiom code and that still appears to be unsupported, but hopefully VS Code now shipping ESM means this limitation will be lifted, soon. |
Hmm, we should wait |
Latest vscode I use esm work fine 🎉🎉🎉 |
Unfortunately |
Which repositories? This target is cjs |
Agreed, very important to clarify using ESM modules and compiling to CJS is not the same as using them "natively" |
@yxw007, |
@igorskyflyer @CoffeeChaton @JustinGrote |
You need to be very careful what you are saying. You are not "using esm", you are transpiling to commonjs, it's a big difference. |
When developing extensions and using either JavaScript or TypeScript we are unable to consume ES modules, only somewhat legacy CommonJS modules, setting the
type
tomodule
and rewriting the extension to useimport
instead ofrequire
breaks the extension, generating an exception that states that all modules should useimport
instead ofrequire
in internal VS Code JavaScript files, I conclude it's caused by thetype: module
that forces Node to treat all.js
files as ES modules. Tried using TypeScript which transpiles its own syntax to CommonJS module - so that's a no, I have also tried using just.mjs
extension, again the same issue.What is the status of this issue and are there plans to enable using of ES modules in extension development? That (could) bring somewhat big performance gains when bundling extensions with, for example,
esbuild
because it would enable tree-shaking - dead code removal, thus loading only necessary code. But I think this is not an extension API only issue, right? This needs to be done for VS Code itself?The text was updated successfully, but these errors were encountered: