Investigate if .cjs extension support is needed.
See original GitHub issueFrom #59, we believed that .cjs
extension support was needed, but I think that was due to not properly supporting the ESM syntax. With the work done in gulp-cli by @snoak, we can import ESM modules.
Given that, I only added support for .mjs in #65 and I wanted to open this to investigate if we actually need to support the .cjs
extension.
If we end up needing to support it, I’ve put in place the architecture to support & test the extension on all versions of node.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
What the heck are CJS, AMD, UMD, and ESM in Javascript?
My goal is to help readers recognize when they see them in the wild . CJS. CJS is short for CommonJS. Here is...
Read more >What does it take to support Node.js ESM? – The Guild
I have worked on all The Guild's libraries and graphql-js to support ESM. Here is how you can do it too.
Read more >How to Create a Hybrid NPM Module for ESM and CommonJS.
Creating a single NPM module that works in all environments.
Read more >How do I import an ES6 JavaScript module in my VS Code ...
Yes, this is a pain. To be specific, you can develop and debug extensions using es6 modules in vscode, but you cannot deploy...
Read more >Config Files - Babel.js
files, with the following extensions: .json , .js , .cjs , .mjs . ... New in Babel 7.x, Babel has a concept of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Node.js considers a script an ES module if it either has the file extension
.mjs
, or if it has the file extension.js
and is located in a package that declares"type": "module"
in itspackage.json
.Node.js considers a script a CommonJS module if it either has the file extension
.cjs
, or if it has the file extension.js
and is not located in a package that declares"type": "module"
in itspackage.json
.So if a package uses
"type": "module"
but for whatever reason sticks to CommonJS for their Gulpfile that file would have to be namedgulpfile.cjs
.@anshumanv Can you explain a little more? node.js supports “fall through” when requiring files that don’t have an extension registered, so wouldn’t
.cjs
just be loaded normally as a .js file?