completionId: cgen-9ff2ae28ac8a4a1d8a051a123dffecc6
cgen-9ff2ae28ac8a4a1d8a051a123dffecc6
This commit is contained in:
parent
6e6ed9804f
commit
c2e441a433
1 changed files with 13 additions and 9 deletions
22
build-api.js
22
build-api.js
|
|
@ -64,20 +64,24 @@ function fixImportsInDir(dir) {
|
||||||
let content = fs.readFileSync(fullPath, "utf-8");
|
let content = fs.readFileSync(fullPath, "utf-8");
|
||||||
|
|
||||||
// Fix: import x from "../../_supabase" -> import x from "../../_supabase.js"
|
// Fix: import x from "../../_supabase" -> import x from "../../_supabase.js"
|
||||||
// Match relative imports (starting with . or ..) that don't end with .js
|
// Handle both double and single quotes
|
||||||
const fixedContent = content.replace(
|
let fixedContent = content.replace(
|
||||||
/from\s+["'](\.[^"']*?)(?<!\.js)(["'])/g,
|
/from\s+"(\.\.?\/[^"]+)"/g,
|
||||||
(match, importPath, quote) => {
|
(match, importPath) => {
|
||||||
// Skip if it already has .js
|
|
||||||
if (importPath.endsWith(".js")) {
|
if (importPath.endsWith(".js")) {
|
||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
// Skip if it's a node_modules import
|
return `from "${importPath}.js"`;
|
||||||
if (!importPath.startsWith(".")) {
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
fixedContent = fixedContent.replace(
|
||||||
|
/from\s+'(\.\.?\/[^']+)'/g,
|
||||||
|
(match, importPath) => {
|
||||||
|
if (importPath.endsWith(".js")) {
|
||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
// Add .js extension and return with proper quote
|
return `from '${importPath}.js'`;
|
||||||
return `from "${importPath}.js"${quote}`;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue