Skip to content

Commit 125aa23

Browse files
authored
Fix emitted package.json structure (#4091)
1 parent 9d6693a commit 125aa23

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
[#4082](https://github.com/rustwasm/wasm-bindgen/pull/4082)
1919
[#4088](https://github.com/rustwasm/wasm-bindgen/pull/4088)
2020

21+
* Fixed emitted `package.json` structure to correctly specify its dependencies
22+
[#4091](https://github.com/rustwasm/wasm-bindgen/pull/4091)
23+
2124
--------------------------------------------------------------------------------
2225

2326
## [0.2.93](https://github.com/rustwasm/wasm-bindgen/compare/0.2.92...0.2.93)

crates/cli-support/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ anyhow = "1.0"
1818
base64 = "0.22"
1919
log = "0.4"
2020
rustc-demangle = "0.1.13"
21+
serde = { version = "1.0", features = ["derive"] }
2122
serde_json = "1.0"
2223
tempfile = "3.0"
2324
unicode-ident = "1.0.5"

crates/cli-support/src/lib.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -641,12 +641,18 @@ impl Output {
641641
}
642642

643643
if !gen.npm_dependencies.is_empty() {
644-
let map = gen
645-
.npm_dependencies
646-
.iter()
647-
.map(|(k, v)| (k, &v.1))
648-
.collect::<BTreeMap<_, _>>();
649-
let json = serde_json::to_string_pretty(&map)?;
644+
#[derive(serde::Serialize)]
645+
struct PackageJson<'a> {
646+
dependencies: BTreeMap<&'a str, &'a str>,
647+
}
648+
let pj = PackageJson {
649+
dependencies: gen
650+
.npm_dependencies
651+
.iter()
652+
.map(|(k, v)| (k.as_str(), v.1.as_str()))
653+
.collect(),
654+
};
655+
let json = serde_json::to_string_pretty(&pj)?;
650656
fs::write(out_dir.join("package.json"), json)?;
651657
}
652658

0 commit comments

Comments
 (0)