Skip to content

fix(worker-build): read the dependencies map from wasm-bindgen's package.json - #1096

Open
PedroRosalba wants to merge 1 commit into
cloudflare:mainfrom
PedroRosalba:fix/worker-build-package-json
Open

PedroRosalba wants to merge 1 commit into
cloudflare:mainfrom
PedroRosalba:fix/worker-build-package-json

Conversation

@PedroRosalba

Copy link
Copy Markdown

Problem

write_package_json parses the package.json that wasm-bindgen leaves in the output directory as a flat HashMap<String, String>. Since wasm-bindgen 0.2.94 (wasm-bindgen/wasm-bindgen#4091) that file is a real manifest, {"dependencies": {...}}, so any crate whose JS snippet imports an NPM package fails worker-build with invalid type: map, expected a string.

wasm-pack hit the same change (wasm-bindgen/wasm-pack#1420); this is the equivalent fix for worker-build.

Fix

Deserialize the dependencies object and ignore the other fields. Crates without snippet dependencies are unaffected.

Tests

Unit tests in manifest.rs for the new shape, the old flat shape, and a manifest without dependencies.

Tested on macOS (Apple Silicon) only.

Fixes #1087

…age.json

`write_package_json` parsed the `package.json` that wasm-bindgen leaves in
the output directory as a flat `HashMap<String, String>`. Since wasm-bindgen
0.2.94 (wasm-bindgen/wasm-bindgen#4091) that file is a real manifest,
`{"dependencies": {...}}`, so any crate whose JS snippet pulls in an NPM
package failed with `invalid type: map, expected a string`. Deserialize the
`dependencies` object instead and ignore the other fields.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] worker-build fails when the crate's package.json has dependencies (invalid type: map, expected a string)

1 participant