completionId: cgen-179694e7d310494a8a612bc6d66e691b
cgen-179694e7d310494a8a612bc6d66e691b
This commit is contained in:
parent
7533ff683b
commit
6e6ed9804f
1 changed files with 11 additions and 8 deletions
19
build-api.js
19
build-api.js
|
|
@ -64,19 +64,22 @@ 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"
|
||||||
// This regex matches relative imports without .js extension
|
// Match relative imports (starting with . or ..) that don't end with .js
|
||||||
const fixedContent = content
|
const fixedContent = content.replace(
|
||||||
.replace(/from\s+["'](\.[^"']*?)(?<!\.js)(["'])/g, (match, path, quote) => {
|
/from\s+["'](\.[^"']*?)(?<!\.js)(["'])/g,
|
||||||
// Skip if it's already .js
|
(match, importPath, quote) => {
|
||||||
if (path.endsWith(".js")) {
|
// Skip if it already has .js
|
||||||
|
if (importPath.endsWith(".js")) {
|
||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
// Skip if it's a node_modules import
|
// Skip if it's a node_modules import
|
||||||
if (!path.startsWith(".")) {
|
if (!importPath.startsWith(".")) {
|
||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
return `from "${path}.js"${quote}`;
|
// Add .js extension and return with proper quote
|
||||||
});
|
return `from "${importPath}.js"${quote}`;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
if (fixedContent !== content) {
|
if (fixedContent !== content) {
|
||||||
fs.writeFileSync(fullPath, fixedContent);
|
fs.writeFileSync(fullPath, fixedContent);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue