-
- Notifications
You must be signed in to change notification settings - Fork 12
fix: wasm load error #677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: wasm load error #677
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { expect, test } from '@rstest/core'; | ||
| Check failure on line 1 in e2e/wasm/index.test.ts | ||
| | ||
| test('WASM factorial', async () => { | ||
| const { _Z4facti: AsyncFactorial } = await import('./src/factorial.wasm'); | ||
| | ||
| expect(AsyncFactorial(1)).toBe(1); | ||
| expect(AsyncFactorial(2)).toBe(2); | ||
| expect(AsyncFactorial(3)).toBe(6); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export function _Z4facti(n: number): number; |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| | @@ -171,6 +171,22 @@ export const loadModule = ({ | |||||
| assetFiles, | ||||||
| interopDefault, | ||||||
| ), | ||||||
| readWasmFile: ( | ||||||
| wasmPath: string, | ||||||
| callback: (err: Error | null, data?: Buffer) => void, | ||||||
| ) => { | ||||||
| const joinedPath = isRelativePath(wasmPath) | ||||||
| ? path.join(path.dirname(distPath), wasmPath) | ||||||
| : wasmPath; | ||||||
| const content = assetFiles[path.normalize(joinedPath)]; | ||||||
| if (content) { | ||||||
| callback(null, Buffer.from(content, 'utf-8')); | ||||||
| ||||||
| callback(null, Buffer.from(content, 'utf-8')); | |
| callback(null, Buffer.from(content, 'base64')); |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| | @@ -67,8 +67,11 @@ export async function printError( | |||||||||||||
| fullStack: error.fullStack, | ||||||||||||||
| getSourcemap, | ||||||||||||||
| }); | ||||||||||||||
| | ||||||||||||||
| if (!stackFrames.length && error.stack.length) { | ||||||||||||||
| if ( | ||||||||||||||
| !stackFrames.length && | ||||||||||||||
| Array.isArray(error.stack) && | ||||||||||||||
| error.stack.length | ||||||||||||||
| ) { | ||||||||||||||
| Comment on lines +70 to +74 | ||||||||||||||
| if ( | |
| !stackFrames.length && | |
| Array.isArray(error.stack) && | |
| error.stack.length | |
| ) { | |
| if (!stackFrames.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment 'Sets the object configurable so that imported properties can be spied' is misleading. This replacement changes
readFile(toreadWasmFile(to use the custom WASM file loader, not to set object configurability. The comment should be updated to reflect the actual purpose of this transformation.