Skip to content

Commit 20f1e50

Browse files
committed
Fix the webidl-tests crate
1 parent 5de3189 commit 20f1e50

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

crates/cli-support/src/js/mod.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::descriptor::{Descriptor, VectorKind};
33
use crate::{Bindgen, EncodeInto, OutputMode};
44
use failure::{bail, Error, ResultExt};
55
use std::collections::{HashMap, HashSet};
6+
use std::env;
67
use walrus::{MemoryId, Module};
78
use wasm_bindgen_wasm_interpreter::Interpreter;
89

@@ -2797,11 +2798,14 @@ impl<'a, 'b> SubContext<'a, 'b> {
27972798
// module syntax in the snippet to a CommonJS module, which is in theory
27982799
// not that hard but is a chunk of work to do.
27992800
if is_local_snippet && self.cx.config.mode.nodejs() {
2800-
bail!(
2801-
"local JS snippets are not supported with `--nodejs`; \
2802-
see rustwasm/rfcs#6 for more details, but this restriction \
2803-
will be lifted in the future"
2804-
);
2801+
// have a small unergonomic escape hatch for our webidl-tests tests
2802+
if env::var("WBINDGEN_I_PROMISE_JS_SYNTAX_WORKS_IN_NODE").is_err() {
2803+
bail!(
2804+
"local JS snippets are not supported with `--nodejs`; \
2805+
see rustwasm/rfcs#6 for more details, but this restriction \
2806+
will be lifted in the future"
2807+
);
2808+
}
28052809
}
28062810

28072811
// Similar to `--no-modules`, only allow vendor prefixes basically for web

crates/webidl-tests/build.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@ fn main() {
2121

2222
let out_file = out_dir.join(path.file_name().unwrap()).with_extension("rs");
2323

24-
let js_file = path.with_extension("js").canonicalize().unwrap();
2524
generated_rust.push_str(&format!(
2625
r#"
2726
pub mod import_script {{
2827
use wasm_bindgen::prelude::*;
2928
use wasm_bindgen_test::*;
3029
31-
#[wasm_bindgen(module = r"{}")]
30+
#[wasm_bindgen(module = "/{}.js")]
3231
extern "C" {{
3332
fn not_actually_a_function{1}(x: &str);
3433
}}
@@ -41,7 +40,7 @@ fn main() {
4140
}}
4241
}}
4342
"#,
44-
js_file.display(),
43+
path.file_stem().unwrap().to_str().unwrap(),
4544
i
4645
));
4746

0 commit comments

Comments
 (0)