如何自动将依赖性使用的WASM束?
我的网站使用包装。
该软件包是用C中编写的低级网络库的打字稿端口。移植是用Emscripten完成的,它为我们提供了networking.wasm
and networking.js 文件。我们添加了一些手动TS代码,以使用模式TS-IDIOMATION模式使用该软件包。
我希望我的React网站依赖该软件包,但我不想手动将networking.wasm
文件复制到我的public/static/static/js 目录
用于工作的基础“网络”软件包。我希望“网络”软件包可以使用简单的
npm install
从包装盒中进行操作。
如何使我的网站依赖于告诉WebPack添加networking.wasm
文件需要正确的位置?
如果不可能,什么是露出.wasm文件的最干净的解决方案,供软件包用户在正确的位置复制以获取的用户?
My website uses a package.
This package is a Typescript port of a low level networking library written in C. The porting was done with emscripten, which gives us a networking.wasm
and networking.js
files. We added some manual TS code to use the package in a mode TS-idiomatic way.
I want my react website to depend on that package, but I don't want to have to manually copy the networking.wasm
file into my public/static/js
directory for the underlying 'networking' package to work. I want the 'networking' package to work out of the box with a simple npm install
.
How can I make the 'networking' package my site depends on tell webpack to add the networking.wasm
file where it needs to be to be GET correctly ?
If this is not possible, what would be the cleanest solution to expose the .wasm file for the user of the package to copy in the right place to get GET ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于emscripten用户,您可以使用标志构建,
因此整个WASM二进制内容都会以字面字符串的形式写入生成的.js文件中。因此,您需要的只是生成的JavaScript文件,无需担心WebAssembly文件。
For emscripten user, you can build with the flag
so the entire wasm binary content gets written in the generated .js file as a literal string. Therefore all you need is the generated javascript file, no need to worry about the webassembly file.