diff --git a/tools/building.py b/tools/building.py index 183307179364c..671eff55f4017 100644 --- a/tools/building.py +++ b/tools/building.py @@ -539,6 +539,7 @@ def transpile(filename): config_json = json.dumps(config, indent=2) outfile = shared.get_temp_files().get('babel.js').name config_file = shared.get_temp_files().get('babel_config.json').name + logger.debug(config_json) utils.write_file(config_file, config_json) cmd = shared.get_npm_cmd('babel') + [filename, '-o', outfile, '--presets', '@babel/preset-env', '--config-file', config_file] check_call(cmd, cwd=path_from_root()) diff --git a/tools/feature_matrix.py b/tools/feature_matrix.py index 8f2e1386f1191..3a836d92f7295 100644 --- a/tools/feature_matrix.py +++ b/tools/feature_matrix.py @@ -15,6 +15,21 @@ UNSUPPORTED = 0x7FFFFFFF +# Oldest support browser versions. These have been set somewhat +# arbitrarily for now, based on: +# https://caniuse.com/mdn-javascript_builtins_object_assign +# -> FF:34 CHROME:45 SAFARI:9 NODE:4.0.0 +# https://caniuse.com/promises +# https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise +# -> FF:29 CHROME:33 SAFARI:8 NODE:0.12.0 +# TODO(sbc): Design a of policy for manging these values. +OLDEST_SUPPORTED_CHROME = 45 +OLDEST_SUPPORTED_FIREFOX = 34 +OLDEST_SUPPORTED_SAFARI = 90000 +# 10.19.0 is the oldest version of node that we do any testing with. +# Keep this in sync with the test-node-compat in .circleci/config.yml. +OLDEST_SUPPORTED_NODE = 101900 + class Feature(IntEnum): NON_TRAPPING_FPTOINT = auto() diff --git a/tools/link.py b/tools/link.py index 1f2a6489a5719..4f3275319035e 100644 --- a/tools/link.py +++ b/tools/link.py @@ -621,6 +621,26 @@ def set_max_memory(): exit_with_error('MAXIMUM_MEMORY cannot be less than INITIAL_MEMORY') +def check_browser_versions(): + settings_map = { + 'MIN_FIREFOX_VERSION': feature_matrix.OLDEST_SUPPORTED_FIREFOX, + 'MIN_CHROME_VERSION': feature_matrix.OLDEST_SUPPORTED_CHROME, + 'MIN_SAFARI_VERSION': feature_matrix.OLDEST_SUPPORTED_SAFARI, + 'MIN_NODE_VERSION': feature_matrix.OLDEST_SUPPORTED_NODE, + } + + if settings.LEGACY_VM_SUPPORT: + # Support all old browser versions + for key, oldest in settings_map.items(): + default_setting(key, oldest) + + for key, oldest in settings_map.items(): + if settings[key] == 0: + settings[key] = oldest + if settings[key] < oldest: + exit_with_error(f'{key} older than {oldest} is not supported') + + @ToolchainProfiler.profile_block('linker_setup') def phase_linker_setup(options, state, newargs): system_libpath = '-L' + str(cache.get_lib_dir(absolute=True)) @@ -1091,27 +1111,16 @@ def phase_linker_setup(options, state, newargs): if settings.MINIMAL_RUNTIME and options.oformat == OFormat.HTML and not settings.PTHREADS: settings.EXPORT_READY_PROMISE = 0 - if settings.LEGACY_VM_SUPPORT: - if settings.WASM2JS: - settings.POLYFILL_OLD_MATH_FUNCTIONS = 1 + if settings.WASM2JS and settings.LEGACY_VM_SUPPORT: + settings.POLYFILL_OLD_MATH_FUNCTIONS = 1 - # Support all old browser versions - settings.MIN_FIREFOX_VERSION = 0 - settings.MIN_SAFARI_VERSION = 0 - settings.MIN_CHROME_VERSION = 0 - settings.MIN_NODE_VERSION = 0 + check_browser_versions() if settings.MIN_CHROME_VERSION <= 37: settings.WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG = 1 - # 10.19.0 is the oldest version of node that we do any testing with. - # Keep this in sync with the test-node-compat in .circleci/config.yml - # and MINIMUM_NODE_VERSION in tools/shared.py - if settings.MIN_NODE_VERSION: - if settings.MIN_NODE_VERSION < 101900: - exit_with_error('targeting node older than 10.19.00 is not supported') - if settings.MIN_NODE_VERSION >= 150000: - default_setting('NODEJS_CATCH_REJECTION', 0) + if settings.MIN_NODE_VERSION >= 150000: + default_setting('NODEJS_CATCH_REJECTION', 0) # Do not catch rejections or exits in modularize mode, as these options # are for use when running emscripten modules standalone