Skip to content

Conversation

@9aoy
Copy link
Contributor

@9aoy 9aoy commented Nov 6, 2025

Summary

TODO: below error should be fixed in rspack 1.6.2 web-infra-dev/rspack#12068
image

Related Links

fix: #676

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings November 6, 2025 11:51
@netlify
Copy link

netlify bot commented Nov 6, 2025

Deploy Preview for rstest-dev ready!

Name Link
🔨 Latest commit ed0cce8
🔍 Latest deploy log https://app.netlify.com/projects/rstest-dev/deploys/690d6820b97aea000879a6ff
😎 Deploy Preview https://deploy-preview-677--rstest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for WebAssembly (WASM) modules in Rstest by implementing a custom WASM file loader and integrating it with the runtime module system.

  • Adds readWasmFile function to load WASM files from asset files
  • Modifies the async_wasm_loading runtime module to use the custom WASM loader
  • Prevents WASM files from being externalized during bundling
  • Adds an E2E test for WASM factorial function

Reviewed Changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/core/src/runtime/worker/loadModule.ts Implements readWasmFile function to load WASM files from asset files
packages/core/src/core/plugins/mockRuntime.ts Patches async_wasm_loading runtime module to use custom WASM loader
packages/core/src/core/plugins/external.ts Excludes WASM files from externalization
packages/core/src/utils/error.ts Adds type guard for error.stack
e2e/wasm/index.test.ts E2E test for WASM module loading
e2e/wasm/src/factorial.wasm.d.ts TypeScript declaration for WASM module
e2e/wasm/src/factorial.wasm Binary WASM file for testing

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +70 to +74
if (
!stackFrames.length &&
Array.isArray(error.stack) &&
error.stack.length
) {
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Array.isArray(error.stack) check is incorrect. According to the FormattedError type definition, error.stack is typed as string | undefined, not an array. This check will always be false. The condition should simply check if error.stack is a non-empty string.

Suggested change
if (
!stackFrames.length &&
Array.isArray(error.stack) &&
error.stack.length
) {
if (!stackFrames.length) {

Copilot uses AI. Check for mistakes.
: wasmPath;
const content = assetFiles[joinedPath];
if (content) {
callback(null, Buffer.from(content, 'utf-8'));
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WASM files are binary data, not UTF-8 text. Using Buffer.from(content, 'utf-8') will corrupt the binary data. The assetFiles dictionary stores file contents as strings, so they should be decoded using base64 encoding (e.g., Buffer.from(content, 'base64')) or the content should be stored and retrieved as binary data without text encoding.

Suggested change
callback(null, Buffer.from(content, 'utf-8'));
callback(null, Buffer.from(content, 'base64'));

Copilot uses AI. Check for mistakes.

if (module.name === 'async_wasm_loading') {
const finalSource = module.source!.source.toString('utf-8').replace(
// Sets the object configurable so that imported properties can be spied
Copy link

Copilot AI Nov 6, 2025

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( to readWasmFile( 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.

Suggested change
// Sets the object configurable so that imported properties can be spied
// Replace readFile with readWasmFile to use the custom WASM file loader

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: load wasm error

2 participants