feat(joint-router-avoid): worker.createWorker option and /worker subpath export - #3488
Open
kumilingus wants to merge 1 commit into
Open
feat(joint-router-avoid): worker.createWorker option and /worker subpath export#3488kumilingus wants to merge 1 commit into
kumilingus wants to merge 1 commit into
Conversation
kumilingus
force-pushed
the
feat/router-avoid-worker-factory
branch
from
August 26, 2026 18:08
c163c7f to
9f372fc
Compare
…port Angular CLI's esbuild builder only transforms 'new Worker(new URL(...))' spawns in application sources, so the provider's hardcoded spawn 404s at runtime and the worker script URL was not configurable. The new 'worker.createWorker' option lets the application spawn the Worker itself, and the '@joint/router-avoid/worker' subpath export gives it a public worker entry to spawn (same pattern as pdfjs-dist). The factory is stripped from the options posted to the Worker - a function cannot be structured-cloned. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
kumilingus
force-pushed
the
feat/router-avoid-worker-factory
branch
from
August 26, 2026 18:56
9f372fc to
c9066ef
Compare
Geliogabalus
approved these changes
Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
WorkerProviderspawns its Web Worker with a hardcodednew Worker(new URL('./Worker.mjs', import.meta.url), { type: 'module' }). That only works when the consumer's bundler transforms this pattern insidenode_modules(Vite, webpack 5). The Angular CLI esbuild builder transforms it only in application TS sources — at runtime the URL resolves against the main bundle (/Worker.mjs→ 404), and hand-copying the file cannot work either, since it contains bare@joint/core/libavoid-jsspecifiers. The worker script URL was not configurable at all.Changes
1.
worker.createWorkeroptionThe factory is stripped from the options posted to the Worker (a function cannot be structured-cloned). Default path unchanged — Vite/webpack consumers are unaffected.
2.
@joint/router-avoid/workersubpath exportPublic worker entry so the application-side worker file is one line —
import '@joint/router-avoid/worker';— and never references the privatedist/layout. Same pattern aspdfjs-distand the Monaco editor workers.Tests
TDD — written first and watched fail on
dev:worker.createWorker overrides how the routing Worker is spawned(factory called once, provider talks to the factory-created Worker through theinit/readyhandshake, worker options forwarded). 29/29 passing; lint clean. Changeset:@joint/router-avoidminor.The
MainThreadProvideridlefix that briefly lived on this branch was split out to #3489 (patch, againstmaster).🤖 Generated with Claude Code