Skip to content

Commit 53568c0

Browse files
authored
Ensure compatibility with Safari for multi-environment ES6 builds (#18482)
Use a different parameter name to prevent the variable from being incorrectly hoisted in JavaScriptCore-based engines (such as Safari). See: https://bugs.webkit.org/show_bug.cgi?id=223533. Regressed for multi-environment ES6 builds since commit ce4c405 (Emscripten 3.1.27). `-sENVIRONMENT=web` is not affected, as that would avoid the emit of this async function altogether. Resolves: #18357.
1 parent 1d45c23 commit 53568c0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

emcc.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3769,9 +3769,13 @@ def modularize():
37693769
if not settings.EXPORT_READY_PROMISE:
37703770
return_value = '{}'
37713771

3772+
# TODO: Remove when https://bugs.webkit.org/show_bug.cgi?id=223533 is resolved.
3773+
if async_emit != '' and settings.EXPORT_NAME == 'config':
3774+
diagnostics.warning('emcc', 'EXPORT_NAME should not be named "config" when targeting Safari')
3775+
37723776
src = '''
3773-
%(maybe_async)sfunction(%(EXPORT_NAME)s) {
3774-
%(EXPORT_NAME)s = %(EXPORT_NAME)s || {};
3777+
%(maybe_async)sfunction(config) {
3778+
var %(EXPORT_NAME)s = config || {};
37753779
37763780
%(src)s
37773781

0 commit comments

Comments
 (0)