fix: leave JSON and other non-CommonJS module formats out of the //nodejs rewrite

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014bq66fSmaPvLtjnDPfMYcj
This commit is contained in:
Ruben Fiszel
2026-08-21 10:36:35 +00:00
co-authored by Claude Opus 5
parent b0152ef9d8
commit 8de64d4c4a
+6 -4
View File
@@ -175,14 +175,16 @@ function wmCommonJsSpecs(specs, jobDir, nodePath) {
}
// Node's own rule for a file's format: the extension decides, and `.js` — like an
// extensionless entry — follows the `type` of the closest package.json.
// extensionless entry — follows the `type` of the closest package.json. Only the
// formats node loads through CommonJS qualify; a JSON module exposes `default`
// alone and must keep that shape.
function wmIsCommonJsFile(file) {
const ext = extname(file);
if (ext === ".mjs") {
return false;
if (ext === ".cjs" || ext === ".node") {
return true;
}
if (ext !== ".js" && ext !== "") {
return true;
return false;
}
let dir = dirname(file);
for (;;) {