Skip to content

Commit 7da29b2

Browse files
fix(bindgen): don't rename to index
1 parent c779c74 commit 7da29b2

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

src/bindgen.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use console::style;
22
use emoji;
33
use failure::Error;
4-
use std::fs;
54
use std::process::Command;
65
use PBAR;
76

@@ -51,9 +50,6 @@ pub fn wasm_bindgen_build(path: &str, name: &str) -> Result<(), Error> {
5150
PBAR.error("wasm-bindgen failed to execute properly");
5251
bail!(format!("Details:\n{}", s));
5352
} else {
54-
let js_file = format!("{}/pkg/{}.js", path, binary_name);
55-
let index_file = format!("{}/pkg/index.js", path);
56-
fs::rename(&js_file, &index_file)?;
5753
Ok(())
5854
}
5955
}

src/manifest.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ impl CargoManifest {
5555
fn into_npm(mut self, scope: Option<String>) -> NpmPackage {
5656
let filename = self.package.name.replace("-", "_");
5757
let wasm_file = format!("{}_bg.wasm", filename);
58+
let js_file = format!("{}.js", filename);
5859
if let Some(s) = scope {
5960
self.package.name = format!("@{}/{}", s, self.package.name);
6061
}
@@ -69,7 +70,7 @@ impl CargoManifest {
6970
url: repo_url,
7071
}),
7172
files: vec![wasm_file],
72-
main: "index.js".to_string(),
73+
main: js_file,
7374
}
7475
}
7576
}

tests/manifest/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fn it_creates_a_package_json_default_path() {
4141
"https://github.com/ashleygwilliams/wasm-pack.git"
4242
);
4343
assert_eq!(pkg.files, ["wasm_pack_bg.wasm"]);
44-
assert_eq!(pkg.main, "index.js");
44+
assert_eq!(pkg.main, "wasm_pack.js");
4545
}
4646

4747
#[test]

0 commit comments

Comments
 (0)