如何自动将依赖性使用的WASM束?

发布于 2025-02-11 12:02:54 字数 500 浏览 0 评论 0原文

我的网站使用包装。
该软件包是用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沒落の蓅哖 2025-02-18 12:02:54

对于emscripten用户,您可以使用标志构建,

-s SINGLE_FILE=1

因此整个WASM二进制内容都会以字面字符串的形式写入生成的.js文件中。因此,您需要的只是生成的JavaScript文件,无需担心WebAssembly文件。

For emscripten user, you can build with the flag

-s SINGLE_FILE=1

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文