Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use .cjs file extension for CommonJS modules #37

Open
jsejcksn opened this issue Jul 13, 2020 · 0 comments
Open

Use .cjs file extension for CommonJS modules #37

jsejcksn opened this issue Jul 13, 2020 · 0 comments

Comments

@jsejcksn
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant