forked from swc-project/swc
-
Notifications
You must be signed in to change notification settings - Fork 4
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): Do not drop used properties (swc-project#7702)
**Related issue:** - Closes swc-project#7700. - Closes swc-project#7710.
- Loading branch information
Showing
60 changed files
with
1,214 additions
and
61,563 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,63 @@ | ||
{ | ||
"jsc": { | ||
"parser": { | ||
"syntax": "typescript", | ||
"tsx": true | ||
}, | ||
"transform": { | ||
"react": {} | ||
}, | ||
"target": "esnext", | ||
"loose": true, | ||
"minify": { | ||
"compress": { | ||
"arguments": false, | ||
"arrows": true, | ||
"booleans": true, | ||
"booleans_as_integers": false, | ||
"collapse_vars": true, | ||
"comparisons": true, | ||
"computed_props": true, | ||
"conditionals": true, | ||
"dead_code": true, | ||
"directives": true, | ||
"drop_console": false, | ||
"drop_debugger": true, | ||
"evaluate": true, | ||
"expression": false, | ||
"hoist_funs": false, | ||
"hoist_props": true, | ||
"hoist_vars": false, | ||
"if_return": true, | ||
"join_vars": true, | ||
"keep_classnames": false, | ||
"keep_fargs": true, | ||
"keep_fnames": false, | ||
"keep_infinity": false, | ||
"loops": true, | ||
"negate_iife": true, | ||
"properties": true, | ||
"reduce_funcs": false, | ||
"reduce_vars": false, | ||
"side_effects": true, | ||
"switches": true, | ||
"typeofs": true, | ||
"unsafe": false, | ||
"unsafe_arrows": false, | ||
"unsafe_comps": false, | ||
"unsafe_Function": false, | ||
"unsafe_math": false, | ||
"unsafe_symbols": false, | ||
"unsafe_methods": false, | ||
"unsafe_proto": false, | ||
"unsafe_regexp": false, | ||
"unsafe_undefined": false, | ||
"unused": true, | ||
"const_to_let": true, | ||
"pristine_globals": true | ||
} | ||
}, | ||
}, | ||
"isModule": true, | ||
"minify": false | ||
} |
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,22 @@ | ||
const positions = { | ||
top: 1, | ||
left: 2, | ||
right: 3, | ||
bottom: 4, | ||
} | ||
|
||
const rtlPositions = { | ||
top: 1, | ||
right: 2, | ||
left: 3, | ||
bottom: 4, | ||
} | ||
|
||
export function PositionRender({ isRtl, position }) { | ||
|
||
const display = (isRtl === 'fe-fe-fe' ? rtlPositions : positions)[position]; | ||
|
||
return <h1> | ||
PositionRender: {display} | ||
</h1> | ||
} |
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,23 @@ | ||
|
||
const positions = { | ||
top: 1, | ||
left: 2, | ||
right: 3, | ||
bottom: 4, | ||
} | ||
|
||
const rtlPositions = { | ||
top: 1, | ||
right: 2, | ||
left: 3, | ||
bottom: 4, | ||
} | ||
|
||
export function PositionRender({ isRtl, position }) { | ||
|
||
const display = (isRtl === 'fe-fe-fe' ? [rtlPositions] : { positions })[position]; | ||
|
||
return <h1> | ||
PositionRender: {display} | ||
</h1> | ||
} |
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,23 @@ | ||
|
||
const positions = { | ||
top: 1, | ||
left: 2, | ||
right: 3, | ||
bottom: 4, | ||
} | ||
|
||
const rtlPositions = { | ||
top: 1, | ||
right: 2, | ||
left: 3, | ||
bottom: 4, | ||
} | ||
|
||
export function PositionRender({ isRtl, position }) { | ||
|
||
const display = (isRtl === 'fe-fe-fe' ? [rtlPositions ?? 1] : { positions })[position]; | ||
|
||
return <h1> | ||
PositionRender: {display} | ||
</h1> | ||
} |
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,23 @@ | ||
|
||
const positions = { | ||
top: 1, | ||
left: 2, | ||
right: 3, | ||
bottom: 4, | ||
} | ||
|
||
const rtlPositions = { | ||
top: 1, | ||
right: 2, | ||
left: 3, | ||
bottom: 4, | ||
} | ||
|
||
export function PositionRender({ isRtl, position }) { | ||
|
||
const display = (isRtl === 'fe-fe-fe' ? rtlPositions : { a: positions })[position]; | ||
|
||
return <h1> | ||
PositionRender: {display} | ||
</h1> | ||
} |
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,23 @@ | ||
|
||
const positions = { | ||
top: 1, | ||
left: 2, | ||
right: 3, | ||
bottom: 4, | ||
} | ||
|
||
const rtlPositions = { | ||
top: 1, | ||
right: 2, | ||
left: 3, | ||
bottom: 4, | ||
} | ||
|
||
export function PositionRender({ isRtl, position }) { | ||
|
||
const display = (isRtl === 'fe-fe-fe' ? rtlPositions : { a: [positions] })[position]; | ||
|
||
return <h1> | ||
PositionRender: {display} | ||
</h1> | ||
} |
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,15 @@ | ||
let positions = { | ||
top: 1, | ||
left: 2, | ||
right: 3, | ||
bottom: 4 | ||
}, rtlPositions = { | ||
top: 1, | ||
right: 2, | ||
left: 3, | ||
bottom: 4 | ||
}; | ||
export function PositionRender({ isRtl, position }) { | ||
let display = ('fe-fe-fe' === isRtl ? rtlPositions : positions)[position]; | ||
return React.createElement("h1", null, "PositionRender: ", display); | ||
} |
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,19 @@ | ||
let positions = { | ||
top: 1, | ||
left: 2, | ||
right: 3, | ||
bottom: 4 | ||
}, rtlPositions = { | ||
top: 1, | ||
right: 2, | ||
left: 3, | ||
bottom: 4 | ||
}; | ||
export function PositionRender({ isRtl, position }) { | ||
let display = ('fe-fe-fe' === isRtl ? [ | ||
rtlPositions | ||
] : { | ||
positions | ||
})[position]; | ||
return React.createElement("h1", null, "PositionRender: ", display); | ||
} |
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,19 @@ | ||
let positions = { | ||
top: 1, | ||
left: 2, | ||
right: 3, | ||
bottom: 4 | ||
}, rtlPositions = { | ||
top: 1, | ||
right: 2, | ||
left: 3, | ||
bottom: 4 | ||
}; | ||
export function PositionRender({ isRtl, position }) { | ||
let display = ('fe-fe-fe' === isRtl ? [ | ||
rtlPositions ?? 1 | ||
] : { | ||
positions | ||
})[position]; | ||
return React.createElement("h1", null, "PositionRender: ", display); | ||
} |
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,17 @@ | ||
let positions = { | ||
top: 1, | ||
left: 2, | ||
right: 3, | ||
bottom: 4 | ||
}, rtlPositions = { | ||
top: 1, | ||
right: 2, | ||
left: 3, | ||
bottom: 4 | ||
}; | ||
export function PositionRender({ isRtl, position }) { | ||
let display = ('fe-fe-fe' === isRtl ? rtlPositions : { | ||
a: positions | ||
})[position]; | ||
return React.createElement("h1", null, "PositionRender: ", display); | ||
} |
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,19 @@ | ||
let positions = { | ||
top: 1, | ||
left: 2, | ||
right: 3, | ||
bottom: 4 | ||
}, rtlPositions = { | ||
top: 1, | ||
right: 2, | ||
left: 3, | ||
bottom: 4 | ||
}; | ||
export function PositionRender({ isRtl, position }) { | ||
let display = ('fe-fe-fe' === isRtl ? rtlPositions : { | ||
a: [ | ||
positions | ||
] | ||
})[position]; | ||
return React.createElement("h1", null, "PositionRender: ", display); | ||
} |
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,14 @@ | ||
{ | ||
"jsc": { | ||
"parser": { | ||
"syntax": "ecmascript" | ||
}, | ||
"loose": false, | ||
"minify": { | ||
"compress": { | ||
"hoist_props": true | ||
} | ||
}, | ||
"target": "es2022" | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
crates/swc/tests/fixture/issues-7xxx/7710/input/export-class-1.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,10 @@ | ||
const obj = { | ||
foo: 1, | ||
bar: 2, | ||
}; | ||
|
||
console.log(obj.bar); | ||
|
||
export class Foo { | ||
[obj] = 1; | ||
}; |
10 changes: 10 additions & 0 deletions
10
crates/swc/tests/fixture/issues-7xxx/7710/input/export-class-2.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,10 @@ | ||
const obj = { | ||
foo: 1, | ||
bar: 2, | ||
}; | ||
|
||
console.log(obj.bar); | ||
|
||
export class Foo { | ||
foo = obj; | ||
}; |
10 changes: 10 additions & 0 deletions
10
crates/swc/tests/fixture/issues-7xxx/7710/input/export-class-3.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,10 @@ | ||
const obj = { | ||
foo: 1, | ||
bar: 2, | ||
}; | ||
|
||
console.log(obj.bar); | ||
|
||
export class Foo { | ||
foo = obj ?? 1; | ||
}; |
10 changes: 10 additions & 0 deletions
10
crates/swc/tests/fixture/issues-7xxx/7710/input/export-default-class-1.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,10 @@ | ||
const obj = { | ||
foo: 1, | ||
bar: 2, | ||
}; | ||
|
||
console.log(obj.bar); | ||
|
||
export default class { | ||
[obj] = 1; | ||
}; |
10 changes: 10 additions & 0 deletions
10
crates/swc/tests/fixture/issues-7xxx/7710/input/export-default-class-2.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,10 @@ | ||
const obj = { | ||
foo: 1, | ||
bar: 2, | ||
}; | ||
|
||
console.log(obj.bar); | ||
|
||
export default class { | ||
[obj ?? 1] = 1; | ||
}; |
10 changes: 10 additions & 0 deletions
10
crates/swc/tests/fixture/issues-7xxx/7710/input/export-default-class-3.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,10 @@ | ||
const obj = { | ||
foo: 1, | ||
bar: 2, | ||
}; | ||
|
||
console.log(obj.bar); | ||
|
||
export default class { | ||
foo = obj ?? 1; | ||
}; |
10 changes: 10 additions & 0 deletions
10
crates/swc/tests/fixture/issues-7xxx/7710/input/export-default-class-4.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,10 @@ | ||
const obj = { | ||
foo: 1, | ||
bar: 2, | ||
}; | ||
|
||
console.log(obj.bar); | ||
|
||
export default class { | ||
foo = obj; | ||
}; |
10 changes: 10 additions & 0 deletions
10
crates/swc/tests/fixture/issues-7xxx/7710/input/export-default-class-5.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,10 @@ | ||
const obj = { | ||
foo: 1, | ||
bar: 2, | ||
}; | ||
|
||
console.log(obj.bar); | ||
|
||
export default class Foo { | ||
foo = obj ?? 1; | ||
}; |
Oops, something went wrong.