-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 bugs of the minifier (#2052)
swc_ecma_minifier: - Test mangler using execution test suite. - `mangler`: Preserve `arguments`. - `mangler`: Handle shorthand. (#2051) - `mangler`: Handle object pattern properties. - `precompress`: Don't drop function declarations if the variable with same name is in different scope. (#2011)
- Loading branch information
Showing
804 changed files
with
560 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
55 changes: 55 additions & 0 deletions
55
ecmascript/minifier/tests/compress/fixture/issues/2011/actual/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,55 @@ | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
} | ||
function _defineProperties(target, props) { | ||
for (var i = 0; i < props.length; i++) { | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, descriptor.key, descriptor); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
var ClassA = function ClassA() { | ||
"use strict"; | ||
_classCallCheck(this, ClassA); | ||
}; | ||
module.exports = (function () { | ||
var ClassB = /*#__PURE__*/ function () { | ||
"use strict"; | ||
function ClassB() { | ||
_classCallCheck(this, ClassB); | ||
} | ||
_createClass(ClassB, [ | ||
{ | ||
key: "it", | ||
value: function it() { | ||
this.bb = new ClassB.MyA(); | ||
} | ||
} | ||
]); | ||
return ClassB; | ||
}(); | ||
_defineProperty(ClassB, "MyA", ClassA); | ||
return ClassB; | ||
})(); |
41 changes: 41 additions & 0 deletions
41
ecmascript/minifier/tests/compress/fixture/issues/2011/actual/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,41 @@ | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function"); | ||
} | ||
function _defineProperties(target, props) { | ||
for(var i = 0; i < props.length; i++){ | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0, "value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, descriptor.key, descriptor); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
return protoProps && _defineProperties(Constructor.prototype, protoProps), staticProps && _defineProperties(Constructor, staticProps), Constructor; | ||
} | ||
function _defineProperty(obj, key, value) { | ||
return key in obj ? Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: !0, | ||
configurable: !0, | ||
writable: !0 | ||
}) : obj[key] = value, obj; | ||
} | ||
var ClassA = function ClassA() { | ||
"use strict"; | ||
_classCallCheck(this, ClassA); | ||
}; | ||
module.exports = (function() { | ||
var ClassB = function() { | ||
"use strict"; | ||
function ClassB() { | ||
_classCallCheck(this, ClassB); | ||
} | ||
return _createClass(ClassB, [ | ||
{ | ||
key: "it", | ||
value: function() { | ||
this.bb = new ClassB.MyA(); | ||
} | ||
} | ||
]), ClassB; | ||
}(); | ||
return _defineProperty(ClassB, "MyA", ClassA), ClassB; | ||
})(); |
9 changes: 9 additions & 0 deletions
9
ecmascript/minifier/tests/compress/fixture/issues/2011/reduced/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,9 @@ | ||
class ClassA { } | ||
|
||
module.exports = class ClassB { | ||
static MyA = ClassA; | ||
|
||
it() { | ||
this.bb = new ClassB.MyA(); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
ecmascript/minifier/tests/compress/fixture/issues/2011/reduced/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,8 @@ | ||
class ClassA { | ||
} | ||
module.exports = class ClassB { | ||
static MyA = ClassA; | ||
it() { | ||
this.bb = new ClassB.MyA(); | ||
} | ||
}; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,3 @@ | ||
{ | ||
"defaults": true | ||
} |
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,24 @@ | ||
class ClassA { | ||
constructor() { | ||
console.log('Class A'); | ||
} | ||
} | ||
|
||
const cls = class ClassB { | ||
static MyA = ClassA; | ||
|
||
constructor() { | ||
console.log('Claas B'); | ||
} | ||
|
||
it() { | ||
console.log('method it - start'); | ||
|
||
this.bb = new ClassB.MyA(); | ||
|
||
console.log('method it - end'); | ||
} | ||
} | ||
|
||
|
||
new cls().it(); |
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,3 @@ | ||
{ | ||
"defaults": true | ||
} |
Oops, something went wrong.