Skip to content

convert inline worker generation to a post-processing step#449

Open
DTCurrie wants to merge 11 commits intomainfrom
make-worker-transform-post-process
Open

convert inline worker generation to a post-processing step#449
DTCurrie wants to merge 11 commits intomainfrom
make-worker-transform-post-process

Conversation

@DTCurrie
Copy link
Copy Markdown
Member

@DTCurrie DTCurrie commented Mar 3, 2026

Web workers using new Worker(new URL('./worker.js', import.meta.url)) break when consumed as a library because Vite's dep optimizer moves the package to .vite/deps/ but the worker file doesn't follow.

This PR switches from pre-generating inlined worker files in src/lib to post-processing dist/ after svelte-package.

  • src/lib/loaders/pcd/index.ts reverted to standard new Worker(new URL(...)) syntax
  • scripts/post-process-workers.js runs after svelte-package, bundles workers with esbuild, and rewrites dist/ to use Blob URLs
  • check/prepare scripts no longer need a pre-build step
  • Added scripts/README.md documenting both build scripts

The previous approach (pre-generating worker.inline.ts before svelte-package) required running a build step before check, didn't support HMR for worker changes in dev, and left generated files in the source tree. Post-processing dist/ solves all three: dev mode works natively with Vite, CI runs check without a pre-build, and the source stays clean.

I tested running locally, and the changes were reflected in HMR. By running pnpm preview and make up in the environments, I was able to file-drop a PCD and load it.

  • Test downstream with linking

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 3, 2026

⚠️ No Changeset found

Latest commit: 5e8ff89

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 3, 2026

Codecov Report

❌ Patch coverage is 1.56250% with 63 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
scripts/post-process-workers.js 0.00% 62 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@DTCurrie DTCurrie marked this pull request as ready for review April 2, 2026 16:39
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://viamrobotics.github.io/visualization/pr-preview/pr-449/

Built to branch gh-pages at 2026-05-04 14:17 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants