This commit is contained in:
2026-07-31 15:07:12 +08:00
parent 3448ffe961
commit 9d92f86f08
49 changed files with 13833 additions and 1265 deletions

15
scripts/alias-hooks.mjs Normal file
View File

@@ -0,0 +1,15 @@
import path from 'path';
import fs from 'fs';
import { pathToFileURL } from 'url';
export async function resolve(specifier, context, nextResolve) {
if (specifier.startsWith('@/')) {
let abs = path.join(process.cwd(), 'src', specifier.slice(2));
if (!fs.existsSync(abs) && !path.extname(abs)) {
if (fs.existsSync(abs + '.js')) abs += '.js';
else if (fs.existsSync(path.join(abs, 'index.js'))) abs = path.join(abs, 'index.js');
}
return { shortCircuit: true, url: pathToFileURL(abs).href };
}
return nextResolve(specifier, context);
}