CJS plugins file (and ideally also allowing an ESM one)
See original GitHub issueEspecially with Node 10 reaching EOL, and native ESM being used increasingly in Node projects (type: module
in package.json
), including those which may also house browser code in need of testing, the apparent inability to use at least an index.cjs
plugins file with Cypress seems rather problematic. (It complains about the extension; pointing pluginsFile
in cypress.json
to a .cjs
file didn’t work either; only switching to .js
works–or removing type: module
but that causes problems for Node ESM execution.)
(Please note that I’m not speaking about a @babel/register
problem–I mean one simply can’t use a cjs file at all.)
Are there any plans (or workarounds) about this? Thanks!
Issue Analytics
- State:
- Created 2 years ago
- Reactions:20
- Comments:21 (5 by maintainers)
Top Results From Across the Web
CJS vs ESM - Andrea Giammarchi - Medium
The biggest difference between CJS and ESM, is that the former, filesystem constrained, understands some file content based on its extension, ...
Read more >Config Files - Babel.js
Because project-wide config files are separated from the physical location of the config file, they can be ideal for configuration that must apply...
Read more >Error [ERR_MODULE_NOT_FOUND]: Cannot find module
This answer was the one that helped me! I was using import and the file was .js - Adding --es-module-specifier-resolution=node saved the day...
Read more >[AskJS] Any way to support ESM outputs from a CJS ... - Reddit
My preferred ideal way would be if there was a babel plugin that outputs ... The ESM standards require the file extensions, and...
Read more >cjstoesm - npm
API support, enabling you to convert a project from CJS to ESM ... You can also run cjstoesm along with its peer dependencies...
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
A simple workaround, till Cypress enables
*.cjs
configuration scripts, is to add apackage.json
in thecypress/plugins
andcypress/support
folders that have the following text in them:This tells Node.js that all “js” files in this folder are CJS, and Cypress will load them without any problem.
One important detail though is that since the plugins file is commonJS, the only way to use your esm modules is via dynamic import, e.g.