Skip to content

Commit

Permalink
fix: browser tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Gozala committed Jan 30, 2024
1 parent 054c738 commit 4141473
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gen/wasm_bg.js

Large diffs are not rendered by default.

Binary file modified gen/wasm_bg.wasm
Binary file not shown.
14 changes: 11 additions & 3 deletions src/lib.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import load, { create } from "../gen/wasm.js"
import { code, CODE_LENGTH, HEIGHT_SIZE, ROOT_SIZE, MAX_SIZE } from './constant.js'
import {
code,
CODE_LENGTH,
HEIGHT_SIZE,
ROOT_SIZE,
MAX_SIZE,
} from "./constant.js"
export * from "./type.js"
export { code, CODE_LENGTH, HEIGHT_SIZE, ROOT_SIZE, MAX_SIZE }

Expand All @@ -11,8 +17,10 @@ export const CLOUDFLARE_WORKERS_NAVIGATOR = "Cloudflare-Workers"
/* c8 ignore start */
try {
if (globalThis.navigator?.userAgent === CLOUDFLARE_WORKERS_NAVIGATOR) {
// @ts-expect-error no declaration types
bytecode = (await import('../gen/wasm_bg.wasm')).default
// playwright tries to bundle imported file when it sees import with
// string literal. We workaround by using variable to import.
const wasm = "../gen/wasm_bg.wasm"
bytecode = (await import(wasm)).default
}
} catch {}
/* c8 ignore stop */
Expand Down

0 comments on commit 4141473

Please sign in to comment.