Skip to content

Commit 0bed0b0

Browse files
committed
possibility
1 parent f174667 commit 0bed0b0

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

src/settings.js

+10
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,16 @@ var MODULARIZE_INSTANCE = 0;
885885
// be enabled for ES6 exports.
886886
var EXPORT_ES6 = 0;
887887

888+
// The version of JS that may be used in input you provide: --pre-js,
889+
// --js-library, EM_ASM, and EM_JS.
890+
// The number here can be 0, which means plain ES5. Otherwise,
891+
// it should be any of the modern year-based JS names, e.g., 2015(=ES6),
892+
// 2016(=ES7), etc.
893+
// For anything other than ES5, some JS minification that depends on
894+
// uglify1 is not run, and so you should build with --closure 1 to get
895+
// minified that way.
896+
var INPUT_JS_VERSION = 0;
897+
888898
// If 1, will just time how long main() takes to execute, and not print out
889899
// anything at all whatsoever. This is useful for benchmarking.
890900
var BENCHMARK = 0;

tools/shared.py

+11-12
Original file line numberDiff line numberDiff line change
@@ -2536,13 +2536,11 @@ def minify_wasm_js(js_file, wasm_file, expensive_optimizations, minify_whitespac
25362536
if minify_whitespace:
25372537
passes.append('minifyWhitespace')
25382538
if passes:
2539-
logger.debug('running cleanup on shell code: ' + ' '.join(passes))
2540-
# XXX estree syntax doesn't clearly separate definitions from uses, e.g.
2541-
# Identifier is used both for the x in function foo(x) {
2542-
# and for y = x + 1. That means our JSDCE would need to know about
2543-
# all aspects of estree, e.g., ArrowFunctionExpression and perhaps
2544-
# more in the future, so it would not be safe for us to do this.
2545-
js_file = Building.acorn_optimizer(js_file, ['noPrintMetadata'] + passes)
2539+
if Settings.INPUT_JS_VERSION == 0:
2540+
logger.debug('running cleanup on shell code: ' + ' '.join(passes))
2541+
js_file = Building.js_optimizer_no_asmjs(js_file, ['noPrintMetadata'] + passes)
2542+
else:
2543+
logging.debug('num running JSDCE since code may contain JS later than ES5. you should use --closure 1 for compact JS')
25462544
# if we can optimize this js+wasm combination under the assumption no one else
25472545
# will see the internals, do so
25482546
if not Settings.LINKABLE:
@@ -2552,11 +2550,12 @@ def minify_wasm_js(js_file, wasm_file, expensive_optimizations, minify_whitespac
25522550
js_file = Building.metadce(js_file, wasm_file, minify_whitespace=minify_whitespace, debug_info=debug_info)
25532551
# now that we removed unneeded communication between js and wasm, we can clean up
25542552
# the js some more.
2555-
passes = ['noPrintMetadata', 'AJSDCE']
2556-
if minify_whitespace:
2557-
passes.append('minifyWhitespace')
2558-
logger.debug('running post-meta-DCE cleanup on shell code: ' + ' '.join(passes))
2559-
js_file = Building.js_optimizer_no_asmjs(js_file, passes)
2553+
if Settings.INPUT_JS_VERSION == 0:
2554+
passes = ['noPrintMetadata', 'AJSDCE']
2555+
if minify_whitespace:
2556+
passes.append('minifyWhitespace')
2557+
logger.debug('running post-meta-DCE cleanup on shell code: ' + ' '.join(passes))
2558+
js_file = Building.js_optimizer_no_asmjs(js_file, passes)
25602559
# also minify the names used between js and wasm, if we emitting JS (then the JS knows how to load the minified names)
25612560
# If we are building with DECLARE_ASM_MODULE_EXPORTS=0, we must *not* minify the exports from the wasm module, since in DECLARE_ASM_MODULE_EXPORTS=0 mode, the code that
25622561
# reads out the exports is compacted by design that it does not have a chance to unminify the functions. If we are building with DECLARE_ASM_MODULE_EXPORTS=1, we might

0 commit comments

Comments
 (0)