diff --git a/src/bindgen.rs b/src/bindgen.rs index 3b587b1..a640c0e 100644 --- a/src/bindgen.rs +++ b/src/bindgen.rs @@ -1,7 +1,6 @@ use console::style; use emoji; use failure::Error; -use std::fs; use std::process::Command; use PBAR; @@ -51,9 +50,6 @@ pub fn wasm_bindgen_build(path: &str, name: &str) -> Result<(), Error> { PBAR.error("wasm-bindgen failed to execute properly"); bail!(format!("Details:\n{}", s)); } else { - let js_file = format!("{}/pkg/{}.js", path, binary_name); - let index_file = format!("{}/pkg/index.js", path); - fs::rename(&js_file, &index_file)?; Ok(()) } } diff --git a/src/manifest.rs b/src/manifest.rs index 9f60435..9ea770f 100644 --- a/src/manifest.rs +++ b/src/manifest.rs @@ -55,6 +55,7 @@ impl CargoManifest { fn into_npm(mut self, scope: Option<String>) -> NpmPackage { let filename = self.package.name.replace("-", "_"); let wasm_file = format!("{}_bg.wasm", filename); + let js_file = format!("{}.js", filename); if let Some(s) = scope { self.package.name = format!("@{}/{}", s, self.package.name); } @@ -69,7 +70,7 @@ impl CargoManifest { url: repo_url, }), files: vec![wasm_file], - main: "index.js".to_string(), + main: js_file, } } } diff --git a/tests/manifest/main.rs b/tests/manifest/main.rs index 6b4ca9e..813087d 100644 --- a/tests/manifest/main.rs +++ b/tests/manifest/main.rs @@ -41,7 +41,7 @@ fn it_creates_a_package_json_default_path() { "https://github.com/ashleygwilliams/wasm-pack.git" ); assert_eq!(pkg.files, ["wasm_pack_bg.wasm"]); - assert_eq!(pkg.main, "index.js"); + assert_eq!(pkg.main, "wasm_pack.js"); } #[test]