mirror of
https://github.com/swc-project/swc.git
synced 2024-11-30 07:03:50 +03:00
fix(es/preset-env): Change order of passes
This commit is contained in:
parent
372f81fd97
commit
7eea95be7a
@ -0,0 +1,11 @@
|
||||
{
|
||||
"env": {
|
||||
"targets": {
|
||||
"ie": "11.0.0"
|
||||
},
|
||||
"mode": "entry",
|
||||
"coreJs": 3,
|
||||
"shippedProposals": true,
|
||||
"bugfixes": true
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
class A {
|
||||
constructor() {
|
||||
this.foo = async () => {
|
||||
this.x();
|
||||
};
|
||||
this.bar = async () => {
|
||||
this.x();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
console.log(A);
|
@ -0,0 +1,31 @@
|
||||
import * as swcHelpers from "@swc/helpers";
|
||||
import regeneratorRuntime from "regenerator-runtime";
|
||||
var A = function A() {
|
||||
"use strict";
|
||||
swcHelpers.classCallCheck(this, A);
|
||||
var _this = this;
|
||||
this.foo = swcHelpers.asyncToGenerator(regeneratorRuntime.mark(function _callee() {
|
||||
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
||||
while(1)switch(_ctx.prev = _ctx.next){
|
||||
case 0:
|
||||
_this.x();
|
||||
case 1:
|
||||
case "end":
|
||||
return _ctx.stop();
|
||||
}
|
||||
}, _callee);
|
||||
}));
|
||||
var _this1 = this;
|
||||
this.bar = swcHelpers.asyncToGenerator(regeneratorRuntime.mark(function _callee() {
|
||||
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
||||
while(1)switch(_ctx.prev = _ctx.next){
|
||||
case 0:
|
||||
_this1.x();
|
||||
case 1:
|
||||
case "end":
|
||||
return _ctx.stop();
|
||||
}
|
||||
}, _callee);
|
||||
}));
|
||||
};
|
||||
console.log(A);
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
"jsc": {
|
||||
"target": "es2015"
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
class A {
|
||||
constructor() {
|
||||
this.foo = async () => {
|
||||
this.x();
|
||||
};
|
||||
this.bar = async () => {
|
||||
this.x();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
console.log(A);
|
@ -0,0 +1,14 @@
|
||||
import * as swcHelpers from "@swc/helpers";
|
||||
class A {
|
||||
constructor(){
|
||||
var _this = this;
|
||||
this.foo = swcHelpers.asyncToGenerator(function*() {
|
||||
_this.x();
|
||||
});
|
||||
var _this1 = this;
|
||||
this.bar = swcHelpers.asyncToGenerator(function*() {
|
||||
_this1.x();
|
||||
});
|
||||
}
|
||||
}
|
||||
console.log(A);
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
"jsc": {
|
||||
"target": "es5"
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
class A {
|
||||
method() {
|
||||
this.foo = async () => {
|
||||
this.x();
|
||||
};
|
||||
this.bar = async () => {
|
||||
this.x();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
console.log(A);
|
@ -0,0 +1,41 @@
|
||||
import * as swcHelpers from "@swc/helpers";
|
||||
import regeneratorRuntime from "regenerator-runtime";
|
||||
var A = /*#__PURE__*/ function() {
|
||||
"use strict";
|
||||
function A() {
|
||||
swcHelpers.classCallCheck(this, A);
|
||||
}
|
||||
swcHelpers.createClass(A, [
|
||||
{
|
||||
key: "method",
|
||||
value: function method() {
|
||||
var _this = this;
|
||||
this.foo = swcHelpers.asyncToGenerator(regeneratorRuntime.mark(function _callee() {
|
||||
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
||||
while(1)switch(_ctx.prev = _ctx.next){
|
||||
case 0:
|
||||
_this.x();
|
||||
case 1:
|
||||
case "end":
|
||||
return _ctx.stop();
|
||||
}
|
||||
}, _callee);
|
||||
}));
|
||||
var _this1 = this;
|
||||
this.bar = swcHelpers.asyncToGenerator(regeneratorRuntime.mark(function _callee() {
|
||||
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
||||
while(1)switch(_ctx.prev = _ctx.next){
|
||||
case 0:
|
||||
_this1.x();
|
||||
case 1:
|
||||
case "end":
|
||||
return _ctx.stop();
|
||||
}
|
||||
}, _callee);
|
||||
}));
|
||||
}
|
||||
}
|
||||
]);
|
||||
return A;
|
||||
}();
|
||||
console.log(A);
|
@ -74,24 +74,6 @@ where
|
||||
}};
|
||||
}
|
||||
|
||||
// Bugfixes
|
||||
let pass = add!(pass, BugfixEdgeDefaultParam, bugfixes::edge_default_param());
|
||||
let pass = add!(
|
||||
pass,
|
||||
BugfixAsyncArrowsInClass,
|
||||
bugfixes::async_arrows_in_class()
|
||||
);
|
||||
let pass = add!(
|
||||
pass,
|
||||
BugfixTaggedTemplateCaching,
|
||||
bugfixes::template_literal_caching()
|
||||
);
|
||||
let pass = add!(
|
||||
pass,
|
||||
BugfixSafariIdDestructuringCollisionInFunctionExpression,
|
||||
bugfixes::safari_id_destructuring_collision_in_function_expression()
|
||||
);
|
||||
|
||||
let pass = {
|
||||
let enable_dot_all_regex = should_enable!(DotAllRegex, false);
|
||||
let enable_named_capturing_groups_regex = should_enable!(NamedCapturingGroupsRegex, false);
|
||||
@ -291,6 +273,24 @@ where
|
||||
);
|
||||
let pass = add!(pass, ReservedWords, es3::reserved_words(c.dynamic_import));
|
||||
|
||||
// Bugfixes
|
||||
let pass = add!(pass, BugfixEdgeDefaultParam, bugfixes::edge_default_param());
|
||||
let pass = add!(
|
||||
pass,
|
||||
BugfixAsyncArrowsInClass,
|
||||
bugfixes::async_arrows_in_class()
|
||||
);
|
||||
let pass = add!(
|
||||
pass,
|
||||
BugfixTaggedTemplateCaching,
|
||||
bugfixes::template_literal_caching()
|
||||
);
|
||||
let pass = add!(
|
||||
pass,
|
||||
BugfixSafariIdDestructuringCollisionInFunctionExpression,
|
||||
bugfixes::safari_id_destructuring_collision_in_function_expression()
|
||||
);
|
||||
|
||||
if c.debug {
|
||||
println!("Targets: {:?}", targets);
|
||||
}
|
||||
|
@ -113,33 +113,35 @@ impl VisitMut for Regenerator {
|
||||
e.visit_mut_children_with(self);
|
||||
|
||||
if let Expr::Fn(FnExpr {
|
||||
ident, function, ..
|
||||
ident,
|
||||
function: function @ Function {
|
||||
is_generator: true, ..
|
||||
},
|
||||
..
|
||||
}) = e
|
||||
{
|
||||
if function.is_generator {
|
||||
let marked = ident.clone().unwrap_or_else(|| private_ident!("_callee"));
|
||||
let ident = self.visit_mut_fn(
|
||||
Some(ident.take().unwrap_or_else(|| marked.clone())),
|
||||
marked,
|
||||
function,
|
||||
);
|
||||
let marked = ident.clone().unwrap_or_else(|| private_ident!("_callee"));
|
||||
let ident = self.visit_mut_fn(
|
||||
Some(ident.take().unwrap_or_else(|| marked.clone())),
|
||||
marked,
|
||||
function,
|
||||
);
|
||||
|
||||
*e = Expr::Call(CallExpr {
|
||||
span: DUMMY_SP,
|
||||
callee: self
|
||||
.regenerator_runtime
|
||||
.clone()
|
||||
.unwrap()
|
||||
.make_member(quote_ident!("mark"))
|
||||
.as_callee(),
|
||||
args: vec![FnExpr {
|
||||
ident,
|
||||
function: function.take(),
|
||||
}
|
||||
.as_arg()],
|
||||
type_args: None,
|
||||
});
|
||||
}
|
||||
*e = Expr::Call(CallExpr {
|
||||
span: DUMMY_SP,
|
||||
callee: self
|
||||
.regenerator_runtime
|
||||
.clone()
|
||||
.unwrap()
|
||||
.make_member(quote_ident!("mark"))
|
||||
.as_callee(),
|
||||
args: vec![FnExpr {
|
||||
ident,
|
||||
function: function.take(),
|
||||
}
|
||||
.as_arg()],
|
||||
type_args: None,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user