However, Jiang’s argument is that CJS has inherent problems, including loading modules synchronously, less susceptibility to “tree shaking”, where unused code is removed before being bundled for deployment, and the main problem is that it is not browser-native . CJS modules must be transposed before deployment, if they are to run in the browser, which means a build process is required.
It’s easy to say, as Jiang does, that “CommonJS just isn’t enough. ESM is a better solution for developers”, but it does not disappear.
Sumner also said that CJS modules boot faster. “ES modules are designed slower. They need two passes to tie imports to exports,” he said. This can be a problem in the case of serverless applications that constantly launch new instances. In one benchmark, “with Node.js the difference was 1.8x)” for a cold boot, Sumner said.
However, his main point is that millions of npm modules use CJS, some of which are no longer actively maintained and will never be updated, but “remain critical to existing projects”. According to Sumner, “we will never reach a point where all packages can be expected to use ES modules”.
Bun supports both ESM and CJS, and Sumner added that “As of Bun v0.6.5, the Bun runtime natively implements CommonJS”, as opposed to transpiling CJS modules into some form of ESM.
The dilemma with obsolete technology is that the longer it’s supported, the more time it takes to replace it; but not supporting it entails high costs. The late arrival of Node compatibility in Deno perhaps shows that Dahl’s team made wrong assumptions about developers’ willingness to move, despite technical advantages in ESM. Despite the publication of CJS’s shortcomings, Deno is practically forced to support it.
A debate on Hacker News shows that developers are also divided on the subject. Node is making the same mistake that Microsoft made with Windows, that Apple didn’t make with OSX – instead of letting go of a system that has outgrown and forcing the user base to grow, they cling to the old way and the old API, said one developer; but another said that “the benefits of ESM are not compelling enough to rewrite everything. Loading browser-native modules is a niche use case that can never be as performant as bundling.”
Updated Microsoft Developer Proxy chaos engineering tool to check for excessive permissions granted
Rust: Not hard to learn, but slow to compile, according to an internal Google study
Open VSX alternative to VS Code Marketplace saved from shutdown by new Eclipse working group
Smaller, faster, less legacy: Svelte 4 arrives four years after the last major release
AWS to remove 62,000-message Simple Email Service “always free” tier starting August 2023
Figma introduces Dev Mode, VS Code plugin and more – many of them only for paid plans
Chief Inventor Adam Jacob Introduces System Initiative, ‘Figma for Infrastructure’
C++ 26 is already taking shape, says Herb Sutter
Microsoft releases a new preview of MAUI with “lots of bug fixes,” but quality concerns remain
Amazon ‘Verified Permissions’ for custom apps now generally available, built on open-source Cedar pr…
PostgreSQL now the developer’s top choice ahead of MySQL, according to a massive new study
Stack Overflow strives to protect community content from AI companies, notable mods say “Switch the…