fork of hey-api/openapi-ts because I need some additional things
1import fs from 'node:fs';
2import path from 'node:path';
3import { fileURLToPath } from 'node:url';
4
5import { defineConfig } from 'tsdown';
6
7const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
9export default defineConfig({
10 clean: true,
11 dts: true,
12 entry: ['./src/{index,run}.ts'],
13 format: ['esm'],
14 minify: false,
15 onSuccess: async () => {
16 // Copy client files to dist folder for runtime access
17 const pluginNames = ['client-httpx'];
18
19 for (const pluginName of pluginNames) {
20 const srcPath = path.resolve(__dirname, 'src', 'plugins', '@hey-api', pluginName, 'bundle');
21 const destPath = path.resolve(
22 __dirname,
23 'dist',
24 'clients',
25 pluginName.slice('client-'.length),
26 );
27
28 if (fs.existsSync(srcPath)) {
29 fs.mkdirSync(path.dirname(destPath), { recursive: true });
30 fs.cpSync(srcPath, destPath, { recursive: true });
31
32 // replace core imports in client bundle
33 // const clientFiles = fs.readdirSync(destPath);
34 // for (const file of clientFiles) {
35 // replaceCoreImports(path.resolve(destPath, file));
36 // }
37 }
38 }
39 },
40 sourcemap: true,
41 treeshake: true,
42});