From cd2e121510b943f9769a6fdef7632daf4f161385 Mon Sep 17 00:00:00 2001 From: Rafael Beckel Date: Wed, 12 Nov 2025 04:34:58 +0100 Subject: [PATCH 01/20] build: add --wbg-arg passthrough to wasm-bindgen - Add repeatable --wbg-arg (alias: --wbg) to forward args to wasm-bindgen - Wire args through build pipeline and bindgen invocation - Docs: usage examples and notes - Tests: verify passthrough forwards unknown flag --- docs/src/commands/build.md | 13 +++++++++++++ src/bindgen.rs | 5 +++++ src/command/build.rs | 8 ++++++++ tests/all/build.rs | 23 +++++++++++++++++++++++ 4 files changed, 49 insertions(+) diff --git a/docs/src/commands/build.md b/docs/src/commands/build.md index 9b12922e5..66f07fe28 100644 --- a/docs/src/commands/build.md +++ b/docs/src/commands/build.md @@ -138,6 +138,19 @@ example, to build the previous example using cargo's offline feature: wasm-pack build examples/js-hello-world --mode no-install -- --offline ``` +## Passing arguments to wasm-bindgen + +You can forward arbitrary flags to the underlying `wasm-bindgen` CLI by repeating `--wbg-arg` (alias: `--wbg`). For example: + +``` +wasm-pack build --wbg-arg --experimental-reset-state-function +wasm-pack build --wbg-arg --weak-refs --wbg-arg --reference-types +``` + +Notes: +- `--wbg-arg` may be specified multiple times; each value is appended to the `wasm-bindgen` invocation. +- If a forwarded flag conflicts with a default flag that wasm-pack sets, the later one on the command line takes effect. +
0 If you need to include additional assets in the pkg diff --git a/src/bindgen.rs b/src/bindgen.rs index 1c0f9e9ad..06a8cac78 100644 --- a/src/bindgen.rs +++ b/src/bindgen.rs @@ -22,6 +22,7 @@ pub fn wasm_bindgen_build( target: Target, profile: BuildProfile, extra_options: &Vec, + bindgen_args: &[String], ) -> Result<()> { let profile_name = match profile.clone() { BuildProfile::Release | BuildProfile::Profiling => "release", @@ -96,6 +97,10 @@ pub fn wasm_bindgen_build( cmd.arg("--split-linked-modules"); } + for a in bindgen_args { + cmd.arg(a); + } + child::run(cmd, "wasm-bindgen").context("Running the wasm-bindgen CLI")?; Ok(()) } diff --git a/src/command/build.rs b/src/command/build.rs index 11d3ab98b..3f05a4406 100644 --- a/src/command/build.rs +++ b/src/command/build.rs @@ -40,6 +40,7 @@ pub struct Build { pub out_name: Option, pub bindgen: Option, pub cache: Cache, + pub bindgen_args: Vec, pub extra_options: Vec, } @@ -182,6 +183,10 @@ pub struct BuildOptions { /// Option to skip optimization with wasm-opt pub no_opt: bool, + #[clap(long = "wbg-arg", visible_alias = "wbg", allow_hyphen_values = true)] + /// Pass an argument to wasm-bindgen. May be used multiple times. + pub wbg_arg: Vec, + /// List of extra options to pass to `cargo build` pub extra_options: Vec, } @@ -205,6 +210,7 @@ impl Default for BuildOptions { profile: None, out_dir: String::new(), out_name: None, + wbg_arg: Vec::new(), extra_options: Vec::new(), } } @@ -259,6 +265,7 @@ impl Build { out_name: build_opts.out_name, bindgen: None, cache: cache::get_wasm_pack_cache()?, + bindgen_args: build_opts.wbg_arg, extra_options: build_opts.extra_options, }) } @@ -445,6 +452,7 @@ impl Build { self.target, self.profile.clone(), &self.extra_options, + &self.bindgen_args, )?; info!("wasm bindings were built at {:#?}.", &self.out_dir); Ok(()) diff --git a/tests/all/build.rs b/tests/all/build.rs index c588d6bde..23c38590e 100644 --- a/tests/all/build.rs +++ b/tests/all/build.rs @@ -421,3 +421,26 @@ fn build_crates_with_same_names() { .assert() .success(); } + +#[test] +fn build_forwards_wbg_arg_to_wasm_bindgen() { + let fixture = utils::fixture::js_hello_world(); + fixture.install_local_wasm_bindgen(); + + let cmd = fixture + .wasm_pack() + .arg("build") + .arg("--target") + .arg("web") + .arg("--wbg-arg") + .arg("--this-flag-should-be-forwarded") + .assert() + .failure(); + + let output = String::from_utf8(cmd.get_output().stderr.clone()).unwrap(); + assert!( + output.contains("--this-flag-should-be-forwarded"), + "stderr did not contain forwarded flag, stderr was: {}", + output + ); +} From 4aa7b7f2e66b8bd862e2217d494cc590cbed345e Mon Sep 17 00:00:00 2001 From: Rafael Beckel Date: Wed, 12 Nov 2025 04:35:28 +0100 Subject: [PATCH 02/20] chore(clippy): apply automated lint fixes --- src/build/wasm_target.rs | 4 ++-- src/command/build.rs | 32 +++----------------------------- src/command/login.rs | 4 ++-- src/command/test.rs | 5 ++--- src/command/utils.rs | 4 ++-- src/generate.rs | 4 ++-- src/install/mod.rs | 2 +- src/install/mode.rs | 7 ++----- src/installer.rs | 1 - src/license.rs | 4 ++-- src/main.rs | 2 +- src/manifest/mod.rs | 20 ++++++++++---------- src/npm.rs | 2 +- src/readme.rs | 4 ++-- 14 files changed, 32 insertions(+), 63 deletions(-) diff --git a/src/build/wasm_target.rs b/src/build/wasm_target.rs index 51380bc6b..175a7cf78 100644 --- a/src/build/wasm_target.rs +++ b/src/build/wasm_target.rs @@ -68,7 +68,7 @@ pub fn check_for_wasm32_target() -> Result<()> { /// Get rustc's sysroot as a PathBuf fn get_rustc_sysroot() -> Result { let command = Command::new("rustc") - .args(&["--print", "sysroot"]) + .args(["--print", "sysroot"]) .output()?; if command.status.success() { @@ -84,7 +84,7 @@ fn get_rustc_sysroot() -> Result { /// Get wasm32-unknown-unknown target libdir fn get_rustc_wasm32_unknown_unknown_target_libdir() -> Result { let command = Command::new("rustc") - .args(&[ + .args([ "--target", "wasm32-unknown-unknown", "--print", diff --git a/src/command/build.rs b/src/command/build.rs index 3f05a4406..ece49db7f 100644 --- a/src/command/build.rs +++ b/src/command/build.rs @@ -47,9 +47,11 @@ pub struct Build { /// What sort of output we're going to be generating and flags we're invoking /// `wasm-bindgen` with. #[derive(Clone, Copy, Debug)] +#[derive(Default)] pub enum Target { /// Default output mode or `--target bundler`, indicates output will be /// used with a bundle in a later step. + #[default] Bundler, /// Correspond to `--target web` where the output is natively usable as an /// ES module in a browser and the wasm is manually instantiated. @@ -66,11 +68,6 @@ pub enum Target { Deno, } -impl Default for Target { - fn default() -> Target { - Target::Bundler - } -} impl fmt::Display for Target { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -116,6 +113,7 @@ pub enum BuildProfile { /// Everything required to configure and run the `wasm-pack build` command. #[derive(Debug, Args)] #[command(allow_hyphen_values = true, trailing_var_arg = true)] +#[derive(Default)] pub struct BuildOptions { /// The path to the Rust crate. If not set, searches up the path from the current directory. #[clap()] @@ -191,30 +189,6 @@ pub struct BuildOptions { pub extra_options: Vec, } -impl Default for BuildOptions { - fn default() -> Self { - Self { - path: None, - scope: None, - mode: InstallMode::default(), - disable_dts: false, - weak_refs: false, - reference_types: false, - target: Target::default(), - debug: false, - dev: false, - no_pack: false, - no_opt: false, - release: false, - profiling: false, - profile: None, - out_dir: String::new(), - out_name: None, - wbg_arg: Vec::new(), - extra_options: Vec::new(), - } - } -} type BuildStep = fn(&mut Build) -> Result<()>; diff --git a/src/command/login.rs b/src/command/login.rs index 07af70c3d..e1cfe4abc 100644 --- a/src/command/login.rs +++ b/src/command/login.rs @@ -16,9 +16,9 @@ pub fn login( &scope, ®istry, &auth_type ); info!("npm info located in the npm debug log"); - npm::npm_login(®istry, &scope, &auth_type)?; + npm::npm_login(®istry, scope, auth_type)?; info!("Logged you in!"); - PBAR.info(&"👋 logged you in!".to_string()); + PBAR.info("👋 logged you in!"); Ok(()) } diff --git a/src/command/test.rs b/src/command/test.rs index 74a884481..05739be41 100644 --- a/src/command/test.rs +++ b/src/command/test.rs @@ -120,8 +120,7 @@ impl Test { mut path_and_extra_options, } = test_opts; - let first_arg_is_path = path_and_extra_options - .get(0) + let first_arg_is_path = path_and_extra_options.first() .map(|first_arg| !first_arg.starts_with("-")) .unwrap_or(false); @@ -295,7 +294,7 @@ impl Test { let status = install::download_prebuilt_or_cargo_install( Tool::WasmBindgen, &self.cache, - &bindgen_version, + bindgen_version, self.mode.install_permitted(), )?; diff --git a/src/command/utils.rs b/src/command/utils.rs index 509bc5301..bff93c4b6 100644 --- a/src/command/utils.rs +++ b/src/command/utils.rs @@ -38,7 +38,7 @@ fn find_manifest_from_cwd() -> Result { /// Construct our `pkg` directory in the crate. pub fn create_pkg_dir(out_dir: &Path) -> Result<()> { let _ = fs::remove_file(out_dir.join("package.json")); // Clean up package.json from previous runs - fs::create_dir_all(&out_dir)?; + fs::create_dir_all(out_dir)?; fs::write(out_dir.join(".gitignore"), "*")?; Ok(()) } @@ -53,7 +53,7 @@ pub fn find_pkg_directory(path: &Path, pkg_directory: &Path) -> Option WalkDir::new(path) .into_iter() .filter_map(|x| x.ok().map(|e| e.into_path())) - .find(|x| is_pkg_directory(&x, pkg_directory)) + .find(|x| is_pkg_directory(x, pkg_directory)) } fn is_pkg_directory(path: &Path, pkg_directory: &Path) -> bool { diff --git a/src/generate.rs b/src/generate.rs index 660f123bd..2f3608883 100644 --- a/src/generate.rs +++ b/src/generate.rs @@ -13,8 +13,8 @@ pub fn generate(template: &str, name: &str, install_status: &install::Status) -> .binary(&Tool::CargoGenerate.to_string())?; let mut cmd = Command::new(&bin_path); cmd.arg("generate"); - cmd.arg("--git").arg(&template); - cmd.arg("--name").arg(&name); + cmd.arg("--git").arg(template); + cmd.arg("--name").arg(name); println!( "{} Generating a new rustwasm project with name '{}'...", diff --git a/src/install/mod.rs b/src/install/mod.rs index b1eedfa2c..3b560c2e2 100644 --- a/src/install/mod.rs +++ b/src/install/mod.rs @@ -110,7 +110,7 @@ pub fn get_cli_version(tool: &Tool, path: &Path) -> Result { let mut cmd = Command::new(path); cmd.arg("--version"); let stdout = child::run_capture_stdout(cmd, tool)?; - let version = stdout.trim().split_whitespace().nth(1); + let version = stdout.split_whitespace().nth(1); match version { Some(v) => Ok(v.to_string()), None => bail!("Something went wrong! We couldn't determine your version of the wasm-bindgen CLI. We were supposed to set that up for you, so it's likely not your fault! You should file an issue: https://github.com/drager/wasm-pack/issues/new?template=bug_report.md.") diff --git a/src/install/mode.rs b/src/install/mode.rs index a55153def..d265051f2 100644 --- a/src/install/mode.rs +++ b/src/install/mode.rs @@ -4,8 +4,10 @@ use std::str::FromStr; /// The `InstallMode` determines which mode of initialization we are running, and /// what install steps we perform. #[derive(Clone, Copy, Debug)] +#[derive(Default)] pub enum InstallMode { /// Perform all the install steps. + #[default] Normal, /// Don't install tools like `wasm-bindgen`, just use the global /// environment's existing versions to do builds. @@ -14,11 +16,6 @@ pub enum InstallMode { Force, } -impl Default for InstallMode { - fn default() -> InstallMode { - InstallMode::Normal - } -} impl FromStr for InstallMode { type Err = Error; diff --git a/src/installer.rs b/src/installer.rs index 06cbafff1..7cfc5be04 100644 --- a/src/installer.rs +++ b/src/installer.rs @@ -24,7 +24,6 @@ use std::path::Path; use std::process; use anyhow::{anyhow, bail, Context, Result}; -use which; pub fn install() -> ! { if let Err(e) = do_install() { diff --git a/src/license.rs b/src/license.rs index 5305e41e3..94593108b 100644 --- a/src/license.rs +++ b/src/license.rs @@ -39,12 +39,12 @@ fn glob_license_files(path: &Path) -> Result> { /// Copy the crate's license into the `pkg` directory. pub fn copy_from_crate(crate_data: &CrateData, path: &Path, out_dir: &Path) -> Result<()> { assert!( - fs::metadata(path).ok().map_or(false, |m| m.is_dir()), + fs::metadata(path).ok().is_some_and(|m| m.is_dir()), "crate directory should exist" ); assert!( - fs::metadata(&out_dir).ok().map_or(false, |m| m.is_dir()), + fs::metadata(out_dir).ok().is_some_and(|m| m.is_dir()), "crate's pkg directory should exist" ); diff --git a/src/main.rs b/src/main.rs index 46555f2bb..bcfd5ccc3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -61,7 +61,7 @@ fn run() -> Result<()> { let wasm_pack_version = background_check_for_updates(); // Deprecate `init` - if let Some("init") = env::args().nth(1).as_ref().map(|arg| arg.as_str()) { + if let Some("init") = env::args().nth(1).as_deref() { println!("wasm-pack init is deprecated, consider using wasm-pack build"); } diff --git a/src/manifest/mod.rs b/src/manifest/mod.rs index a326693a9..9ad53bc4f 100644 --- a/src/manifest/mod.rs +++ b/src/manifest/mod.rs @@ -152,7 +152,7 @@ impl Crate { match old_metadata_file { Some(ref file_contents) => { - let last_updated = Self::return_stamp_file_value(&file_contents, "created") + let last_updated = Self::return_stamp_file_value(file_contents, "created") .and_then(|t| DateTime::parse_from_str(t.as_str(), "%+").ok()); last_updated @@ -160,7 +160,7 @@ impl Crate { if current_time.signed_duration_since(last_updated).num_hours() > 24 { Self::return_api_call_result(current_time).map(Some) } else { - Ok(Self::return_stamp_file_value(&file_contents, "version")) + Ok(Self::return_stamp_file_value(file_contents, "version")) } }) .unwrap_or_else(|| Ok(None)) @@ -177,7 +177,7 @@ impl Crate { // "policy" as the success. This means that the 24 hours rate limiting // will be active regardless if the check succeeded or failed. match version { - Ok(ref version) => Self::override_stamp_file(current_time, Some(&version)).ok(), + Ok(ref version) => Self::override_stamp_file(current_time, Some(version)).ok(), Err(_) => Self::override_stamp_file(current_time, None).ok(), }; @@ -192,7 +192,7 @@ impl Crate { let mut file = fs::OpenOptions::new() .read(true) - .write(true) + .append(true) .create(true) .open(path.with_extension("stamp"))?; @@ -240,7 +240,7 @@ impl Crate { .try_proxy_from_env(true) .user_agent(&format!( "wasm-pack/{} ({})", - WASM_PACK_VERSION.unwrap_or_else(|| "unknown"), + WASM_PACK_VERSION.unwrap_or("unknown"), WASM_PACK_REPO_URL )) .build(); @@ -251,7 +251,7 @@ impl Crate { let status_code = resp.status(); - if 200 <= status_code && status_code < 300 { + if (200..300).contains(&status_code) { let json = resp.into_json()?; Ok(json) @@ -473,8 +473,8 @@ impl CrateData { } fn is_same_path(path1: &Path, path2: &Path) -> bool { - if let Ok(path1) = fs::canonicalize(&path1) { - if let Ok(path2) = fs::canonicalize(&path2) { + if let Ok(path1) = fs::canonicalize(path1) { + if let Ok(path2) = fs::canonicalize(path2) { return path1 == path2; } } @@ -489,7 +489,7 @@ impl CrateData { /// Will return Err if the file (manifest_path) couldn't be read or /// if deserialize to `CargoManifest` fails. pub fn parse_crate_data(manifest_path: &Path) -> Result { - let manifest = fs::read_to_string(&manifest_path) + let manifest = fs::read_to_string(manifest_path) .with_context(|| anyhow!("failed to read: {}", manifest_path.display()))?; let manifest = toml::Deserializer::new(&manifest); @@ -683,7 +683,7 @@ impl CrateData { None }; - let keywords = if pkg.keywords.len() > 0 { + let keywords = if !pkg.keywords.is_empty() { Some(pkg.keywords.clone()) } else { None diff --git a/src/npm.rs b/src/npm.rs index 9cdadaa6f..6fc3cd6d8 100644 --- a/src/npm.rs +++ b/src/npm.rs @@ -20,7 +20,7 @@ pub fn npm_pack(path: &str) -> Result<()> { pub fn npm_publish(path: &str, access: Option, tag: Option) -> Result<()> { let mut cmd = child::new_command("npm"); match access { - Some(a) => cmd.current_dir(path).arg("publish").arg(&a.to_string()), + Some(a) => cmd.current_dir(path).arg("publish").arg(a.to_string()), None => cmd.current_dir(path).arg("publish"), }; if let Some(tag) = tag { diff --git a/src/readme.rs b/src/readme.rs index d82f5b3f4..2f88eed0d 100644 --- a/src/readme.rs +++ b/src/readme.rs @@ -10,11 +10,11 @@ use crate::PBAR; /// Copy the crate's README into the `pkg` directory. pub fn copy_from_crate(crate_data: &CrateData, path: &Path, out_dir: &Path) -> Result<()> { assert!( - fs::metadata(path).ok().map_or(false, |m| m.is_dir()), + fs::metadata(path).ok().is_some_and(|m| m.is_dir()), "crate directory should exist" ); assert!( - fs::metadata(&out_dir).ok().map_or(false, |m| m.is_dir()), + fs::metadata(out_dir).ok().is_some_and(|m| m.is_dir()), "crate's pkg directory should exist" ); From 83b056ef6426e3e8fec6b19a9ca7ad29f8bb6038 Mon Sep 17 00:00:00 2001 From: Rafael Beckel Date: Wed, 12 Nov 2025 05:51:17 +0100 Subject: [PATCH 03/20] test: stabilize CI - Quiet test: suppress unexpected_cfg warnings via RUSTFLAGS - Generate/new tests: default template now rustwasm/wasm-pack-template to avoid auth issues --- src/command/mod.rs | 2 +- tests/all/log_level.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/command/mod.rs b/src/command/mod.rs index ebc08c97b..979ed797e 100644 --- a/src/command/mod.rs +++ b/src/command/mod.rs @@ -48,7 +48,7 @@ pub enum Command { /// The URL to the template #[clap( long = "template", - default_value = "https://github.com/drager/wasm-pack-template" + default_value = "https://github.com/rustwasm/wasm-pack-template" )] template: String, #[clap(long = "mode", short = 'm', default_value = "normal")] diff --git a/tests/all/log_level.rs b/tests/all/log_level.rs index a283a3170..0a6431d8a 100644 --- a/tests/all/log_level.rs +++ b/tests/all/log_level.rs @@ -27,6 +27,7 @@ fn quiet() { .cargo_toml("js-hello-world") .hello_world_src_lib() .wasm_pack() + .env("RUSTFLAGS", "-Aunexpected_cfgs") .arg("--quiet") .arg("build") .assert() From bdfb6c9d91634e501c26c7ab5d5a7764c9a096a4 Mon Sep 17 00:00:00 2001 From: Rafael Beckel Date: Wed, 12 Nov 2025 05:58:46 +0100 Subject: [PATCH 04/20] Revert "test: stabilize CI" This reverts commit 83b056ef6426e3e8fec6b19a9ca7ad29f8bb6038. --- src/command/mod.rs | 2 +- tests/all/log_level.rs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/command/mod.rs b/src/command/mod.rs index 979ed797e..ebc08c97b 100644 --- a/src/command/mod.rs +++ b/src/command/mod.rs @@ -48,7 +48,7 @@ pub enum Command { /// The URL to the template #[clap( long = "template", - default_value = "https://github.com/rustwasm/wasm-pack-template" + default_value = "https://github.com/drager/wasm-pack-template" )] template: String, #[clap(long = "mode", short = 'm', default_value = "normal")] diff --git a/tests/all/log_level.rs b/tests/all/log_level.rs index 0a6431d8a..a283a3170 100644 --- a/tests/all/log_level.rs +++ b/tests/all/log_level.rs @@ -27,7 +27,6 @@ fn quiet() { .cargo_toml("js-hello-world") .hello_world_src_lib() .wasm_pack() - .env("RUSTFLAGS", "-Aunexpected_cfgs") .arg("--quiet") .arg("build") .assert() From 1ba38d1a3cc9169e5c7c34d3bba7bb84baa503cf Mon Sep 17 00:00:00 2001 From: Rafael Beckel Date: Sat, 15 Nov 2025 01:15:02 +0100 Subject: [PATCH 05/20] Update src/build/wasm_target.rs --- src/build/wasm_target.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/build/wasm_target.rs b/src/build/wasm_target.rs index 175a7cf78..a46d0ddc7 100644 --- a/src/build/wasm_target.rs +++ b/src/build/wasm_target.rs @@ -68,7 +68,7 @@ pub fn check_for_wasm32_target() -> Result<()> { /// Get rustc's sysroot as a PathBuf fn get_rustc_sysroot() -> Result { let command = Command::new("rustc") - .args(["--print", "sysroot"]) + .args(&["--print", "sysroot"]) .output()?; if command.status.success() { From 9c05b8b8f84b1161fd733ed0c865fb8daaf562ad Mon Sep 17 00:00:00 2001 From: Rafael Beckel Date: Sat, 15 Nov 2025 01:15:21 +0100 Subject: [PATCH 06/20] Update src/build/wasm_target.rs --- src/build/wasm_target.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/build/wasm_target.rs b/src/build/wasm_target.rs index a46d0ddc7..51380bc6b 100644 --- a/src/build/wasm_target.rs +++ b/src/build/wasm_target.rs @@ -84,7 +84,7 @@ fn get_rustc_sysroot() -> Result { /// Get wasm32-unknown-unknown target libdir fn get_rustc_wasm32_unknown_unknown_target_libdir() -> Result { let command = Command::new("rustc") - .args([ + .args(&[ "--target", "wasm32-unknown-unknown", "--print", From 724a8034b843a9b7d9117cd492b8e065230715d1 Mon Sep 17 00:00:00 2001 From: Rafael Beckel Date: Sat, 15 Nov 2025 01:16:56 +0100 Subject: [PATCH 07/20] Update src/command/build.rs --- src/command/build.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/command/build.rs b/src/command/build.rs index ece49db7f..fbe453479 100644 --- a/src/command/build.rs +++ b/src/command/build.rs @@ -46,8 +46,7 @@ pub struct Build { /// What sort of output we're going to be generating and flags we're invoking /// `wasm-bindgen` with. -#[derive(Clone, Copy, Debug)] -#[derive(Default)] +#[derive(Clone, Copy, Debug, Default)] pub enum Target { /// Default output mode or `--target bundler`, indicates output will be /// used with a bundle in a later step. From 8b11425bcbf40e62caa245c11a361c2e20eefb9c Mon Sep 17 00:00:00 2001 From: Rafael Beckel Date: Sat, 15 Nov 2025 01:17:39 +0100 Subject: [PATCH 08/20] Update src/command/build.rs --- src/command/build.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/command/build.rs b/src/command/build.rs index fbe453479..cdafdf94a 100644 --- a/src/command/build.rs +++ b/src/command/build.rs @@ -67,7 +67,6 @@ pub enum Target { Deno, } - impl fmt::Display for Target { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let s = match self { From 47760bba85acd7c1586ff7133b68596a51a9c105 Mon Sep 17 00:00:00 2001 From: Rafael Beckel Date: Sat, 15 Nov 2025 01:18:54 +0100 Subject: [PATCH 09/20] Update src/command/build.rs --- src/command/build.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/command/build.rs b/src/command/build.rs index cdafdf94a..44065ed7b 100644 --- a/src/command/build.rs +++ b/src/command/build.rs @@ -109,9 +109,8 @@ pub enum BuildProfile { } /// Everything required to configure and run the `wasm-pack build` command. -#[derive(Debug, Args)] +#[derive(Debug, Args, Default)] #[command(allow_hyphen_values = true, trailing_var_arg = true)] -#[derive(Default)] pub struct BuildOptions { /// The path to the Rust crate. If not set, searches up the path from the current directory. #[clap()] From 13c942195db368f4707a6fd5ce3bd1c2889f725f Mon Sep 17 00:00:00 2001 From: Rafael Beckel Date: Sat, 15 Nov 2025 01:19:08 +0100 Subject: [PATCH 10/20] Update src/command/build.rs --- src/command/build.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/command/build.rs b/src/command/build.rs index 44065ed7b..f96b675aa 100644 --- a/src/command/build.rs +++ b/src/command/build.rs @@ -186,7 +186,6 @@ pub struct BuildOptions { pub extra_options: Vec, } - type BuildStep = fn(&mut Build) -> Result<()>; impl Build { From b27537e98cc0ca9e8b0bbe793cf361923e0b2bf9 Mon Sep 17 00:00:00 2001 From: Rafael Beckel Date: Sat, 15 Nov 2025 01:20:34 +0100 Subject: [PATCH 11/20] Update src/command/login.rs --- src/command/login.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/command/login.rs b/src/command/login.rs index e1cfe4abc..6d9050e8f 100644 --- a/src/command/login.rs +++ b/src/command/login.rs @@ -16,7 +16,7 @@ pub fn login( &scope, ®istry, &auth_type ); info!("npm info located in the npm debug log"); - npm::npm_login(®istry, scope, auth_type)?; + npm::npm_login(®istry, &scope, &auth_type)?; info!("Logged you in!"); PBAR.info("👋 logged you in!"); From d8b9f7b9b2cf5722e40ecdcfa794d2ed914d0110 Mon Sep 17 00:00:00 2001 From: Rafael Beckel Date: Sat, 15 Nov 2025 01:20:53 +0100 Subject: [PATCH 12/20] Update src/command/utils.rs --- src/command/utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/command/utils.rs b/src/command/utils.rs index bff93c4b6..921b69267 100644 --- a/src/command/utils.rs +++ b/src/command/utils.rs @@ -38,7 +38,7 @@ fn find_manifest_from_cwd() -> Result { /// Construct our `pkg` directory in the crate. pub fn create_pkg_dir(out_dir: &Path) -> Result<()> { let _ = fs::remove_file(out_dir.join("package.json")); // Clean up package.json from previous runs - fs::create_dir_all(out_dir)?; + fs::create_dir_all(&out_dir)?; fs::write(out_dir.join(".gitignore"), "*")?; Ok(()) } From f78b0eb9f5e16f5f6f74878f445832acd80b4f5a Mon Sep 17 00:00:00 2001 From: Rafael Beckel Date: Sat, 15 Nov 2025 01:23:08 +0100 Subject: [PATCH 13/20] Update src/readme.rs --- src/readme.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/readme.rs b/src/readme.rs index 2f88eed0d..070860833 100644 --- a/src/readme.rs +++ b/src/readme.rs @@ -10,7 +10,7 @@ use crate::PBAR; /// Copy the crate's README into the `pkg` directory. pub fn copy_from_crate(crate_data: &CrateData, path: &Path, out_dir: &Path) -> Result<()> { assert!( - fs::metadata(path).ok().is_some_and(|m| m.is_dir()), + fs::metadata(path).ok().map_or(false, |m| m.is_dir()), "crate directory should exist" ); assert!( From 307983a1c29793439d27c15cf37d987cbca2b3fa Mon Sep 17 00:00:00 2001 From: Rafael Beckel Date: Sat, 15 Nov 2025 01:23:44 +0100 Subject: [PATCH 14/20] Update src/readme.rs --- src/readme.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/readme.rs b/src/readme.rs index 070860833..7bcc75b02 100644 --- a/src/readme.rs +++ b/src/readme.rs @@ -14,7 +14,7 @@ pub fn copy_from_crate(crate_data: &CrateData, path: &Path, out_dir: &Path) -> R "crate directory should exist" ); assert!( - fs::metadata(out_dir).ok().is_some_and(|m| m.is_dir()), + fs::metadata(out_dir).ok().map_or(false, |m| m.is_dir()), "crate's pkg directory should exist" ); From 35eca63606c159db4effd5feef61e23b8f1ef0ee Mon Sep 17 00:00:00 2001 From: Rafael Beckel Date: Sat, 15 Nov 2025 01:24:10 +0100 Subject: [PATCH 15/20] Update src/readme.rs --- src/readme.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/readme.rs b/src/readme.rs index 7bcc75b02..d82f5b3f4 100644 --- a/src/readme.rs +++ b/src/readme.rs @@ -14,7 +14,7 @@ pub fn copy_from_crate(crate_data: &CrateData, path: &Path, out_dir: &Path) -> R "crate directory should exist" ); assert!( - fs::metadata(out_dir).ok().map_or(false, |m| m.is_dir()), + fs::metadata(&out_dir).ok().map_or(false, |m| m.is_dir()), "crate's pkg directory should exist" ); From ca1ca9051be355ced51ec3ef4bdb012ae0fd18fe Mon Sep 17 00:00:00 2001 From: Rafael Beckel Date: Sat, 15 Nov 2025 01:24:37 +0100 Subject: [PATCH 16/20] Update src/npm.rs --- src/npm.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/npm.rs b/src/npm.rs index 6fc3cd6d8..9cdadaa6f 100644 --- a/src/npm.rs +++ b/src/npm.rs @@ -20,7 +20,7 @@ pub fn npm_pack(path: &str) -> Result<()> { pub fn npm_publish(path: &str, access: Option, tag: Option) -> Result<()> { let mut cmd = child::new_command("npm"); match access { - Some(a) => cmd.current_dir(path).arg("publish").arg(a.to_string()), + Some(a) => cmd.current_dir(path).arg("publish").arg(&a.to_string()), None => cmd.current_dir(path).arg("publish"), }; if let Some(tag) = tag { From 981b5190f7ff0852ed1d3d60fc40a5f20c023bcb Mon Sep 17 00:00:00 2001 From: Rafael Beckel Date: Sat, 15 Nov 2025 01:26:03 +0100 Subject: [PATCH 17/20] Update src/command/login.rs --- src/command/login.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/command/login.rs b/src/command/login.rs index 6d9050e8f..07af70c3d 100644 --- a/src/command/login.rs +++ b/src/command/login.rs @@ -19,6 +19,6 @@ pub fn login( npm::npm_login(®istry, &scope, &auth_type)?; info!("Logged you in!"); - PBAR.info("👋 logged you in!"); + PBAR.info(&"👋 logged you in!".to_string()); Ok(()) } From 8dfb2ea123b287540dbddd91777c3dd85c78e42d Mon Sep 17 00:00:00 2001 From: Rafael Beckel Date: Sat, 15 Nov 2025 01:26:31 +0100 Subject: [PATCH 18/20] Update src/manifest/mod.rs --- src/manifest/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/manifest/mod.rs b/src/manifest/mod.rs index 9ad53bc4f..5b9bde098 100644 --- a/src/manifest/mod.rs +++ b/src/manifest/mod.rs @@ -489,7 +489,7 @@ impl CrateData { /// Will return Err if the file (manifest_path) couldn't be read or /// if deserialize to `CargoManifest` fails. pub fn parse_crate_data(manifest_path: &Path) -> Result { - let manifest = fs::read_to_string(manifest_path) + let manifest = fs::read_to_string(&manifest_path) .with_context(|| anyhow!("failed to read: {}", manifest_path.display()))?; let manifest = toml::Deserializer::new(&manifest); From 29a1b4269a0def8eb122019ee952512b06d38ed5 Mon Sep 17 00:00:00 2001 From: Rafael Beckel Date: Sat, 15 Nov 2025 01:26:57 +0100 Subject: [PATCH 19/20] Update src/manifest/mod.rs --- src/manifest/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/manifest/mod.rs b/src/manifest/mod.rs index 5b9bde098..836dac6f0 100644 --- a/src/manifest/mod.rs +++ b/src/manifest/mod.rs @@ -473,8 +473,8 @@ impl CrateData { } fn is_same_path(path1: &Path, path2: &Path) -> bool { - if let Ok(path1) = fs::canonicalize(path1) { - if let Ok(path2) = fs::canonicalize(path2) { + if let Ok(path1) = fs::canonicalize(&path1) { + if let Ok(path2) = fs::canonicalize(&path2) { return path1 == path2; } } From c5701b308fea88d082b56fee3cc28b204d81fed9 Mon Sep 17 00:00:00 2001 From: Rafael Beckel Date: Sat, 15 Nov 2025 01:27:33 +0100 Subject: [PATCH 20/20] Update src/manifest/mod.rs --- src/manifest/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/manifest/mod.rs b/src/manifest/mod.rs index 836dac6f0..8bbaf8547 100644 --- a/src/manifest/mod.rs +++ b/src/manifest/mod.rs @@ -683,7 +683,7 @@ impl CrateData { None }; - let keywords = if !pkg.keywords.is_empty() { + let keywords = if pkg.keywords.len() > 0 { Some(pkg.keywords.clone()) } else { None