@@ -915,6 +915,12 @@ def phase_linker_setup(options, state): # noqa: C901, PLR0912, PLR0915
915915 # When using MINIMAL_RUNTIME, symbols should only be exported if requested.
916916 default_setting ('EXPORT_KEEPALIVE' , 0 )
917917
918+ if settings .EXPORT_ES6 and not settings .MODULARIZE :
919+ # EXPORT_ES6 requires output to be a module
920+ if 'MODULARIZE' in user_settings :
921+ exit_with_error ('EXPORT_ES6 requires MODULARIZE to be set' )
922+ settings .MODULARIZE = 1
923+
918924 if settings .STRICT_JS and (settings .MODULARIZE or settings .EXPORT_ES6 ):
919925 exit_with_error ("STRICT_JS doesn't work with MODULARIZE or EXPORT_ES6" )
920926
@@ -926,7 +932,7 @@ def phase_linker_setup(options, state): # noqa: C901, PLR0912, PLR0915
926932 options .shell_path = DEFAULT_SHELL_HTML
927933
928934 if settings .STRICT :
929- if not settings .MODULARIZE and not settings . EXPORT_ES6 :
935+ if not settings .MODULARIZE :
930936 default_setting ('STRICT_JS' , 1 )
931937 default_setting ('DEFAULT_TO_CXX' , 0 )
932938 default_setting ('IGNORE_MISSING_MAIN' , 0 )
@@ -1441,17 +1447,11 @@ def phase_linker_setup(options, state): # noqa: C901, PLR0912, PLR0915
14411447
14421448 set_initial_memory ()
14431449
1444- if settings .EXPORT_ES6 :
1445- if not settings .MODULARIZE :
1446- # EXPORT_ES6 requires output to be a module
1447- if 'MODULARIZE' in user_settings :
1448- exit_with_error ('EXPORT_ES6 requires MODULARIZE to be set' )
1449- settings .MODULARIZE = 1
1450- if settings .ENVIRONMENT_MAY_BE_NODE and not settings .USE_ES6_IMPORT_META :
1451- # EXPORT_ES6 + ENVIRONMENT=*node* requires the use of import.meta.url
1452- if 'USE_ES6_IMPORT_META' in user_settings :
1453- exit_with_error ('EXPORT_ES6 and ENVIRONMENT=*node* requires USE_ES6_IMPORT_META to be set' )
1454- settings .USE_ES6_IMPORT_META = 1
1450+ if settings .EXPORT_ES6 and settings .ENVIRONMENT_MAY_BE_NODE and not settings .USE_ES6_IMPORT_META :
1451+ # EXPORT_ES6 + ENVIRONMENT=*node* requires the use of import.meta.url
1452+ if 'USE_ES6_IMPORT_META' in user_settings :
1453+ exit_with_error ('EXPORT_ES6 and ENVIRONMENT=*node* requires USE_ES6_IMPORT_META to be set' )
1454+ settings .USE_ES6_IMPORT_META = 1
14551455
14561456 if settings .MODULARIZE and not settings .DECLARE_ASM_MODULE_EXPORTS :
14571457 # When MODULARIZE option is used, currently requires declaring all module exports
0 commit comments