wasmbind-js-file-macro

Crates.iowasmbind-js-file-macro
lib.rswasmbind-js-file-macro
version0.1.5
sourcesrc
created_at2024-10-22 22:17:01.429792
updated_at2024-11-08 15:53:10.647662
descriptionProvide a macro to generate JavaScript bindings from an external JS file
homepage
repositoryhttps://github.com/corebreaker/rs-trading-charts
max_upload_size
id1419398
size5,680
Frédéric Meyer (corebreaker)

documentation

https://docs.rs/wasmbind-js-file-macro

README

Crates.io Docs.rs

Wasmbind JS File Macro

Provide a macro to generate JavaScript bindings from an external JS file.

The procedural macro will generate the #[wasm_bindgen] attribute with parameter inline_js. The parameter inline_js will be filled by this macro with the content of the file that the path is passed as the argument path of this macro. The path can contain ${outDir} placeholders which is the value of the OUT_DIR environment variable.

Pre-requisites

The crate wasm-bindgen must be in the dependencies of the project.

Example

use wasmbind_js_macro::wasmbind_js;

#[wasmbind_dump_js_file_as_inline(path = "${outDir}/js/external.js")]
extern "C" {
    fn external_function();
}

This will generate the following code:

#[wasm_bindgen(inline_js = r###" ... here is the content of the file external.js ... "###)]
extern "C" {
    fn external_function();
}
Commit count: 50

cargo fmt