From 6e6ed9804f8a24e9ca35fea67d7abcb3187c747c Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sun, 16 Nov 2025 01:52:42 +0000 Subject: [PATCH] completionId: cgen-179694e7d310494a8a612bc6d66e691b cgen-179694e7d310494a8a612bc6d66e691b --- build-api.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/build-api.js b/build-api.js index 2b17fa75..81e2300f 100644 --- a/build-api.js +++ b/build-api.js @@ -64,19 +64,22 @@ function fixImportsInDir(dir) { let content = fs.readFileSync(fullPath, "utf-8"); // Fix: import x from "../../_supabase" -> import x from "../../_supabase.js" - // This regex matches relative imports without .js extension - const fixedContent = content - .replace(/from\s+["'](\.[^"']*?)(? { - // Skip if it's already .js - if (path.endsWith(".js")) { + // Match relative imports (starting with . or ..) that don't end with .js + const fixedContent = content.replace( + /from\s+["'](\.[^"']*?)(? { + // Skip if it already has .js + if (importPath.endsWith(".js")) { return match; } // Skip if it's a node_modules import - if (!path.startsWith(".")) { + if (!importPath.startsWith(".")) { return match; } - return `from "${path}.js"${quote}`; - }); + // Add .js extension and return with proper quote + return `from "${importPath}.js"${quote}`; + } + ); if (fixedContent !== content) { fs.writeFileSync(fullPath, fixedContent);