-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtsdown.exe.config.ts
More file actions
67 lines (58 loc) · 1.96 KB
/
Copy pathtsdown.exe.config.ts
File metadata and controls
67 lines (58 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import type { ExeTarget } from '@tsdown/exe';
import { defineConfig } from 'tsdown';
import pkg from './package.json' with { type: 'json' };
import { SEA_MANIFEST_KEY, seaAssetKey } from './src/sea.ts';
import { clientPlugins, getClientBundleDir } from './tsdown-utils.ts';
const assets: Record<string, string> = {};
const manifest: Record<string, Array<string>> = {};
const seaTmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'hey-api-sea-'));
for (const pluginName of clientPlugins) {
const clientName = pluginName.slice('client-'.length);
const bundleDir = getClientBundleDir(pluginName);
if (fs.existsSync(bundleDir)) {
manifest[clientName] = [];
for (const file of fs.readdirSync(bundleDir)) {
const key = seaAssetKey(clientName, file);
assets[key] = path.resolve(bundleDir, file);
manifest[clientName].push(file);
}
}
}
const manifestPath = path.resolve(seaTmpDir, 'sea-manifest.json');
fs.writeFileSync(manifestPath, JSON.stringify(manifest));
assets[SEA_MANIFEST_KEY] = manifestPath;
const nodeVersion = fs
.readFileSync(path.resolve(import.meta.dirname, '..', '..', '.nvmrc'), 'utf-8')
.trim();
export default defineConfig(() => {
const targets = process.env.CI
? ([
{ arch: 'x64', nodeVersion, platform: 'linux' },
{ arch: 'arm64', nodeVersion, platform: 'linux' },
{ arch: 'arm64', nodeVersion, platform: 'darwin' },
{ arch: 'x64', nodeVersion, platform: 'win' },
] as const satisfies Array<ExeTarget>)
: undefined;
return {
deps: {
alwaysBundle: Object.keys(pkg.dependencies),
},
entry: ['./src/run.ts'],
exe: {
fileName: 'openapi-python',
seaConfig: {
assets,
disableExperimentalSEAWarning: true,
...(targets && {
useCodeCache: false,
useSnapshot: false,
}),
},
targets,
},
platform: 'node' as const,
};
});