The following error is thrown in CI and can be also reproduced locally using Node 22.7.0.
$ npm run test:node -w @web/config-loader
> @web/config-loader@0.3.1 test:node
> mocha test/**/*.test.js --reporter dot
11 passing (12ms)
1 failing
1) cjs package
throws when loading module-in-.js:
AssertionError: expected false to equal true
+ expected - actual
-false
+true
Looks like it's caused by the fact that module syntax detection is now enabled by default and Node is now smarter than we expect it to be, which makes the test fail as no exception is thrown as the file is parsed due to syntax detection:
Syntax detection attempts to run ambiguous files as CommonJS, and if the module fails to parse as CommonJS due to ES module syntax, Node.js tries again and runs the file as an ES module. Ambiguous files are those with a .js or no extension, where the nearest parent package.json has no "type" field (either "type": "module" or "type": "commonjs").
I think for now we can workaround this by adding --no-experimental-detect-module flag. This would make the test pass.
The following error is thrown in CI and can be also reproduced locally using Node 22.7.0.
Looks like it's caused by the fact that module syntax detection is now enabled by default and Node is now smarter than we expect it to be, which makes the test fail as no exception is thrown as the file is parsed due to syntax detection:
I think for now we can workaround this by adding
--no-experimental-detect-module
flag. This would make the test pass.