-
-
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.
fix(es/minifier): Improve DCE (#9853)
**Description:** - We should check for the superclass while dropping class declarations. - Add early-check for `null && foo` and `true || foo`. **Related issue:** - Closes #9823
- Loading branch information
Showing
17 changed files
with
114 additions
and
6 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
crates/swc/tests/tsc-references/accessorsOverrideProperty3.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 +1,2 @@ | ||
//// [accessorsOverrideProperty3.ts] | ||
Animal; |
1 change: 1 addition & 0 deletions
1
crates/swc/tests/tsc-references/accessorsOverrideProperty4.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 +1,2 @@ | ||
//// [accessorsOverrideProperty4.ts] | ||
Animal; |
7 changes: 4 additions & 3 deletions
7
...s/swc/tests/tsc-references/asyncGeneratorParameterEvaluation(target=es2015).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,4 +1,5 @@ | ||
//// [asyncGeneratorParameterEvaluation.ts] | ||
import "@swc/helpers/_/_extends"; | ||
import "@swc/helpers/_/_object_destructuring_empty"; | ||
import "@swc/helpers/_/_wrap_async_generator"; | ||
import { _ as _extends } from "@swc/helpers/_/_extends"; | ||
import { _ as _object_destructuring_empty } from "@swc/helpers/_/_object_destructuring_empty"; | ||
import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator"; | ||
Super; |
5 changes: 3 additions & 2 deletions
5
...s/swc/tests/tsc-references/asyncGeneratorParameterEvaluation(target=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,3 +1,4 @@ | ||
//// [asyncGeneratorParameterEvaluation.ts] | ||
import "@swc/helpers/_/_extends"; | ||
import "@swc/helpers/_/_object_destructuring_empty"; | ||
import { _ as _extends } from "@swc/helpers/_/_extends"; | ||
import { _ as _object_destructuring_empty } from "@swc/helpers/_/_object_destructuring_empty"; | ||
Super; |
1 change: 1 addition & 0 deletions
1
...s/swc/tests/tsc-references/asyncGeneratorParameterEvaluation(target=es2018).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 +1,2 @@ | ||
//// [asyncGeneratorParameterEvaluation.ts] | ||
Super; |
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 +1,7 @@ | ||
//// [override19.ts] | ||
class Context { | ||
} | ||
class A { | ||
doSomething() {} | ||
} | ||
CreateMixin(Context, A), CreateMixin(Context, A); |
1 change: 1 addition & 0 deletions
1
crates/swc/tests/tsc-references/overrideInterfaceProperty.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 +1,2 @@ | ||
//// [overrideInterfaceProperty.ts] | ||
Mup, Mup; |
1 change: 1 addition & 0 deletions
1
crates/swc/tests/tsc-references/thisPropertyOverridesAccessors.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,2 +1,3 @@ | ||
//// [foo.ts] | ||
//// [bar.js] | ||
Foo; |
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
26 changes: 26 additions & 0 deletions
26
crates/swc_ecma_minifier/tests/fixture/issues/9823/1-class/input.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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
(() => { | ||
"use strict"; | ||
class Element { } | ||
class PointElement extends Element { | ||
static id = 'point'; | ||
constructor(cfg) { | ||
super(); | ||
} | ||
} | ||
|
||
// var chart_elements = /*#__PURE__*/ Object.freeze({ | ||
// PointElement: PointElement | ||
// }); | ||
|
||
var chart_elements = /*#__PURE__*/(null && (Object.freeze({ | ||
PointElement: PointElement | ||
}))); | ||
|
||
const registerables = null && ([ | ||
chart_elements, | ||
chart_plugins, | ||
]); | ||
|
||
console.log('Done 1') | ||
})() | ||
; |
1 change: 1 addition & 0 deletions
1
crates/swc_ecma_minifier/tests/fixture/issues/9823/1-class/output.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 |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('Done 1'); |
21 changes: 21 additions & 0 deletions
21
crates/swc_ecma_minifier/tests/fixture/issues/9823/2-class-extends/input.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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
(() => { | ||
"use strict"; | ||
class Element { } | ||
|
||
|
||
// var chart_elements = /*#__PURE__*/ Object.freeze({ | ||
// PointElement: PointElement | ||
// }); | ||
|
||
var chart_elements = /*#__PURE__*/(null && (Object.freeze({ | ||
Element: Element | ||
}))); | ||
|
||
const registerables = null && ([ | ||
chart_elements, | ||
chart_plugins | ||
]); | ||
|
||
console.log('Done 2') | ||
})() | ||
; |
1 change: 1 addition & 0 deletions
1
crates/swc_ecma_minifier/tests/fixture/issues/9823/2-class-extends/output.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 |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('Done 2'); |
7 changes: 7 additions & 0 deletions
7
crates/swc_ecma_minifier/tests/fixture/issues/9823/3/input.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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(function () { | ||
function foo() { | ||
|
||
} | ||
|
||
console.log('Done') | ||
})() |
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 @@ | ||
console.log('Done'); |
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