Prettier format pending files
This commit is contained in:
parent
fa9d8ed717
commit
f26047f125
1 changed files with 8 additions and 8 deletions
16
build-api.js
16
build-api.js
|
|
@ -40,7 +40,7 @@ console.log("Step 2: Transpiling to JavaScript with ESM imports...");
|
||||||
try {
|
try {
|
||||||
execSync(
|
execSync(
|
||||||
`npx esbuild "${destApi}/**/*.ts" --platform=node --target=es2020 --format=esm --outdir="${destApi}" --allow-overwrite`,
|
`npx esbuild "${destApi}/**/*.ts" --platform=node --target=es2020 --format=esm --outdir="${destApi}" --allow-overwrite`,
|
||||||
{ cwd: __dirname, stdio: "inherit" }
|
{ cwd: __dirname, stdio: "inherit" },
|
||||||
);
|
);
|
||||||
console.log("✓ Transpiled to JavaScript");
|
console.log("✓ Transpiled to JavaScript");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -53,32 +53,32 @@ let fixedCount = 0;
|
||||||
|
|
||||||
function fixImportsInDir(dir) {
|
function fixImportsInDir(dir) {
|
||||||
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
||||||
|
|
||||||
for (const entry of entries) {
|
for (const entry of entries) {
|
||||||
const fullPath = path.join(dir, entry.name);
|
const fullPath = path.join(dir, entry.name);
|
||||||
|
|
||||||
if (entry.isDirectory()) {
|
if (entry.isDirectory()) {
|
||||||
fixImportsInDir(fullPath);
|
fixImportsInDir(fullPath);
|
||||||
} else if (entry.name.endsWith(".js")) {
|
} else if (entry.name.endsWith(".js")) {
|
||||||
let content = fs.readFileSync(fullPath, "utf-8");
|
let content = fs.readFileSync(fullPath, "utf-8");
|
||||||
|
|
||||||
// Fix relative imports for ESM: "../../_supabase" -> "../../_supabase.js"
|
// Fix relative imports for ESM: "../../_supabase" -> "../../_supabase.js"
|
||||||
let fixedContent = content.replace(
|
let fixedContent = content.replace(
|
||||||
/from\s+"(\.\.?\/[^"]+)"/g,
|
/from\s+"(\.\.?\/[^"]+)"/g,
|
||||||
(match, importPath) => {
|
(match, importPath) => {
|
||||||
if (importPath.endsWith(".js")) return match;
|
if (importPath.endsWith(".js")) return match;
|
||||||
return `from "${importPath}.js"`;
|
return `from "${importPath}.js"`;
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
fixedContent = fixedContent.replace(
|
fixedContent = fixedContent.replace(
|
||||||
/from\s+'(\.\.?\/[^']+)'/g,
|
/from\s+'(\.\.?\/[^']+)'/g,
|
||||||
(match, importPath) => {
|
(match, importPath) => {
|
||||||
if (importPath.endsWith(".js")) return match;
|
if (importPath.endsWith(".js")) return match;
|
||||||
return `from '${importPath}.js'`;
|
return `from '${importPath}.js'`;
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (fixedContent !== content) {
|
if (fixedContent !== content) {
|
||||||
fs.writeFileSync(fullPath, fixedContent);
|
fs.writeFileSync(fullPath, fixedContent);
|
||||||
fixedCount++;
|
fixedCount++;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue