Skip to content

Commit

Permalink
Merge branch 'main' into hub-optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
berekuk committed Dec 5, 2024
2 parents 4469bbb + ab23814 commit 50f22f2
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 16 deletions.
2 changes: 1 addition & 1 deletion packages/squiggle-lang/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"build": "pnpm run build:peggy && pnpm run build:ts && pnpm run build:worker",
"build:peggy": "peggy --cache --format es ./src/ast/peggyParser.peggy",
"build:ts": "tsc -b",
"build:worker": "esbuild src/runners/worker.ts --bundle --minify --platform=browser --outfile=dist/runners/esbuild-worker.cjs",
"build:worker": "esbuild src/runners/worker.ts --bundle --minify --platform=browser --format=esm --outfile=dist/runners/esbuild-worker.js",
"dev": "tsc -b -w",
"clean": "rm -rf dist && rm -f src/ast/peggyParser.js && rm *.tsbuildinfo",
"jest": "NODE_OPTIONS=--experimental-vm-modules jest",
Expand Down
15 changes: 4 additions & 11 deletions packages/squiggle-lang/src/runners/WebWorkerRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,11 @@ export class WebWorkerRunner extends AnyWorkerRunner {
* If you need to touch this code, make sure to check carefully both the components (storybook) and the hub editor.
* This configuration and the esbuild configuration in `package.json` are extremely fragile.
*
* In particular:
* 1. ESM is problematic:`{ type: "module" }` (with `.mjs` or `.js`)will seemingly work, but cause lots of Turbopack CLI errors; Turbopack fails to analyze `(url, { type: "module" })` parameters correctly, as of Next.js 15.0.3.
* 2. `.js` extension will collide with the default `"type": "module"` in `package.json`, which will lead to Next.js warnings.
*
* So, instead, we bundle the worker to the basic IIFE; see `package.json` for details.
*
* This might cause issues in the future, if we decide to depend on some library that's ESM-only; I'm not sure how good esbuild is for bundling ESM dependencies.
*
* But, for now, it seems like it's working.
* Details here: https://github.com/quantified-uncertainty/squiggle/pull/3456
*/
const url = new URL("./esbuild-worker.cjs", import.meta.url);
this.worker = new Worker(url);
this.worker = new Worker(new URL("./esbuild-worker.js", import.meta.url), {
type: "module",
});
}

async getWorker(): Promise<Worker> {
Expand Down
89 changes: 85 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 50f22f2

Please sign in to comment.