-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(es/minifier): Inline across side-effect-free member exprs, (#10056)
**Description:** This is safe even in the presence of an impure setter because JS eval rhs **before** setter ```js ({ set a(v) { console.log(v) }}).a = (console.log(1), 2) ``` would output `1 2`, and gcc has this optimization too.
- Loading branch information
Showing
84 changed files
with
1,862 additions
and
2,541 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
swc_core: minor | ||
swc_ecma_minifier: minor | ||
--- | ||
|
||
feat(es/minifier): Seq inline across side effect free member |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
crates/swc/tests/tsc-references/ES5SymbolProperty2.2.minified.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
//// [ES5SymbolProperty2.ts] | ||
var M, M1, _$Symbol, C; | ||
var M, _$Symbol, C; | ||
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; | ||
M1 = M || (M = {}), C = /*#__PURE__*/ function() { | ||
(M || (M = {})).C = C = /*#__PURE__*/ function() { | ||
function C() { | ||
_class_call_check(this, C); | ||
} | ||
return C.prototype[_$Symbol.iterator] = function() {}, C; | ||
}(), M1.C = C, (new C)[_$Symbol.iterator], (new M.C)[Symbol.iterator]; | ||
}(), (new C)[_$Symbol.iterator], (new M.C)[Symbol.iterator]; |
6 changes: 3 additions & 3 deletions
6
...c/tests/tsc-references/ExportClassWhichExtendsInterfaceWithInaccessibleType.2.minified.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
//// [ExportClassWhichExtendsInterfaceWithInaccessibleType.ts] | ||
var A, A1, Point2d; | ||
var A; | ||
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; | ||
A1 = A || (A = {}), Point2d = /*#__PURE__*/ function() { | ||
(A || (A = {})).Point2d = /*#__PURE__*/ function() { | ||
function Point2d(x, y) { | ||
_class_call_check(this, Point2d), this.x = x, this.y = y; | ||
} | ||
return Point2d.prototype.fromOrigin = function(p) { | ||
return 1; | ||
}, Point2d; | ||
}(), A1.Point2d = Point2d; | ||
}(); |
10 changes: 5 additions & 5 deletions
10
...ssibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.2.minified.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
...sts/tsc-references/ExportClassWithInaccessibleTypeInTypeParameterConstraint.2.minified.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
//// [ExportClassWithInaccessibleTypeInTypeParameterConstraint.ts] | ||
var A, A1, Point3d, Line; | ||
var A, A1; | ||
import { _ as _call_super } from "@swc/helpers/_/_call_super"; | ||
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; | ||
import { _ as _inherits } from "@swc/helpers/_/_inherits"; | ||
(A1 = A || (A = {})).Origin = { | ||
x: 0, | ||
y: 0 | ||
}, Point3d = /*#__PURE__*/ function(Point) { | ||
}, A1.Point3d = /*#__PURE__*/ function(Point) { | ||
function Point3d() { | ||
return _class_call_check(this, Point3d), _call_super(this, Point3d, arguments); | ||
} | ||
return _inherits(Point3d, Point), Point3d; | ||
}(function Point() { | ||
_class_call_check(this, Point); | ||
}), A1.Point3d = Point3d, A1.Origin3d = { | ||
}), A1.Origin3d = { | ||
x: 0, | ||
y: 0, | ||
z: 0 | ||
}, Line = /*#__PURE__*/ function() { | ||
}, A1.Line = /*#__PURE__*/ function() { | ||
function Line(start, end) { | ||
_class_call_check(this, Line), this.start = start, this.end = end; | ||
} | ||
return Line.fromorigin2d = function(p) { | ||
return null; | ||
}, Line; | ||
}(), A1.Line = Line; | ||
}(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...tsc-references/ExportFunctionWithInaccessibleTypesInParameterTypeAnnotation.2.minified.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 1 addition & 4 deletions
5
crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es2017.2.minified.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
//// [asyncAwaitIsolatedModules_es2017.ts] | ||
var M; | ||
!function(M) { | ||
async function f1() {} | ||
M.f1 = f1; | ||
}(M || (M = {})); | ||
(M || (M = {})).f1 = async function() {}; | ||
export { }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 1 addition & 4 deletions
5
crates/swc/tests/tsc-references/asyncAwait_es2017.2.minified.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
//// [asyncAwait_es2017.ts] | ||
var M; | ||
!function(M) { | ||
async function f1() {} | ||
M.f1 = f1; | ||
}(M || (M = {})); | ||
(M || (M = {})).f1 = async function() {}; |
6 changes: 3 additions & 3 deletions
6
crates/swc/tests/tsc-references/circularImportAlias.2.minified.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
//// [circularImportAlias.ts] | ||
var B, A, B1, D, A1; | ||
var B, A, B1, A1; | ||
import { _ as _call_super } from "@swc/helpers/_/_call_super"; | ||
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; | ||
import { _ as _inherits } from "@swc/helpers/_/_inherits"; | ||
(B1 = B || (B = {})).a = A, D = /*#__PURE__*/ function(_B_a_C) { | ||
(B1 = B || (B = {})).a = A, B1.D = /*#__PURE__*/ function(_B_a_C) { | ||
function D() { | ||
return _class_call_check(this, D), _call_super(this, D, arguments); | ||
} | ||
return _inherits(D, _B_a_C), D; | ||
}(B1.a.C), B1.D = D, (A1 = A || (A = {})).C = function C() { | ||
}(B1.a.C), (A1 = A || (A = {})).C = function C() { | ||
_class_call_check(this, C); | ||
}, A1.b = B, new B.a.C(); |
6 changes: 3 additions & 3 deletions
6
crates/swc/tests/tsc-references/classAbstractImportInstantiation.2.minified.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
//// [classAbstractImportInstantiation.ts] | ||
var M, A, M1; | ||
var A, M; | ||
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; | ||
M = M1 || (M1 = {}), A = function A() { | ||
(M || (M = {})).A = A = function A() { | ||
_class_call_check(this, A); | ||
}, M.A = A, new A, new M1.A; | ||
}, new A, new M.A; |
8 changes: 4 additions & 4 deletions
8
crates/swc/tests/tsc-references/classAbstractInAModule.2.minified.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
//// [classAbstractInAModule.ts] | ||
var M, M1, A, B; | ||
var M, M1, A; | ||
import { _ as _call_super } from "@swc/helpers/_/_call_super"; | ||
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; | ||
import { _ as _inherits } from "@swc/helpers/_/_inherits"; | ||
M1 = M || (M = {}), A = function A() { | ||
(M1 = M || (M = {})).A = A = function A() { | ||
_class_call_check(this, A); | ||
}, M1.A = A, B = /*#__PURE__*/ function(A) { | ||
}, M1.B = /*#__PURE__*/ function(A) { | ||
function B() { | ||
return _class_call_check(this, B), _call_super(this, B, arguments); | ||
} | ||
return _inherits(B, A), B; | ||
}(A), M1.B = B, new M.A, new M.B; | ||
}(A), new M.A, new M.B; |
Oops, something went wrong.