module: move cjs type check behind experimental-modules flag
This puts the check added in https://github.com/nodejs/node/pull/29492 behind the --experimental-modules
flag instead of being on by default.
We added this error for require(.js) inside of "type": "module" packages to reduce an edge case hazard but it has caused more compatibility issues itself, for which we need to discuss a way forward.
While we do that, at least restricting the error to --experimental-modules
usage will avoid unintentional compatibility issues unflagged.
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
documentation is changed or added -
commit message follows commit guidelines