From c2e441a433e5fa94199f44353f7f47ecf64da560 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sun, 16 Nov 2025 01:52:57 +0000 Subject: [PATCH] completionId: cgen-9ff2ae28ac8a4a1d8a051a123dffecc6 cgen-9ff2ae28ac8a4a1d8a051a123dffecc6 --- build-api.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/build-api.js b/build-api.js index 81e2300f..18dcef4f 100644 --- a/build-api.js +++ b/build-api.js @@ -64,20 +64,24 @@ function fixImportsInDir(dir) { let content = fs.readFileSync(fullPath, "utf-8"); // Fix: import x from "../../_supabase" -> import x from "../../_supabase.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 + // Handle both double and single quotes + let fixedContent = content.replace( + /from\s+"(\.\.?\/[^"]+)"/g, + (match, importPath) => { if (importPath.endsWith(".js")) { return match; } - // Skip if it's a node_modules import - if (!importPath.startsWith(".")) { + return `from "${importPath}.js"`; + } + ); + + fixedContent = fixedContent.replace( + /from\s+'(\.\.?\/[^']+)'/g, + (match, importPath) => { + if (importPath.endsWith(".js")) { return match; } - // Add .js extension and return with proper quote - return `from "${importPath}.js"${quote}`; + return `from '${importPath}.js'`; } );