@@ -216,7 +216,7 @@ def parse_args(newargs): # noqa: C901, PLR0912, PLR0915
216216 """
217217 should_exit = False
218218 skip = False
219- user_js_defines = set ()
219+ user_js_defines : dict [ str , str ] = {}
220220 LEGACY_ARGS = {'--js-opts' , '--llvm-opts' , '--llvm-lto' , '--memory-init-file' }
221221 LEGACY_FLAGS = {'--separate-asm' , '--jcache' , '--proxy-to-worker' , '--default-obj-ext' ,
222222 '--embind-emit-tsd' , '--remove-duplicates' , '--no-heap-copy' }
@@ -576,11 +576,9 @@ def consume_arg_file():
576576 key , value = key .split ('=' )
577577 else :
578578 value = '1'
579- if key in settings .keys () and key not in user_js_defines :
579+ if key in settings .keys () and key not in options . user_js_defines :
580580 exit_with_error (f'{ arg } : cannot change built-in settings values with a -jsD directive. Pass -s{ key } ={ value } instead!' )
581- user_js_defines .add (key )
582- # Apply user -jsD settings
583- settings [key ] = value
581+ options .user_js_defines [key ] = value
584582 newargs [i ] = ''
585583 elif check_flag ('-shared' ):
586584 options .shared = True
@@ -869,5 +867,9 @@ def parse_arguments(args):
869867
870868 # Apply -s args here (after optimization levels, so they can override them)
871869 apply_user_settings ()
870+
871+ # Apply -jsD defines last so they win over -s args
872+ for key , value in options .user_js_defines .items ():
873+ settings [key ] = value
872874
873875 return newargs
0 commit comments