Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/js_optimizer/JSDCE-defaultArg-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var usedAsDefaultArg = 42;

var usedAsDefaultArg2 = [ 1, 2 ];

function g({notUsed: notUsed}, a, b = usedAsDefaultArg, [c, d] = usedAsDefaultArg2) {
function g({notUsed}, a, b = usedAsDefaultArg, [c, d] = usedAsDefaultArg2) {
return a + b + notUsed + 1;
}

Expand Down
2 changes: 1 addition & 1 deletion test/js_optimizer/JSDCE-objectPattern-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ let d = 40;
let z = 50;

globalThis.f = function([, r]) {
let {a: a, b: b} = r;
let {a, b} = r;
let {z: c} = r;
let [, i, {foo: p, bar: q}] = r;
return g(a, b, c, d, z);
Expand Down
4 changes: 2 additions & 2 deletions test/js_optimizer/applyImportAndExportNameChanges2-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,9 @@ env["__memory_base"] = STATIC_BASE;
env["__table_base"] = 0;

var imports = {
env: env,
env,
global: {
NaN: NaN,
NaN,
Infinity: Infinity
},
"global.Math": Math,
Expand Down
20 changes: 10 additions & 10 deletions test/js_optimizer/constructor-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ function u(a) {
};
}
return m({
Int8Array: Int8Array,
Int16Array: Int16Array,
Int32Array: Int32Array,
Uint8Array: Uint8Array,
Uint16Array: Uint16Array,
Uint32Array: Uint32Array,
Float32Array: Float32Array,
Float64Array: Float64Array,
NaN: NaN,
Int8Array,
Int16Array,
Int32Array,
Uint8Array,
Uint16Array,
Uint32Array,
Float32Array,
Float64Array,
NaN,
Infinity: Infinity,
Math: Math
Math
}, q, r.buffer);
}
// EMSCRIPTEN_END_ASM
Expand Down
14 changes: 14 additions & 0 deletions test/js_optimizer/test-object-literals-output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var foo = 1;

var baz = {};

var bar = {
foo,
baz
};

var bar2 = {
foo,
baz,
bar: foo
};
15 changes: 15 additions & 0 deletions test/js_optimizer/test-object-literals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var foo = 1;
var baz = {};

// Verify that shorthand object literals are preserved.
var bar = {
foo,
baz,
};

// Objects that could use shorthand are also converted where possible.
var bar2 = {
foo: foo,
"baz": baz,
bar: foo,
};
20 changes: 10 additions & 10 deletions test/js_optimizer/wasm2js-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,17 +430,17 @@ function X() {}
};
}
return D({
Int8Array: Int8Array,
Int16Array: Int16Array,
Int32Array: Int32Array,
Uint8Array: Uint8Array,
Uint16Array: Uint16Array,
Uint32Array: Uint32Array,
Float32Array: Float32Array,
Float64Array: Float64Array,
NaN: NaN,
Int8Array,
Int16Array,
Int32Array,
Uint8Array,
Uint16Array,
Uint32Array,
Float32Array,
Float64Array,
NaN,
Infinity: Infinity,
Math: Math
Math
}, H, I.buffer);
}
// EMSCRIPTEN_END_ASM
Expand Down
1 change: 1 addition & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -2889,6 +2889,7 @@ def test_extern_prepost(self):
'unsignPointers': ('test-unsignPointers.js', ['unsignPointers', '--closure-friendly']),
'asanify': ('test-asanify.js', ['asanify']),
'safeHeap': ('test-safeHeap.js', ['safeHeap']),
'object_literals': ('test-object-literals.js', []),
'LittleEndianHeap': ('test-LittleEndianHeap.js', ['littleEndianHeap']),
})
@crossplatform
Expand Down
1 change: 1 addition & 0 deletions tools/acorn-optimizer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2107,6 +2107,7 @@ if (!noPrint) {
keep_quoted_props: closureFriendly, // for closure
wrap_func_args: false, // don't add extra braces
comments: true, // for closure as well
shorthand: true, // Use object literal shorthand notation
});

output += '\n';
Expand Down
Loading