Build lightweight AI agent admin
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import { build } from 'vite';
|
||||
|
||||
function tracePlugin() {
|
||||
const importers = [];
|
||||
return {
|
||||
name: 'trace-jiti-importer',
|
||||
async resolveId(source, importer, options) {
|
||||
if (source.includes('jiti') || importer?.includes('jiti')) {
|
||||
console.log('[resolve]', JSON.stringify({ source, importer }));
|
||||
}
|
||||
const resolved = await this.resolve(source, importer, {
|
||||
...options,
|
||||
skipSelf: true,
|
||||
});
|
||||
if (resolved?.id?.includes('jiti') || source.includes('jiti')) {
|
||||
console.log(
|
||||
'[resolved]',
|
||||
JSON.stringify({ source, importer, resolved: resolved?.id }),
|
||||
);
|
||||
}
|
||||
return resolved;
|
||||
},
|
||||
moduleParsed(info) {
|
||||
if (info.importedIds.some((id) => id.includes('jiti'))) {
|
||||
importers.push({
|
||||
id: info.id,
|
||||
importedIds: info.importedIds.filter((id) => id.includes('jiti')),
|
||||
});
|
||||
console.log('[imports-jiti]', JSON.stringify(importers.at(-1)));
|
||||
}
|
||||
if (info.id.includes('jiti')) {
|
||||
console.log('[module-jiti]', info.id);
|
||||
console.log('[jiti-importers]', JSON.stringify(importers, null, 2));
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
await build({
|
||||
configFile: './vite.config.mts',
|
||||
mode: 'production',
|
||||
plugins: [tracePlugin()],
|
||||
build: {
|
||||
write: false,
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user