module: fix extensionless entry with explicit type=commonjs#61600
module: fix extensionless entry with explicit type=commonjs#61600inoway46 wants to merge 1 commit intonodejs:mainfrom
Conversation
|
Review requested:
|
joyeecheung
left a comment
There was a problem hiding this comment.
Thanks for the PR, a couple of comments, otherwise this looks good.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #61600 +/- ##
==========================================
- Coverage 89.76% 89.74% -0.03%
==========================================
Files 673 675 +2
Lines 203944 204511 +567
Branches 39191 39305 +114
==========================================
+ Hits 183080 183540 +460
- Misses 13194 13248 +54
- Partials 7670 7723 +53
🚀 New features to boost your workflow:
|
|
Thanks for the approval. I also verified |
|
@inoway46 Can you squash the commits? I don't think they would pass the test individually. |
601e4c5 to
79d60d5
Compare
|
I squashed the commits and force-pushed the branch. |
When an extensionless entry point contains ESM syntax but is in a package with "type": "commonjs" in package.json, the module would silently exit with code 0 without executing or showing any error. This happened because extensionless files skip the
.jssuffix check in the CJS loader, so the explicittype: commonjswas not being enforced, allowing ESM syntax to be silently delegated to ESM loading which never completed before the process exited.This change ensures the CJS loader treats extensionless entry points as commonjs when
typeis explicitly set to "commonjs" in package.json, forcing ESM syntax to surface as a SyntaxError instead of silently exiting.Fixes: #61104
Related: #61171 (alternative approach)