Skip to content

Commit 998ea20

Browse files
author
zoey
authored
fix: project eval tool bundling (#29)
1 parent 94c3fe5 commit 998ea20

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
uses: oven-sh/setup-bun@v2
5050

5151
- name: Install dependencies
52-
run: bun install
52+
run: bun install && bun dist
5353

5454
- name: Run tests
5555
run: bun test

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
"types": "./dist/next-js.d.ts",
3939
"import": "./dist/next-js.js",
4040
"require": "./dist/next-js.js"
41-
}
41+
},
42+
"./package.json": "./package.json"
4243
},
4344
"files": [
4445
"dist/",

src/evaluation/code_executor.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import { fork } from 'child_process';
2+
import { createRequire } from 'module';
3+
import { dirname, join } from 'path';
24
import type { EvaluatedModuleResult, EvaluationRequest } from '../core';
35

46
export async function executeIsolated(request: EvaluationRequest): Promise<EvaluatedModuleResult> {
57
return new Promise(resolve => {
6-
const workerPath = require.resolve('./eval_worker');
8+
// Resolve worker path from package - works even when this code is bundled
9+
const require = createRequire(import.meta.url);
10+
const packageRoot = dirname(require.resolve('tidewave/package.json'));
11+
const workerPath = join(packageRoot, 'dist/evaluation/eval_worker.js');
712

813
const child = fork(workerPath, { silent: true });
914

0 commit comments

Comments
 (0)