Microsoft has released Visual Studio Code 1.94, the first stable version to be built with ECMAScript Modules (ESM), with large gains in startup time and bundle size, but extensions remain bound to legacy CommonJS modules.
ESM are the official standard for JavaScript and native to web browser JavaScript engines including V8, which is embedded with the Chromium browser via Electron, the framework used for VS Code.
The VS Code project originally used AMD (asynchronous module definition) in its source code, but in 2022 the team began to migrate it to ESM. This month, the VS Code developers reported that “all usages of our legacy AMD loader are disabled and will be removed as part of our debt week in October.”
The change “massively improves startup performance,” according to the team, and reduces the bundle size of the main VS Code workbench by more than 10 percent. In addition, the project will now benefit from modern tooling designed for ESM, and there is a plan to “improve our engineering system for VS Code.”
Spoiling this promising news is the fact that VS Code extensions, which are critical to its functionality, can only use CommonJS modules. The only workaround is to use ESM in the source code for an extension and compile to CommonJS. According to a developer who raised the issue over three years ago, native ESM support in extensions could bring “big performance gains when bundling extensions with, for example, esbuild because it would enable tree-shaking – dead code removal, thus loading only necessary code.” The esbuild tool is a bundler for TypeScript and JavaScript. Hundreds of comments on this issue show strong interest from extension authors in getting this working.
The hope is that with ESM now used for VS Code itself, extensions will also get support soon. A developer noted though: “don’t make plans based on what you read on issues. Not the first time highly requested features take years to land.”
Other new features in VS Code 1.94 include many enhancements to GitHub Copilot (paid subscription required), TypeScript 5.6 support, the ability to remote attach to a Kubernetes dev container.
Preview features include support for multiple GitHub accounts, logged in at the same time. This welcome feature is behind an experimental flag but will be enabled by default in the next release.