module: fix --check on ambiguous ESM files #65203
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 193 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.315
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #65203"
general
weight: 0.35
daltino
Fixes #65202.
node --checkexits 0 on a.jsfile that contains module syntax and a genuine syntax error, when the file's format is ambiguous (no"type"in the nearest package.json).Such a file has no format of its own, and
defaultGetFormat()reports it asnull.checkSyntax()passed thatnullstraight towrapSafe(), which parses as CommonJS; the module syntax makes that parse bail out before the rest of the file is parsed, so nothing was reported.At load time the goal for an ambiguous file is decided by looking for module syntax in the source, so this decides it the same way before choosing how to parse.
Verified against a local build. Files whose format is known are unaffected, and ambiguous files without module syntax still parse as CommonJS, so sloppy-mode sources keep working:
| case | before | after |
| --- | --- | --- |
|
.jsambiguous + module syntax + error | exit 0 | exit 1 ||
.jsambiguous, sloppy-modewith| exit 0 | exit 0 ||
.jsambiguous, plain syntax error | exit 1 | exit 1 ||
.mjs, or"type"set | exit 1 | exit 1 ||
.jsambiguous, valid ESM | exit 0 | exit 0 |The added fixture fails the existing
test-cli-syntax-badassertions before this change and passes after. Alltest-cli-syntax*suites pass locally.Fixes: https://github.com/nodejs/node/issues/65202