Enable consuming of ES modules in extensions
See original GitHub issueWhen 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?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:126
- Comments:26 (11 by maintainers)
Top GitHub Comments
For what it’s worth, I ran into this trying to update
node-fetch
from 2.x to 3.x, since the newer version is ESM only. Looks to be the direction things are going, so extension developers are only more likely in the future to run into issues due to lack of ESM support.Closing after 15 days of no reply.