Skip to content

Commit

Permalink
Merge branch 'master' into options-passthrough
Browse files Browse the repository at this point in the history
  • Loading branch information
Pauan authored May 5, 2020
2 parents 645f43e + 2d0af80 commit d147426
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
8 changes: 4 additions & 4 deletions src/manifest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ impl CrateData {
fn npm_data(
&self,
scope: &Option<String>,
include_commonjs_shim: bool,
add_js_bg_to_package_json: bool,
disable_dts: bool,
out_dir: &Path,
) -> NpmData {
Expand All @@ -589,7 +589,7 @@ impl CrateData {
let mut files = vec![wasm_file];

files.push(js_file.clone());
if include_commonjs_shim {
if add_js_bg_to_package_json {
let js_bg_file = format!("{}_bg.js", name_prefix);
files.push(js_bg_file);
}
Expand Down Expand Up @@ -646,7 +646,7 @@ impl CrateData {
}

fn to_commonjs(&self, scope: &Option<String>, disable_dts: bool, out_dir: &Path) -> NpmPackage {
let data = self.npm_data(scope, true, disable_dts, out_dir);
let data = self.npm_data(scope, false, disable_dts, out_dir);
let pkg = &self.data.packages[self.current_idx];

self.check_optional_fields();
Expand Down Expand Up @@ -680,7 +680,7 @@ impl CrateData {
disable_dts: bool,
out_dir: &Path,
) -> NpmPackage {
let data = self.npm_data(scope, false, disable_dts, out_dir);
let data = self.npm_data(scope, true, disable_dts, out_dir);
let pkg = &self.data.packages[self.current_idx];

self.check_optional_fields();
Expand Down
2 changes: 1 addition & 1 deletion tests/all/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ fn build_with_and_without_wasm_bindgen_debug() {
.assert()
.success();

let contents = fs::read_to_string(fixture.path.join("pkg/whatever.js")).unwrap();
let contents = fs::read_to_string(fixture.path.join("pkg/whatever_bg.js")).unwrap();
let contains_move_assertions =
contents.contains("throw new Error('Attempt to use a moved value')");
assert_eq!(
Expand Down
33 changes: 20 additions & 13 deletions tests/all/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ fn it_creates_a_package_json_default_path() {

let actual_files: HashSet<String> = pkg.files.into_iter().collect();
let expected_files: HashSet<String> = [
"js_hello_world_bg.wasm",
"js_hello_world.d.ts",
"js_hello_world_bg.js",
"js_hello_world_bg.wasm",
"js_hello_world.js",
]
.iter()
Expand All @@ -125,8 +126,9 @@ fn it_creates_a_package_json_provided_path() {

let actual_files: HashSet<String> = pkg.files.into_iter().collect();
let expected_files: HashSet<String> = [
"js_hello_world_bg.wasm",
"js_hello_world.d.ts",
"js_hello_world_bg.js",
"js_hello_world_bg.wasm",
"js_hello_world.js",
]
.iter()
Expand All @@ -153,8 +155,9 @@ fn it_creates_a_package_json_provided_path_with_scope() {

let actual_files: HashSet<String> = pkg.files.into_iter().collect();
let expected_files: HashSet<String> = [
"js_hello_world_bg.wasm",
"js_hello_world.d.ts",
"js_hello_world_bg.js",
"js_hello_world_bg.wasm",
"js_hello_world.js",
]
.iter()
Expand Down Expand Up @@ -188,7 +191,6 @@ fn it_creates_a_pkg_json_with_correct_files_on_node() {
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",
"js_hello_world.js",
]
Expand Down Expand Up @@ -222,9 +224,9 @@ fn it_creates_a_pkg_json_with_correct_files_on_nomodules() {

let actual_files: HashSet<String> = pkg.files.into_iter().collect();
let expected_files: HashSet<String> = [
"js_hello_world.d.ts",
"js_hello_world_bg.wasm",
"js_hello_world.js",
"js_hello_world.d.ts",
]
.iter()
.map(|&s| String::from(s))
Expand Down Expand Up @@ -256,10 +258,11 @@ fn it_creates_a_package_json_with_correct_files_when_out_name_is_provided() {
assert_eq!(pkg.side_effects, false);

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

Expand Down Expand Up @@ -300,10 +303,14 @@ fn it_creates_a_package_json_with_correct_keys_when_types_are_skipped() {
assert_eq!(pkg.module, "js_hello_world.js");

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

Expand Down

0 comments on commit d147426

Please sign in to comment.