Skip to content
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

不支持 wasm? #1422

Open
yurnery opened this issue Jul 17, 2024 · 2 comments · May be fixed by #1705
Open

不支持 wasm? #1422

yurnery opened this issue Jul 17, 2024 · 2 comments · May be fixed by #1705
Assignees
Labels
bug Something isn't working

Comments

@yurnery
Copy link

yurnery commented Jul 17, 2024

  1. 使用 wasm-pack new demo 创建一个demo
  2. 使用wasm-pack build打包
  3. 在 js 项目中引用打包出来的 package : const wasm = import('demo'); 引入后就报下面这个错, 但是这个 wasm 在 webpack 和 vite 中都是可以使用的.
image
@sorrycc sorrycc added the bug Something isn't working label Jul 18, 2024
@sorrycc
Copy link
Member

sorrycc commented Jul 18, 2024

试了下 wasm 的 runtime 部分确实有问题,我们之前验过 https://github.com/umijs/mako/blob/master/examples/import-resources/index.tsx#L3 ,需要找时间看下 wasm-pack 产物的差异是什么。

@YufJi
Copy link

YufJi commented Aug 1, 2024

从构建产物对比看,webpack对wasm文件的处理会解析出相应的importsObj。

尝试本地在mako产物中手动补上importsObj,可以正常执行
image

感觉可以参考的修复:https://github.com/web-infra-dev/rspack/blob/main/crates/rspack_plugin_wasm/src/parser_and_generator.rs#L46

@YufJi YufJi linked a pull request Nov 27, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants