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
In consideration of ESM support (pending #36), I think it makes sense for this package to be explicit about CommonJS modules by utilizing the .cjs extension.
JavaScript has standardized on ESM, and Node doesn't care if CommonJS module file extensions are .js or .cjs when package.type is commonjs or undefined — that's the case here. When package.type is module (not the case here) CommonJS files must end in .cjs. (See https://nodejs.org/api/esm.html)
It provides immediate clarity to anyone casually browsing the repository: they can see the .cjs extension and instantly know it's a CommonJS module. Similarly, .mjs serves as an indicator that a file is an ES module for Node (vs. for browser, etc.). This cognitive benefit is the biggest win, IMO.
The text was updated successfully, but these errors were encountered:
In consideration of ESM support (pending #36), I think it makes sense for this package to be explicit about CommonJS modules by utilizing the
.cjs
extension.JavaScript has standardized on ESM, and Node doesn't care if CommonJS module file extensions are
.js
or.cjs
whenpackage.type
iscommonjs
or undefined — that's the case here. Whenpackage.type
ismodule
(not the case here) CommonJS files must end in.cjs
. (See https://nodejs.org/api/esm.html)It provides immediate clarity to anyone casually browsing the repository: they can see the
.cjs
extension and instantly know it's a CommonJS module. Similarly,.mjs
serves as an indicator that a file is an ES module for Node (vs. for browser, etc.). This cognitive benefit is the biggest win, IMO.The text was updated successfully, but these errors were encountered: