-
-
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): Fix minifier (#2711)
swc_ecma_minifier: - Respect `inline_prevented`. - Mark the LHS of an assignment pattern property as a pattern. (vercel/next.js#30498)
- Loading branch information
Showing
26 changed files
with
160 additions
and
54 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...destructuringObjectAssignmentPatternWithNestedSpread/input.ts/es2015.2.minified/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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
var _c; | ||
let d; | ||
let a, d; | ||
(function(source, excluded) { | ||
if (null == source) return { | ||
}; | ||
|
2 changes: 1 addition & 1 deletion
2
...ng/destructuringObjectAssignmentPatternWithNestedSpread/input.ts/es5.2.minified/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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
var _c, ref, d; | ||
var _c, ref, a, d; | ||
(function(source, excluded) { | ||
if (null == source) return { | ||
}; | ||
|
2 changes: 1 addition & 1 deletion
2
...s6/destructuring/destructuringReassignsRightHandSide/input.ts/es2015.2.minified/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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
var foo = { | ||
var bar, foo = { | ||
foo: 1, | ||
bar: 2 | ||
}; | ||
|
2 changes: 1 addition & 1 deletion
2
...nces/es6/destructuring/emptyAssignmentPatterns02_ES5/input.ts/es2015.2.minified/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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
var a; | ||
let a1, a2, a3; | ||
let x, y, z, a1, a2, a3; | ||
({} = { x , y , z } = a), [] = [a1, a2, a3] = a; |
2 changes: 1 addition & 1 deletion
2
.../destructuring/emptyAssignmentPatterns02_ES5iterable/input.ts/es2015.2.minified/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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
var a; | ||
let a1, a2, a3; | ||
let x, y, z, a1, a2, a3; | ||
({} = { x , y , z } = a), [] = [a1, a2, a3] = a; |
2 changes: 1 addition & 1 deletion
2
...nces/es6/destructuring/emptyAssignmentPatterns02_ES6/input.ts/es2015.2.minified/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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
var a; | ||
let a1, a2, a3; | ||
let x, y, z, a1, a2, a3; | ||
({} = { x , y , z } = a), [] = [a1, a2, a3] = a; |
2 changes: 1 addition & 1 deletion
2
...nces/es6/destructuring/emptyAssignmentPatterns04_ES5/input.ts/es2015.2.minified/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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
var a; | ||
let a1, a2, a3; | ||
let x, y, z, a1, a2, a3; | ||
({ x , y , z } = {} = a), [a1, a2, a3] = [] = a; |
2 changes: 1 addition & 1 deletion
2
.../destructuring/emptyAssignmentPatterns04_ES5iterable/input.ts/es2015.2.minified/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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
var a; | ||
let a1, a2, a3; | ||
let x, y, z, a1, a2, a3; | ||
({ x , y , z } = {} = a), [a1, a2, a3] = [] = a; |
2 changes: 1 addition & 1 deletion
2
...nces/es6/destructuring/emptyAssignmentPatterns04_ES6/input.ts/es2015.2.minified/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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
var a; | ||
let a1, a2, a3; | ||
let x, y, z, a1, a2, a3; | ||
({ x , y , z } = {} = a), [a1, a2, a3] = [] = a; |
2 changes: 1 addition & 1 deletion
2
.../es6/destructuring/restElementWithAssignmentPattern2/input.ts/es2015.2.minified/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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
var a; | ||
var a, b; | ||
[...{ 0: a = "" , b }] = [ | ||
"", | ||
1 | ||
|
2 changes: 1 addition & 1 deletion
2
...ces/es6/destructuring/restElementWithAssignmentPattern2/input.ts/es5.2.minified/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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
var a; | ||
var a, b; | ||
({ 0: a = "" , b } = [ | ||
"", | ||
1 | ||
|
2 changes: 1 addition & 1 deletion
2
.../es6/destructuring/restElementWithAssignmentPattern4/input.ts/es2015.2.minified/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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
var a; | ||
var a, b; | ||
[...{ 0: a = "" , b }] = [ | ||
"", | ||
1 | ||
|
2 changes: 1 addition & 1 deletion
2
...c/tests/tsc-references/es6/for-ofStatements/for-of47/input.ts/es2015.2.minified/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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
var y, E, E1; | ||
var x, y, E, E1; | ||
for ({ x , y: y = E.x } of ((E1 = E || (E = { | ||
}))[E1.x = 0] = "x", [ | ||
{ | ||
|
2 changes: 1 addition & 1 deletion
2
...c/tests/tsc-references/es6/for-ofStatements/for-of48/input.ts/es2015.2.minified/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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
var E, E1; | ||
var x, y, E, E1; | ||
for ({ x , y =E.x } of ((E1 = E || (E = { | ||
}))[E1.x = 0] = "x", [ | ||
{ | ||
|
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
7 changes: 4 additions & 3 deletions
7
crates/swc/tests/tsc-references/salsa/commonJSReexport/input.ts/es2015.2.minified/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
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
2 changes: 1 addition & 1 deletion
2
.../tsc-references/types/spread/objectSpreadNoTransform/input.ts/es2015.2.minified/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
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
34 changes: 34 additions & 0 deletions
34
crates/swc_ecma_minifier/tests/compress/fixture/issues/next-30498/1/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,34 @@ | ||
function string_create() { | ||
return new StringSchema(); | ||
} | ||
class StringSchema extends BaseSchema { | ||
|
||
matches(regex, options) { | ||
let excludeEmptyString = false; | ||
let message; | ||
let name; | ||
|
||
if (options) { | ||
if (typeof options === 'object') { | ||
({ | ||
excludeEmptyString = false, | ||
message, | ||
name | ||
} = options); | ||
} else { | ||
message = options; | ||
} | ||
} | ||
|
||
return this.test({ | ||
name: name || 'matches', | ||
message: message || string.matches, | ||
params: { | ||
regex | ||
}, | ||
test: value => isAbsent(value) || value === '' && excludeEmptyString || value.search(regex) !== -1 | ||
}); | ||
} | ||
|
||
} | ||
string_create.prototype = StringSchema.prototype; |
16 changes: 16 additions & 0 deletions
16
crates/swc_ecma_minifier/tests/compress/fixture/issues/next-30498/1/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,16 @@ | ||
class StringSchema extends BaseSchema { | ||
matches(regex, options) { | ||
let excludeEmptyString = !1, message, name; | ||
return options && ("object" == typeof options ? { excludeEmptyString =!1 , message , name } = options : message = options), this.test({ | ||
name: name || "matches", | ||
message: message || string.matches, | ||
params: { | ||
regex | ||
}, | ||
test: (value)=>isAbsent(value) || "" === value && excludeEmptyString || -1 !== value.search(regex) | ||
}); | ||
} | ||
} | ||
(function() { | ||
return new StringSchema(); | ||
}).prototype = StringSchema.prototype; |
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,34 @@ | ||
function string_create() { | ||
return new StringSchema(); | ||
} | ||
class StringSchema extends BaseSchema { | ||
|
||
matches(regex, options) { | ||
let excludeEmptyString = false; | ||
let message; | ||
let name; | ||
|
||
if (options) { | ||
if (typeof options === 'object') { | ||
({ | ||
excludeEmptyString = false, | ||
message, | ||
name | ||
} = options); | ||
} else { | ||
message = options; | ||
} | ||
} | ||
|
||
return this.test({ | ||
name: name || 'matches', | ||
message: message || string.matches, | ||
params: { | ||
regex | ||
}, | ||
test: value => isAbsent(value) || value === '' && excludeEmptyString || value.search(regex) !== -1 | ||
}); | ||
} | ||
|
||
} | ||
string_create.prototype = StringSchema.prototype; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.