Skip to content

Fix browser WASM loader for remapped bundler builds#990

Merged
zxch3n merged 3 commits into
mainfrom
fix/loro-issue-988
May 26, 2026
Merged

Fix browser WASM loader for remapped bundler builds#990
zxch3n merged 3 commits into
mainfrom
fix/loro-issue-988

Conversation

@lodyai
Copy link
Copy Markdown
Contributor

@lodyai lodyai Bot commented May 25, 2026

Summary

  • Fix the browser WASM loader used by bundler browser remaps so synchronous document XHR no longer sets responseType.
  • Generate named WASM imports/re-exports for the browser patch so Parcel scope-hoisted builds can execute.
  • Add explicit WASM re-exports in ESM package entrypoints and add a changeset.

Fixes #988

Validation

  • pnpm dlx deno run -A ./scripts/build.ts release browser
  • pnpm exec rollup -c
  • PATH="$PWD/node_modules/.bin:$PATH" pnpm dlx deno run -A ./scripts/post-rollup.ts
  • pnpm --dir examples/bundler-smoke-tests run test:fast
  • pnpm --dir examples/bundler-smoke-tests run test:next
  • Browser runtime matrix in Chromium/Playwright: Vite 5/6/7/8, Rolldown Vite, Webpack 5, Rsbuild 2, Rspack 2, Esbuild default/base64, Rollup default/base64, Parcel 2, Next 16 Turbopack, Next 16 Webpack.
  • Issue repro repo /tmp/loro-issue-988: Vite dev page loads, dynamic new LoroDoc() succeeds, no page errors or console errors.
  • pnpm dlx prettier --check crates/loro-wasm/scripts/browser_patch.js crates/loro-wasm/scripts/build.ts crates/loro-wasm/scripts/post-rollup.ts .changeset/fix-browser-sync-wasm.md
  • git diff --check

@lodyai
Copy link
Copy Markdown
Contributor Author

lodyai Bot commented May 25, 2026

Additional validation completed for the exact browser snippet:

import { LoroDoc } from "loro-crdt"

const doc = new LoroDoc();
doc.getText("t").insert(0, "hi")
console.log(doc.toJSON()) // { t: "hi" }

I rebuilt the bundler smoke matrix with this snippet and verified in Chromium/Playwright that every case produced doc.toJSON() exactly equal to { t: "hi" }:

  • Vite 5/6/7/8
  • Rolldown Vite
  • Webpack 5
  • Rsbuild 2
  • Rspack 2
  • Esbuild default-copy/base64
  • Rollup default-copy/base64
  • Parcel 2
  • Next 16 Turbopack
  • Next 16 Webpack

All cases passed with no browser page errors or console errors.

@github-actions
Copy link
Copy Markdown
Contributor

WASM Size Report

  • Original size: 2999.99 KB
  • Gzipped size: 990.47 KB
  • Brotli size: 695.95 KB

@zxch3n zxch3n merged commit ebee770 into main May 26, 2026
1 check passed
@zxch3n zxch3n deleted the fix/loro-issue-988 branch May 26, 2026 01:48
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.12.2] Uncaught InvalidAccessError: Failed to set the 'responseType' property

1 participant