Skip to content

Enable consuming of ES modules in extensions #130367

Description

When developing extensions and using either JavaScript or TypeScript we are unable to consume ES modules, only somewhat legacy CommonJS modules, setting the type to module and rewriting the extension to use import instead of require breaks the extension, generating an exception that states that all modules should use import instead of require in internal VS Code JavaScript files, I conclude it's caused by the type: 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?

Activity

  1. vscodebot commented on Aug 8, 2021

    @vscodebot

    (Experimental duplicate detection)
    Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

  2. igorskyflyer commented on Aug 23, 2021

    @igorskyflyer
    Author

    Closing after 15 days of no reply.

  3. alexdima commented on Aug 25, 2021

    @alexdima
    Member
  4. added
    feature-requestRequest for new features or functionality
    webIssues related to running VSCode in the web
    and removed
    webIssues related to running VSCode in the web
    on Aug 25, 2021
  5. vscode-triage-bot commented on Aug 25, 2021

    @vscode-triage-bot

    This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

    Happy Coding!

  6. Lemmingh commented on Sep 3, 2021

    @Lemmingh
  7. 157 remaining items

  8. MicahZoltu commented on Feb 12, 2026

    @MicahZoltu

    Status of Web Worker support for import maps:
    WICG/import-maps#2
    whatwg/html#10858

    The whatwg/html#10858 (comment) from the author of that PR suggests that this is stalled just because they don't want to push it over the finish line if no one is going to implement. So it seems that at the moment someone needs to convince browsers to step up and actually care about finishing import-map support.

  9. lishaduck commented on May 23, 2026

    @lishaduck

    I've been following this issue for a while and as I was just cleaning up my house I was thinking about this. (About to start a new extension in a few days 🤞🏻)

    Would it be possible to shim out web worker support here? https://github.com/guybedford/es-module-shims was the import map polyfill back in the day, and it supported web workers. I just took another look and judging from the issues, I think vs code could still use it to shim out the vscode import in workers so long as they're not service workers.

    Apologies if a similar approach has already been considered, it just seemed from the comments above that the team was open to alternatives to waiting on standardization.

    (Also, my apologies for any typos, I'm typing this on my phone because I wanted to get it down before I forgot)

    EDIT: And now that I posted, this probably should have gone in the loader repository but oh well 🤷🏻‍♂️

  10. alexdima commented on Jul 6, 2026

    @alexdima
    Member

    🤖 Thanks for the report and the follow-up context. This is now implemented for the Node extension host in commit 15260e7 via #245214 and is contained in 1.100.0 and later. Current main detects .mjs / package type "module" extension entry points and loads them with import(...), and #248286 added the hybrid path for extensions that use ESM in the Node extension host and CJS in the web worker extension host. I think this can be closed as completed; any remaining request for ESM in the web worker extension host should be tracked separately.

  11. brianjenkins94 commented on Sep 11, 2026

    @brianjenkins94

    Does there exist an issue for ESM in the web worker extension host?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions