Skip to content
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

Include *_bg.js wasm-bindgen outputs in package.json #200

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ impl CargoManifest {
let wasm_file = format!("{}_bg.wasm", filename);
let js_bg_file = format!("{}_bg.js", filename);
let js_file = format!("{}.js", filename);

let dts_file = if disable_dts == true {
None
} else {
Expand Down
35 changes: 31 additions & 4 deletions tests/manifest/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ extern crate wasm_pack;

mod utils;

use std::collections::HashSet;
use std::fs;

use wasm_pack::manifest;
Expand Down Expand Up @@ -59,13 +60,17 @@ fn it_creates_a_package_json_default_path() {
pkg.repository.url,
"https://github.com/ashleygwilliams/wasm-pack.git"
);
assert_eq!(
pkg.files,
["wasm_pack_bg.wasm", "wasm_pack_bg.js", "wasm_pack.d.ts"]
);
assert_eq!(pkg.main, "wasm_pack.js");
let types = pkg.types.unwrap_or_default();
assert_eq!(types, "wasm_pack.d.ts");

let actual_files: HashSet<String> = pkg.files.into_iter().collect();
let expected_files: HashSet<String> =
["wasm_pack_bg.wasm", "wasm_pack_bg.js", "wasm_pack.d.ts"]
.iter()
.map(|&s| String::from(s))
.collect();
assert_eq!(actual_files, expected_files);
}

#[test]
Expand All @@ -79,6 +84,17 @@ fn it_creates_a_package_json_provided_path() {
assert!(utils::read_package_json(&path).is_ok());
let pkg = utils::read_package_json(&path).unwrap();
assert_eq!(pkg.name, "js-hello-world");
assert_eq!(pkg.main, "js_hello_world.js");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hrm, this seems to assert that the main is not the bg file.... that's not correct right? i might pull this down and just figure out what's happening here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for the confusion around this. i'm honestly baffled about how this bug happened but feels like something i might just need to sort out. thank you so much for all your patience and hard work. i'll pull this down and take it from here so you don't have to worry about it <3<3


let actual_files: HashSet<String> = pkg.files.into_iter().collect();
let expected_files: HashSet<String> = [
"js_hello_world_bg.wasm",
"js_hello_world_bg.js",
"js_hello_world.d.ts",
].iter()
.map(|&s| String::from(s))
.collect();
assert_eq!(actual_files, expected_files);
}

#[test]
Expand All @@ -92,6 +108,17 @@ fn it_creates_a_package_json_provided_path_with_scope() {
assert!(utils::read_package_json(&path).is_ok());
let pkg = utils::read_package_json(&path).unwrap();
assert_eq!(pkg.name, "@test/scopes-hello-world");
assert_eq!(pkg.main, "scopes_hello_world.js");

let actual_files: HashSet<String> = pkg.files.into_iter().collect();
let expected_files: HashSet<String> = [
"scopes_hello_world_bg.wasm",
"scopes_hello_world_bg.js",
"scopes_hello_world.d.ts",
].iter()
.map(|&s| String::from(s))
.collect();
assert_eq!(actual_files, expected_files);
}

#[test]
Expand Down