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

Inline js support #11

Open
hanabi1224 opened this issue Mar 10, 2022 · 1 comment
Open

Inline js support #11

hanabi1224 opened this issue Mar 10, 2022 · 1 comment

Comments

@hanabi1224
Copy link

It looks like the plugin cannot properly bundle inlinejs, is there plan to support that?

Add below code to example/my-crate/src/lib.rs, then the build will fail

#[wasm_bindgen(inline_js = "export function alert2(msg) { alert(msg) }")]
extern "C" {
    fn alert2(s: &str);
}

#[wasm_bindgen]
pub fn greet2(name: &str) {
    alert2(&format!("Hello from js via rs,{}!", name));
}
@Yongle-Fu
Copy link

Yongle-Fu commented Jul 3, 2023

emcc support hope also. build by follow command

emcc -O3 -s WASM=1 \
	-s ASSERTIONS=1 \
	-s MODULARIZE=1 \
	-s ALLOW_MEMORY_GROWTH=1 \
	-s NODEJS_CATCH_EXIT=0 \
	-s NODEJS_CATCH_REJECTION=0 \
	-s EXPORT_NAME='XXXSDK' \
	-s EXPORTED_RUNTIME_METHODS='["cwrap"]' \
	-s LLD_REPORT_UNDEFINED \
	./build/lib_xxx.a \
	main.cpp \
	--post-js glue.js \
	-o ./dist/xxxx.js

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