renames every module (that is not a test fixture or mock) with a .js extension to .cjs
for packaging only ensure the package.json has a type: "module" entry
(during development time we still need the flexiblity of a package.json without - so we can tests scenarios without node throwing a hissy fit)
Motivation and Context
dependency-cruiser has been ESM only since version 13. Until now it didn't advertise this in its package manifest. This is a non-standard way of doing ESM only modules. Then why didn't we do it the standard way? Well, glad you asked. Test fixtures and mocks are affected by the "type": "module" setting as well. As we have several tests that have .js files with commonjs in them, these got qualified as ESM - which jump-scares the nodejs ESM processor.
This PR circumvents this issue by
not specifying a "type" in the manifest, so during development the .js modules in mocks and fixtures can still safely contain commonjs.
when packaging adding the "type": "module" to the manifest.
For this to work properly the last remnants of files still called ".js" but actually having commonjs content in src and configs needed to be renamed to .cjs. For good measure we did the same for all other .js module that wasn't a mock or fixture.
How Has This Been Tested?
[x] green ci
[x] throwing the new version against a few repositories (manually)
Types of changes
[x] Bug fix (non-breaking change which fixes an issue)
[ ] Documentation only change
[ ] Refactor (non-breaking change which fixes an issue without changing functionality)
[ ] New feature (non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to change)
Checklist
[x] :book:
My change doesn't require a documentation update, or ...
it does and I have updated it
[x] :balance_scale:
The contribution will be subject to The MIT license, and I'm OK with that.
Description
package.json
has atype: "module"
entry (during development time we still need the flexiblity of a package.json without - so we can tests scenarios without node throwing a hissy fit)Motivation and Context
dependency-cruiser has been ESM only since version 13. Until now it didn't advertise this in its package manifest. This is a non-standard way of doing ESM only modules. Then why didn't we do it the standard way? Well, glad you asked. Test fixtures and mocks are affected by the
"type": "module"
setting as well. As we have several tests that have .js files with commonjs in them, these got qualified as ESM - which jump-scares the nodejs ESM processor.This PR circumvents this issue by
"type": "module"
to the manifest.For this to work properly the last remnants of files still called ".js" but actually having commonjs content in
src
andconfigs
needed to be renamed to .cjs. For good measure we did the same for all other.js
module that wasn't a mock or fixture.How Has This Been Tested?
Types of changes
Checklist
[x] :book:
[x] :balance_scale: