Skip to content

Add sync and workerd entrypoints for Cloudflare runtimes#61

Open
calclavia wants to merge 1 commit into
eclipse-biscuit:mainfrom
calclavia:cloudflare-runtime-entry
Open

Add sync and workerd entrypoints for Cloudflare runtimes#61
calclavia wants to merge 1 commit into
eclipse-biscuit:mainfrom
calclavia:cloudflare-runtime-entry

Conversation

@calclavia
Copy link
Copy Markdown

Summary

Cloudflare Workers and other workerd-style runtimes import .wasm assets as precompiled WebAssembly.Module objects, while this package currently only publishes the wasm-pack --target bundler entrypoint. That forces downstream consumers to patch the generated loader or maintain wrapper packages just to instantiate biscuit-wasm in Cloudflare-style runtimes.

This PR upstreams that runtime support without changing the existing bundler path.

  • add a new @biscuit-auth/biscuit-wasm/sync entrypoint with initSync(...) for runtimes that can provide a precompiled WebAssembly.Module or raw wasm bytes
  • add a workerd export condition plus an explicit @biscuit-auth/biscuit-wasm/workerd subpath that initializes from biscuit_bg.wasm automatically
  • generate the manual-init runtime files during prepare-package, discovering snippet import paths from the built package instead of hardcoding wasm-bindgen hash directories in source
  • expose ./module/biscuit_bg.js and ./module/biscuit_bg.wasm subpaths for custom loaders, and document the new runtime options in the README
  • add a JS regression test that exercises the new sync entry against a precompiled WebAssembly.Module

Test plan

  • npm run check-format
  • cargo fmt --check
  • cargo clippy -- -D warnings
  • npm run prepare-package
  • cd js-tests && npm install && npm test
  • cd examples/node && npm install && npm start

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.

1 participant