Skip to content

Build the BIDS validator worker from npm.jsr.io with Bun #474

Open

Description

@neuromechanist

Context

The upload page runs the BIDS validator in a Web Worker (#161, ADR 0028, PR #473).
The worker is a 10 MB file built with Deno from the pinned jsr:@bids/validator release and committed under public/vendor/bids-validator/<version>/, because Bun cannot install a jsr: specifier and Cloudflare's build has no Deno.

ADR 0028 ("Alternatives considered") records a second route and calls it viable but not taken.
The JavaScript Registry (JSR) also serves an npm-compatible registry, npm.jsr.io, and Bun installs @jsr/bids__validator from it with an [install.scopes] entry in bunfig.toml.
This issue is to build that route and, if it holds, replace the committed bundle with it.

What was measured

  • bun install from npm.jsr.io works with the scope entry, and puts 108 packages in node_modules for entry points that use a fraction of them.
  • bun build of the two entry points the worker imports (@bids/validator/files/browser and @bids/validator/validate) gave a bundle that, run in Node on five datasets made from the repository's fixtures, reported the same findings as the Deno build, messages included.
  • It was not built through Astro and Vite, which is the part this issue has to settle.

Why it may be worth doing

  • No 10 MB generated file in git history, and no re-vendor each time nemar-cli moves its pin (about monthly; each re-vendor is roughly 1.5 MB of history and needs Deno on a maintainer's machine).
  • No Deno anywhere in the repository's workflow.
  • A pin move becomes a copy of validator-version.json and an ordinary dependency update.

What stands in the way

  • The worker's Content-Security-Policy is a header rule on a fixed path (/vendor/bids-validator/* in public/_headers), and it is where the validator's 'unsafe-eval' lives, kept off the page's own policy.
    Astro and Vite give built files hashed names, so the build has to put the worker at a stable, versioned path, or the rule has to match a hashed one without widening.
  • Cloudflare's build would depend on npm.jsr.io being up, and on its packages not being replaced.
    Today the bytes are pinned by a committed Deno lock with integrity hashes, a SHA256SUMS file, a provenance record and the licence text of every package; a Bun lock has to carry the same guarantees, and the tests that check them (test/bids-validator-vendor.test.ts) have to check what is built instead.
  • The HED validator is most of the bundle, and splitting it would make the output depend on the bundler's chunk names; a single file is what the Deno route settled on.

Done when

  • The worker is built from packages pinned in bun.lock as part of bun run build, at a stable versioned path that the _headers rule matches without widening.
  • public/vendor/bids-validator/, scripts/vendor-bids-validator.ts, the Deno lock and the tests that guard the committed bytes are removed, or replaced by tests of what is built (integrity, the version marker, the licences).
  • test/bids-validator-integration.test.ts passes on the built worker unchanged, which holds the protocol, the gate, the panel and the wording as they are.
  • CI passes without Deno, and the pin drift test still compares validator-version.json with nemar-cli.
  • A new ADR supersedes ADR 0028 on the distribution route, and the protocol, gate, panel and tests it names are said to carry over.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions