forked from MayDay-wpf/snow-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-ncc.mjs
More file actions
29 lines (23 loc) · 693 Bytes
/
build-ncc.mjs
File metadata and controls
29 lines (23 loc) · 693 Bytes
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
import {exec} from 'child_process';
import {promisify} from 'util';
import {copyFileSync, mkdirSync, existsSync} from 'fs';
import {join} from 'path';
const execAsync = promisify(exec);
// Create bundle directory
if (!existsSync('bundle')) {
mkdirSync('bundle');
}
// Run ncc
console.log('Building with ncc...');
await execAsync('ncc build dist/cli.js -o bundle --minify');
// Copy WASM file
copyFileSync(
'node_modules/sql.js/dist/sql-wasm.wasm',
'bundle/sql-wasm.wasm',
);
// Rename index.js to cli.cjs
if (existsSync('bundle/index.js')) {
const {renameSync} = await import('fs');
renameSync('bundle/index.js', 'bundle/cli.cjs');
}
console.log('✓ Bundle created successfully');