diff --git a/guide/src/assets/index.md b/guide/src/assets/index.md index 1ca3bf55..0a6d837f 100644 --- a/guide/src/assets/index.md +++ b/guide/src/assets/index.md @@ -25,6 +25,7 @@ This will typically look like: `, /// The value of the `--target` flag for wasm-bindgen. wasm_bindgen_target: WasmBindgenTarget, /// Name for the module. Is binary name if given, otherwise it is the name of the cargo @@ -169,6 +171,12 @@ impl RustApp { WasmOptLevel::Off } }); + let wasm_opt_params = attrs + .get("data-wasm-opt-params") + .iter() + .flat_map(|val| val.split_whitespace()) + .map(|val| val.to_string()) + .collect(); let wasm_bindgen_target = attrs .get("data-bindgen-target") .map(|s| s.parse()) @@ -282,6 +290,7 @@ impl RustApp { reference_types, weak_refs, wasm_opt, + wasm_opt_params, wasm_bindgen_target, app_type, name, @@ -331,6 +340,7 @@ impl RustApp { reference_types: false, weak_refs: false, wasm_opt: WasmOptLevel::Off, + wasm_opt_params: Default::default(), app_type: RustAppType::Main, wasm_bindgen_target: WasmBindgenTarget::Web, name, @@ -890,6 +900,7 @@ impl RustApp { let output = output.join(format!("{}_bg.wasm", self.name)); let arg_output = format!("--output={output}"); let arg_opt_level = format!("-O{}", self.wasm_opt.as_ref()); + let arg_opt_params = self.wasm_opt_params.as_slice(); let target_wasm = self .cfg .staging_dist @@ -902,6 +913,8 @@ impl RustApp { args.push("--enable-reference-types"); } + args.extend(arg_opt_params.iter().map(|s| s.as_str())); + // Invoke wasm-opt. tracing::debug!("calling wasm-opt"); common::run_command(wasm_opt_name, &wasm_opt, &args, &self.cfg.working_directory)