Skip to content

Commit

Permalink
Add a specific flag to enable / disable the use of 'import.meta.url' (e…
Browse files Browse the repository at this point in the history
…mscripten-core#9234)

This fixes the problem reported by emscripten-core#9233 and by emscripten-core#8729 while fixing the
    regression bug causes by emscripten-core#8940
  • Loading branch information
adevress authored and belraquib committed Dec 23, 2020
1 parent 46aff8b commit 8e7d484
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -422,3 +422,4 @@ a license to everyone to use it as detailed in LICENSE.)
* Egor Suvorov <esuvorov@think-cell.com> (copyright owned by think-cell Software GmbH)
* James Kuszmaul <jabukuszmaul@gmail.com>
* Wei Mingzhi <whistler_wmz@users.sourceforge.net>
* Adrien Devresse <adev@adev.name>
2 changes: 1 addition & 1 deletion emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3043,7 +3043,7 @@ def modularize():
# immediately anyhow, like in non-modularize mode)
# In EXPORT_ES6 + USE_PTHREADS the 'thread' is actually an ES6 module webworker running in strict mode,
# so doesn't have access to 'document'. In this case use 'import.meta' instead.
if shared.Settings.EXPORT_ES6 and shared.Settings.USE_PTHREADS:
if shared.Settings.EXPORT_ES6 and shared.Settings.USE_ES6_IMPORT_META:
script_url = "import.meta.url"
else:
script_url = "typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined"
Expand Down
5 changes: 5 additions & 0 deletions src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,11 @@ var SEPARATE_ASM_MODULE_NAME = '';
// be enabled for ES6 exports.
var EXPORT_ES6 = 0;

// Use the ES6 Module relative import feature 'import.meta.url'
// to auto-detect WASM Module path.
// It might not be supported on old browsers / toolchains
var USE_ES6_IMPORT_META = 1;

// If 1, will just time how long main() takes to execute, and not print out
// anything at all whatsoever. This is useful for benchmarking.
var BENCHMARK = 0;
Expand Down

0 comments on commit 8e7d484

Please sign in to comment.