Skip to content

correctly parse package.json to determine existing dependencies #1483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/manifest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,10 +628,13 @@ impl CrateData {
// Check if a `package.json` was already generated by wasm-bindgen, if so
// we merge the NPM dependencies already specified in it.
let existing_deps = if pkg_file_path.exists() {
// It's just a map of dependency names to versions
Some(serde_json::from_str::<HashMap<String, String>>(
&fs::read_to_string(&pkg_file_path)?,
)?)
#[derive(Deserialize)]
struct HasDependencies {
dependencies: HashMap<String, String>,
}
let package =
serde_json::from_str::<HasDependencies>(&fs::read_to_string(&pkg_file_path)?)?;
Some(package.dependencies)
} else {
None
};
Expand Down
Loading