Skip to content

Commit 6548670

Browse files
committed
Try to fix single-file mode
1 parent 71d39b1 commit 6548670

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/preamble.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,12 @@ function accept(data) {
4545
// Log output
4646
//Module['print'] = console.log
4747

48-
// And now some things just to patch over Emscripten's lack of a none environment. These could probably be removed if https://github.com/emscripten-core/emscripten/issues/12184 ever gets implemented
49-
// Add an importScripts function to prevent an assertion error
50-
//function importScripts() {}
51-
// Fake locateFile so that Lectrote doesn't get tripped up on import.meta.url not being handled in CJS properly
52-
//Module['locateFile'] = function() {}
48+
// In single-file mode new URL constructor won't work
49+
Module['locateFile'] = function(filename) {
50+
try {
51+
return new URL(filename, import.meta.url).href;
52+
}
53+
catch {
54+
return filename
55+
}
56+
}

0 commit comments

Comments
 (0)