-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathbuild.js
More file actions
39 lines (32 loc) · 1.08 KB
/
build.js
File metadata and controls
39 lines (32 loc) · 1.08 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
const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');
// Run TypeScript compilation
console.log('Compiling TypeScript...');
const tscPath = path.join(__dirname, '../../../node_modules/.bin/tsc');
execSync(`${tscPath}`, { stdio: 'inherit', cwd: path.join(__dirname, '..') });
execSync(`${tscPath} -p tsconfig.esm.json`, { stdio: 'inherit', cwd: path.join(__dirname, '..') });
// Rename files to have correct extensions
const wasmDir = path.join(__dirname, '../wasm');
const cjsDir = path.join(__dirname, '../cjs');
const esmDir = path.join(__dirname, '../esm');
// Ensure wasm directory exists
if (!fs.existsSync(wasmDir)) {
fs.mkdirSync(wasmDir, { recursive: true });
}
// Rename CommonJS files
fs.renameSync(
path.join(cjsDir, 'index.js'),
path.join(wasmDir, 'index.cjs')
);
// Rename ESM files
fs.renameSync(
path.join(esmDir, 'index.js'),
path.join(wasmDir, 'index.js')
);
// Rename declaration files
fs.renameSync(
path.join(cjsDir, 'index.d.ts'),
path.join(wasmDir, 'index.d.ts')
);
console.log('Build completed successfully!');