From ea352922f75b0c7cd420f8192fc8e36ee678dfca Mon Sep 17 00:00:00 2001 From: Samuel Cristobal Date: Sun, 13 Nov 2022 08:07:53 -0500 Subject: [PATCH 1/3] added {name_prefix}_bg.wasm.d.ts to package.json files declaration --- src/manifest/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/manifest/mod.rs b/src/manifest/mod.rs index 6a483523..51447063 100644 --- a/src/manifest/mod.rs +++ b/src/manifest/mod.rs @@ -633,6 +633,14 @@ impl CrateData { None }; + if !disable_dts { + let file = format!("{}_bg.wasm.d.ts", name_prefix); + files.push(file.to_string()); + Some(file) + } else { + None + }; + let keywords = if pkg.keywords.len() > 0 { Some(pkg.keywords.clone()) } else { From 113f47e4da0ffe317eb2c460322e802782dd26d0 Mon Sep 17 00:00:00 2001 From: Samuel Cristobal Date: Mon, 13 Feb 2023 20:31:47 -0700 Subject: [PATCH 2/3] more concise --- src/manifest/mod.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/manifest/mod.rs b/src/manifest/mod.rs index 51447063..07de2310 100644 --- a/src/manifest/mod.rs +++ b/src/manifest/mod.rs @@ -628,14 +628,10 @@ impl CrateData { let dts_file = if !disable_dts { let file = format!("{}.d.ts", name_prefix); files.push(file.to_string()); - Some(file) - } else { - None - }; - if !disable_dts { - let file = format!("{}_bg.wasm.d.ts", name_prefix); - files.push(file.to_string()); + let wasm_def_file = format!("{}_bg.wasm.d.ts", name_prefix); + files.push(wasm_def_file); + Some(file) } else { None From 173e7573530e4d570b61b494c7cf1047e62a6e43 Mon Sep 17 00:00:00 2001 From: Samuel Cristobal Date: Tue, 14 Feb 2023 22:10:10 -0700 Subject: [PATCH 3/3] fix manifest tests to include _bg.wasm.d.ts file --- tests/all/manifest.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/all/manifest.rs b/tests/all/manifest.rs index 48d17df0..865fdaa4 100644 --- a/tests/all/manifest.rs +++ b/tests/all/manifest.rs @@ -98,6 +98,7 @@ fn it_creates_a_package_json_default_path() { let actual_files: HashSet = pkg.files.into_iter().collect(); let expected_files: HashSet = [ "js_hello_world.d.ts", + "js_hello_world_bg.wasm.d.ts", "js_hello_world_bg.js", "js_hello_world_bg.wasm", "js_hello_world.js", @@ -127,6 +128,7 @@ fn it_creates_a_package_json_provided_path() { let actual_files: HashSet = pkg.files.into_iter().collect(); let expected_files: HashSet = [ "js_hello_world.d.ts", + "js_hello_world_bg.wasm.d.ts", "js_hello_world_bg.js", "js_hello_world_bg.wasm", "js_hello_world.js", @@ -156,6 +158,7 @@ fn it_creates_a_package_json_provided_path_with_scope() { let actual_files: HashSet = pkg.files.into_iter().collect(); let expected_files: HashSet = [ "js_hello_world.d.ts", + "js_hello_world_bg.wasm.d.ts", "js_hello_world_bg.js", "js_hello_world_bg.wasm", "js_hello_world.js", @@ -191,6 +194,7 @@ fn it_creates_a_pkg_json_with_correct_files_on_node() { let actual_files: HashSet = pkg.files.into_iter().collect(); let expected_files: HashSet = [ "js_hello_world_bg.wasm", + "js_hello_world_bg.wasm.d.ts", "js_hello_world.d.ts", "js_hello_world.js", ] @@ -225,6 +229,7 @@ fn it_creates_a_pkg_json_with_correct_files_on_nomodules() { let actual_files: HashSet = pkg.files.into_iter().collect(); let expected_files: HashSet = [ "js_hello_world.d.ts", + "js_hello_world_bg.wasm.d.ts", "js_hello_world_bg.wasm", "js_hello_world.js", ] @@ -258,11 +263,16 @@ fn it_creates_a_package_json_with_correct_files_when_out_name_is_provided() { assert_eq!(pkg.side_effects, false); let actual_files: HashSet = pkg.files.into_iter().collect(); - let expected_files: HashSet = - ["index_bg.wasm", "index_bg.js", "index.d.ts", "index.js"] - .iter() - .map(|&s| String::from(s)) - .collect(); + let expected_files: HashSet = [ + "index_bg.wasm", + "index_bg.wasm.d.ts", + "index_bg.js", + "index.d.ts", + "index.js", + ] + .iter() + .map(|&s| String::from(s)) + .collect(); assert_eq!(actual_files, expected_files); }