From 8de64d4c4a6bc00a84ef75eb9ae48553522f7123 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Fri, 21 Aug 2026 10:36:35 +0000 Subject: [PATCH] fix: leave JSON and other non-CommonJS module formats out of the //nodejs rewrite Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_014bq66fSmaPvLtjnDPfMYcj --- backend/windmill-worker/node_cjs_interop.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/backend/windmill-worker/node_cjs_interop.js b/backend/windmill-worker/node_cjs_interop.js index 12e1588774..df73671dce 100644 --- a/backend/windmill-worker/node_cjs_interop.js +++ b/backend/windmill-worker/node_cjs_interop.js @@ -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 (;;) {