Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
"import": "./dist/index.js",
"default": "./dist/index.js"
},
"./workerd": {
"types": "./dist/workerd.d.ts",
"import": "./dist/workerd.js",
"default": "./dist/workerd.js"
},
"./dist/sip.wasm": "./dist/sip.wasm"
},
"files": [
Expand Down
9 changes: 6 additions & 3 deletions src/decoders/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@ async function initCodecForNode(
initFn: (module: WebAssembly.Module) => Promise<any>,
wasmPath: string
): Promise<void> {
// Dynamic import for Node.js modules
const { readFile } = await import('fs/promises');
const { createRequire } = await import('module');
// Dynamic module names prevent esbuild/wrangler from resolving these
// at bundle time. Only Node.js reaches this function at runtime.
const fsModule = 'fs/promises';
const moduleModule = 'module';
const { readFile } = await import(/* @vite-ignore */ fsModule);
const { createRequire } = await import(/* @vite-ignore */ moduleModule);
const require = createRequire(import.meta.url);

// Resolve the WASM file path from the package
Expand Down
5 changes: 4 additions & 1 deletion src/wasm/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ async function doLoadWasm(): Promise<SipWasmModule> {
process.versions.node != null;

if (isNode) {
const { readFile } = await import('fs/promises');
// Dynamic module name prevents esbuild/wrangler from resolving this
// at bundle time. Only Node.js reaches this branch at runtime.
const fsModule = 'fs/promises';
const { readFile } = await import(/* @vite-ignore */ fsModule);
const wasmBinary = await readFile(new URL('./sip.wasm', import.meta.url));
const module = await createSipModule({ wasmBinary });
return module as SipWasmModule;
Expand Down
Loading