Skip to content

Commit

Permalink
Implement shim_is_module
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda committed Nov 26, 2022
1 parent f0b154e commit bdd2494
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/cli-support/src/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,5 +269,8 @@ intrinsics! {
#[symbol = "__wbindgen_init_externref_table"]
#[signature = fn() -> Unit]
InitExternrefTable,
#[symbol = "__wbindgen_shim_is_module"]
#[signature = fn() -> Boolean]
ShimIsModule,
}
}
4 changes: 4 additions & 0 deletions crates/cli-support/src/js/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3539,6 +3539,10 @@ impl<'a> Context<'a> {
}
base
}

Intrinsic::ShimIsModule => {
format!("{}", !self.config.mode.no_modules())
}
};
Ok(expr)
}
Expand Down
7 changes: 7 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,8 @@ externs! {
fn __wbindgen_memory() -> u32;
fn __wbindgen_module() -> u32;
fn __wbindgen_function_table() -> u32;

fn __wbindgen_shim_is_module() -> u32;
}
}

Expand Down Expand Up @@ -1364,6 +1366,11 @@ pub fn function_table() -> JsValue {
unsafe { JsValue::_new(__wbindgen_function_table()) }
}

/// Returns if the generated JS shim is a ES module.
pub fn shim_is_module() -> bool {
(unsafe { __wbindgen_shim_is_module() }) != 0
}

#[doc(hidden)]
pub mod __rt {
use crate::JsValue;
Expand Down

0 comments on commit bdd2494

Please sign in to comment.