You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Scope (install, code, runtime, meta, other?): other
Module (and version) (if relevant): -
Now that --experimental-modules is to be unflagged in this month in v13, which is the preferable module system to be used in Node.js, ES modules or CommonJS?
People developing universal Web apps and have been using ES modules for better bundler support may find it is beneficial that they no longer need to transpile their code from ES modules to CommonJS for Node.js.
From performance point of view, it might be possible that the static nature of ES modules provides with some benefit over CommonJS, though I'm not sure.
Another question is that is there any plan or discussion for dropping support for CommonJS?
I found some implication for this (for example, one maintainer said "what a future Node would be like where CommonJS were deprecated" in nodejs/modules#318), but could not have found any official announcement.
The text was updated successfully, but these errors were encountered:
It depends. If you are writing an application and are happy with using the latest Node.js version, using ESM might be a good idea.
However, dropping the flag for ESM does not mean that it will remain unchanged, and it has not been tested to the same degree as CommonJS. If you intend to publish a package on npm, providing ESM only will make it impossible for people to require() your module.
CommonJS will not be deprecated any time soon, and maybe it will never be.
Though I am satisfied with your answers, I wonder whether I should close this issue as this can be one of FAQ in Node.js and might be worth being kept opened.
Now that
--experimental-modules
is to be unflagged in this month in v13, which is the preferable module system to be used in Node.js, ES modules or CommonJS?People developing universal Web apps and have been using ES modules for better bundler support may find it is beneficial that they no longer need to transpile their code from ES modules to CommonJS for Node.js.
From performance point of view, it might be possible that the static nature of ES modules provides with some benefit over CommonJS, though I'm not sure.
Another question is that is there any plan or discussion for dropping support for CommonJS?
I found some implication for this (for example, one maintainer said "what a future Node would be like where CommonJS were deprecated" in nodejs/modules#318), but could not have found any official announcement.
The text was updated successfully, but these errors were encountered: