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

Rust编译及输出优化 #19

Open
honwhy opened this issue Sep 5, 2024 · 1 comment
Open

Rust编译及输出优化 #19

honwhy opened this issue Sep 5, 2024 · 1 comment

Comments

@honwhy
Copy link

honwhy commented Sep 5, 2024

大致浏览器了js端如果使用wasm的,如md5

MD5Algo.wasm = await loadWasm(wasmBytes);

而这个wasmBytes 应该就是在做来自Rust项目编译后的内容,

// file: md5_wasm.js
import { generateWasmBytes } from '../../utils/wasm-utils';

export const wasmBytes = generateWasmBytes('eJy1XH+cVcV1n5l736+977EXREUWZd4VFVRgf79dNA13FZASgp9+...');

有没有可能在Rust编译后,将输出产物写入到一个文件,,然后在 md5_wasm.js 中类似Vite 那种方式

import wasmStrings from './md5_build.wasm?raw' 
@PeterAlfredLee
Copy link
Member

这种是比较理想的使用方式,但是在浏览器端,需要经过配置,将.wasm暴露后才可以使用,成本比较高
如果有Node和浏览器端都兼容的使用方式,欢迎给我介绍说明一下,当然,如果能提交PR的话就更好了:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants