try to fix global / modulaized import ns conflict (#2057)

* use global import map for rename

* fix same ns import

* cargo fmt

* add basic test

* move generate_identifier, add comments, add tests

* remove leading &mut

* remove unnecessary bail

* use import_name for global and some refine

* Add back in error handling, clean up instruction iteration

* Remove unnecessary patch statements

Co-authored-by: Alex Crichton <alex@alexcrichton.com>
This commit is contained in:
a1trl9
2020-04-15 21:28:29 +08:00
committed by GitHub
parent a75570de31
commit ad85de50c6
5 changed files with 141 additions and 54 deletions

View File

@ -135,6 +135,34 @@ fn works_on_empty_project() {
cmd.assert().success();
}
#[test]
fn namespace_global_and_noglobal_works() {
let (mut cmd, _out_dir) = Project::new("namespace_global_and_noglobal_works")
.file(
"src/lib.rs",
r#"
use wasm_bindgen::prelude::*;
#[wasm_bindgen(module = "fs")]
extern "C" {
#[wasm_bindgen(js_namespace = window)]
fn t1();
}
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(js_namespace = window)]
fn t2();
}
#[wasm_bindgen]
pub fn test() {
t1();
t2();
}
"#,
)
.wasm_bindgen("");
cmd.assert().success();
}
mod npm;
#[test]