Skip to content

Configure the section worker URL and warn when it fails to start - #345

Merged
InventivetalentDev merged 3 commits into
mainfrom
feat/section-worker-url
Oct 21, 2026
Merged

InventivetalentDev merged 3 commits into
mainfrom
feat/section-worker-url

Conversation

@InventivetalentDev

Copy link
Copy Markdown
Owner

What

Browser pages can tell MineRender where to load the world section worker from, and a failed worker start is no longer silent.

  • Option: registerBrowserEnv({ sectionWorker }) and new BrowserEnv({ sectionWorker }) accept a worker URL (string or URL) or a function that returns a Worker. Without the option, BrowserEnv.createWorker keeps the literal new Worker(new URL("./section.worker.mjs", import.meta.url), { type: "module" }) that bundlers detect.
  • Warnings: when the worker cannot be created, BrowserEnv logs a warning that sections build on the main thread and names the option. The worker's error and messageerror events log the same fallback through the SectionWorker logger. No warning is logged when the page has no Worker global.
  • Export: minerender/section.worker resolves to dist/browser/esm/env/browser/section.worker.mjs, so build scripts can copy the file without a deep path.
  • Types and docs: BrowserEnvOptions is exported from the browser entry. reference/platforms.md describes copying the worker and calling registerBrowserEnv; reference/concepts.md and AGENTS.md mention the option.

Why

The CommonJS and script-tag builds have no import.meta.url, and some bundlers do not emit the worker file. Those pages fell back to synchronous section builds without any message, and there was no supported way to point them at a copied worker file.

Risk

Low. The option is additive and the default code path is unchanged. Pages that already fall back without a worker now log one warning, for example the apps/web demos, which bundle without the worker file.

Testing

  • yarn workspace minerender typecheck, yarn build:lib, yarn workspace minerender test:package: pass. The built BrowserEnv.mjs still contains the literal worker URL once.
  • yarn test: 835 tests pass, including the new BrowserEnv.test.ts (URL, function, failed start, no Worker global, registerBrowserEnv) and the SectionMesh.test.ts warning checks.
  • Loaded the IIFE bundle in Chrome: with MineRender.registerBrowserEnv({ sectionWorker }) the worker started and no warning was logged; without it, the page logged the new warning and built sections on the main thread.

Note

AI-assisted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added library Public minerender package (packages/minerender) docs Documentation site, READMEs, and docs/ branches feature New functionality (feat/ branches) labels Oct 21, 2026
@InventivetalentDev
InventivetalentDev marked this pull request as ready for review October 21, 2026 19:10
@InventivetalentDev
InventivetalentDev merged commit 1ce900b into main Oct 21, 2026
3 checks passed
@InventivetalentDev
InventivetalentDev deleted the feat/section-worker-url branch October 21, 2026 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation site, READMEs, and docs/ branches feature New functionality (feat/ branches) library Public minerender package (packages/minerender)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant