-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ts
32 lines (29 loc) · 1020 Bytes
/
build.ts
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
import WgslPlugin from './config/wgsl-loader/bun';
// first convert the wasm file to base64
// const dataS2Cell = await Bun.file('./zig-out/bin/optimized-s2cell.wasm').arrayBuffer();
const dataS2Cell = await Bun.file(
'./target/wasm32-unknown-unknown/release/optimized.wasm',
).arrayBuffer();
const u8S2Cell = Array.from(new Uint8Array(dataS2Cell));
const base64 = btoa(String.fromCharCode.apply(null, u8S2Cell));
const code = `export default '${base64}';\n`;
await Bun.write('./src/wasm/uint64.wasm.ts', code);
try {
console.info('Starting the build process...');
const output = await Bun.build({
entrypoints: ['src/index.ts'],
outdir: 'dist',
format: 'esm',
splitting: true,
minify: false,
sourcemap: 'external',
packages: 'external',
plugins: [WgslPlugin],
target: 'browser', // Adjust target based on your project needs
});
console.info(output);
console.info('Build completed successfully!');
} catch (error) {
console.error('Build failed:', error);
}
export {};