-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
40 lines (33 loc) · 1.06 KB
/
build.js
File metadata and controls
40 lines (33 loc) · 1.06 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
import fs from 'node:fs';
import path from 'node:path';
import { build } from 'esbuild';
const distDir = path.resolve('dist');
const outputFile = path.join(distDir, 'jmw');
const distPackageJson = path.join(distDir, 'package.json');
async function main() {
try {
console.log('Building jmw with Node + esbuild...');
fs.rmSync(distDir, { recursive: true, force: true });
fs.mkdirSync(distDir, { recursive: true });
await build({
entryPoints: ['src/cli.js'],
outfile: outputFile,
bundle: true,
platform: 'node',
format: 'esm',
target: ['node20'],
banner: {
js: "#!/usr/bin/env node\nimport { createRequire } from 'node:module';\nconst require = createRequire(import.meta.url);"
},
minify: true,
legalComments: 'none'
});
fs.writeFileSync(distPackageJson, JSON.stringify({ type: 'module' }, null, 2) + '\n');
fs.chmodSync(outputFile, 0o755);
console.log('✓ Build complete: dist/jmw');
} catch (error) {
console.error('Build failed:', error);
process.exit(1);
}
}
main();