Skip to content

Commit afd47f1

Browse files
committed
add helpful error for renamed wasm module
1 parent c6d68f4 commit afd47f1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

godot-macros/src/gdextension.rs

+5
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ pub fn attribute_gdextension(item: venial::Item) -> ParseResult<TokenStream> {
5454
let script = std::ffi::CString::new(concat!(
5555
"var pkgName = '", env!("CARGO_PKG_NAME"), "';", r#"
5656
var libName = pkgName.replaceAll('-', '_') + '.wasm';
57+
if (!(libName in LDSO.loadedLibsByName)) {
58+
// Always print to console, even if the error is suppressed.
59+
console.error(`godot-rust could not find the Wasm module '${libName}', needed to load the '${pkgName}' crate. Please ensure a file named '${libName}' exists in the game's web export files. This may require updating Wasm paths in the crate's corresponding '.gdextension' file, or just renaming the Wasm file to the correct name otherwise.`);
60+
throw new Error(`Wasm module '${libName}' not found. Check the console for more information.`);
61+
}
5762
var dso = LDSO.loadedLibsByName[libName];
5863
// This property was renamed as of emscripten 3.1.34
5964
var dso_exports = "module" in dso ? dso["module"] : dso["exports"];

0 commit comments

Comments
 (0)