Update napcat-types usage and config in plugin

Changed napcat-plugin-builtin to use workspace reference for napcat-types instead of a fixed version. Updated tsconfig to use bundler module resolution and improved Vite config plugin resolution. Enhanced napcat-types package.json exports for better type support.
This commit is contained in:
手瓜一十雪 committed 2026-01-27 20:22:40 +08:00
1 parent 25714244dc
commit 15a983d392
7 files changed
+55 -17

No files matched your search

+5 -1
View File
@@ -1,4 +1,4 @@
// 复制 cp README.md dist/ && cp package.public.json dist/package.json
// 复制 cp README.md dist/ && cp package.public.json dist/package.json && cp external-shims.d.ts dist/
import { copyFile } from 'node:fs/promises';
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
@@ -10,4 +10,8 @@ await copyFile(
await copyFile(
join(__dirname, 'README.md'),
join(__dirname, 'dist', 'README.md')
);
await copyFile(
join(__dirname, 'external-shims.d.ts'),
join(__dirname, 'dist', 'external-shims.d.ts')
);
@@ -0,0 +1,41 @@
import { readdir, readFile, writeFile, rename } from 'node:fs/promises';
import { join, extname, basename } from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = fileURLToPath(new URL('../', import.meta.url));
const distDir = join(__dirname, 'dist');
async function traverseDirectory (dir) {
const entries = await readdir(dir, { withFileTypes: true });
for (const entry of entries) {
const fullPath = join(dir, entry.name);
if (entry.isDirectory()) {
await traverseDirectory(fullPath);
} else if (entry.isFile() && entry.name.endsWith('.d.ts')) {
await processFile(fullPath);
}
}
}
async function processFile (filePath) {
// Read file content
let content = await readFile(filePath, 'utf-8');
// Replace "export declare enum" with "export enum"
content = content.replace(/export declare enum/g, 'export enum');
// Write back the modified content
await writeFile(filePath, content, 'utf-8');
// Rename .d.ts to .ts
const newPath = filePath.replace(/\.d\.ts$/, '.ts');
await rename(filePath, newPath);
console.log(`Processed: ${basename(filePath)} -> ${basename(newPath)}`);
}
console.log('Starting post-build processing...');
await traverseDirectory(distDir);
console.log('Post-build processing completed!');