Skip to content

Commit 61fa63f

Browse files
committed
fix: wrangler build requirements
1 parent 74ce3be commit 61fa63f

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

server/build.js

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,40 @@ const { execSync } = require('child_process');
22
const fs = require('fs');
33
const path = require('path');
44

5+
// Install Rust if not installed
6+
console.log('Installing Rust toolchain...');
7+
try {
8+
execSync('rustc --version');
9+
console.log('Rust already installed');
10+
} catch {
11+
console.log('Installing Rust...');
12+
execSync('curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y', {
13+
stdio: 'inherit'
14+
});
15+
// Add cargo to PATH
16+
process.env.PATH = `${process.env.HOME}/.cargo/bin:${process.env.PATH}`;
17+
}
18+
19+
// Install wasm-pack if not installed
20+
console.log('Installing wasm-pack...');
21+
try {
22+
execSync('wasm-pack --version');
23+
console.log('wasm-pack already installed');
24+
} catch {
25+
console.log('Installing wasm-pack...');
26+
execSync('curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh', {
27+
stdio: 'inherit'
28+
});
29+
}
30+
531
if (!fs.existsSync('server/pkg')) {
6-
fs.mkdirSync('server/pkg');
32+
fs.mkdirSync('server/pkg', { recursive: true });
733
}
834

935
console.log('Building WebAssembly module...');
1036
execSync('wasm-pack build --target web --out-dir server/pkg --no-default-features --features worker', {
1137
stdio: 'inherit',
12-
cwd: path.resolve(__dirname, '..'),
38+
cwd: process.cwd(),
1339
});
1440

1541
console.log('Generating TypeScript types...');
@@ -23,6 +49,6 @@ export interface AnalyzeOptions {
2349
export function analyze_url(url: string, options: AnalyzeOptions): Promise<any>;
2450
`;
2551

26-
fs.writeFileSync(path.join(__dirname, 'pkg', 'bytes_radar.d.ts'), typesContent);
52+
fs.writeFileSync(path.join(process.cwd(), 'server/pkg', 'bytes_radar.d.ts'), typesContent);
2753

28-
console.log('Build complete!');
54+
console.log('Build complete!');

0 commit comments

Comments
 (0)