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?