Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

fix(bindgen,format): enable wasm encoded to be used in the `bindgen!` macro (#12857)

Mikhail Katychev4ad29c7d1a76
diff --git a/crates/component-macro/src/bindgen.rs b/crates/component-macro/src/bindgen.rs
index 9636c7f342..8d3d49f2db 100644
--- a/crates/component-macro/src/bindgen.rs
+++ b/crates/component-macro/src/bindgen.rs
@@ -58,13 +58,16 @@ pub fn expand(input: &Config) -> Result<TokenStream> {
}
let mut contents = src.parse::<TokenStream>().unwrap();
- // Include a dummy `include_str!` for any files we read so rustc knows that
+ // Include a dummy `include_bytes!` for any files we read so rustc knows that
// we depend on the contents of those files.
for file in input.files.iter() {
contents.extend(
- format!("const _: &str = include_str!(r#\"{}\"#);\n", file.display())
- .parse::<TokenStream>()
- .unwrap(),
+ format!(
+ "const _: &[u8] = include_bytes!(r#\"{}\"#);\n",
+ file.display()
+ )
+ .parse::<TokenStream>()
+ .unwrap(),
);
}