-
Notifications
You must be signed in to change notification settings - Fork 28.8k
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. |
@metawrap-dev imo you should switch to CJS. Don't make plans based on what you read on issues. Not the first time highly requested features take years to land. |
@itsdouges @metawrap-dev as of today, the general recommendation is to use a bundler like Generally have had no issues with this, the only major roadblock I've seen is you can't run E2E in-vscode testing using testing frameworks that require ESM such as |
I understand. Unfortunately there are a few packages that don’t work well
with bundling, so I’m doing both: bundling but marking dependencies that
can’t be bundled as external.
…On Tue, 23 Apr 2024 at 1:33 AM, Justin Grote ***@***.***> wrote:
@itsdouges <https://github.com/itsdouges> @metawrap-dev
<https://github.com/metawrap-dev> as of today, the general recommendation
is to use a bundler like esbuild (recommended) or rollup and use their
features/plugins to convert ES modules to CJS automatically. They can even
translate default imports.
Generally have had no issues with this, the only major roadblock is you
can't run E2E in-vscode testing using testing frameworks that require ESM
such as vitest, but mocha is the de-facto standard used by everything
including the official vscode test cli and you can still run tests that
don't need/reference the vscode api or mock it in whatever framework you
want.
—
Reply to this email directly, view it on GitHub
<#130367 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABT4PHLAMN2URABDSREZXZDY6UUTLAVCNFSM5BYXHNA2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMBWHE4TCMRQGMYQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Thanks. That's exactly what I did as a workaround. I am glad that you have confirmed the choice, |
…#148) Update language server and language client to 7.* With the update, we get some benefits: - Fix load symbols (fixes bug #119) - Add support for load symbols on public clusters that need MSA account logins (rather than AAD/Entra account login) - Fix load symbols on remote connections which dont support clipboard writes - Update default load symbols params to be the public sample cluster Also: - Add steps for manual testing the 5 basic scenarios in kusto-language-server/README.md (activate extension, format document, load symbols, autocomplete, hover info) - Update `open` and `clipboardy` to the newest non-ESM versions (vs code does NOT support ESM-only modules, ref: microsoft/vscode#130367)
But ESM is restricted in microsoft/vscode#130367
* Install typescript dependencies * Enable typescript for extensions But ESM is restricted in microsoft/vscode#130367 * Fix merge miss * Follow out dir in package.json * Commit out dir * Revert "Commit out dir" This reverts commit e72912f. * Transpile just before package * Fix step position after npm ci
Can anyone tell me, is there any possibility of importing a esm dependency in a vscode extension? |
You can import an ESM package, but you then have to bundle as CJS. This makes the whole experience considerably worse, as the restart cycles during development are longer, and most of the times source maps don't even work. |
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
|
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: