forked from Kanezal/better-antigravity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.mjs
More file actions
57 lines (51 loc) · 1.58 KB
/
build.mjs
File metadata and controls
57 lines (51 loc) · 1.58 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
import * as esbuild from 'esbuild';
import * as fs from 'fs';
import * as path from 'path';
const isWatch = process.argv.includes('--watch');
/** @type {esbuild.BuildOptions} */
const config = {
entryPoints: ['src/extension.ts'],
bundle: true,
outfile: 'dist/extension.js',
external: ['vscode'],
format: 'cjs',
platform: 'node',
target: 'es2020',
sourcemap: true,
minify: false,
// Resolve antigravity-sdk from monorepo sibling
alias: {
'antigravity-sdk': path.resolve('..', 'antigravity-sdk', 'dist', 'index.js'),
},
};
// Ensure dist/ exists
if (!fs.existsSync('dist')) fs.mkdirSync('dist');
// Copy sql-wasm.wasm AND sql-wasm.js to dist/ (required by antigravity-sdk's StateBridge)
const sqlFiles = ['sql-wasm.wasm', 'sql-wasm.js'];
for (const sqlFile of sqlFiles) {
const searchPaths = [
path.join('node_modules', 'sql.js', 'dist', sqlFile),
path.join('..', 'antigravity-sdk', 'node_modules', 'sql.js', 'dist', sqlFile),
];
let copied = false;
for (const src of searchPaths) {
if (fs.existsSync(src)) {
fs.copyFileSync(src, path.join('dist', sqlFile));
console.log(`Copied ${sqlFile} from ${src}`);
copied = true;
break;
}
}
if (!copied) {
console.error(`ERROR: ${sqlFile} not found. Run "npm install" first.`);
process.exit(1);
}
}
if (isWatch) {
const ctx = await esbuild.context(config);
await ctx.watch();
console.log('Watching...');
} else {
await esbuild.build(config);
console.log('Build complete');
}