Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(es/common): Introduce pure Span and BytePos to handle #__PURE__ #9539

Merged
merged 18 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion crates/swc/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ impl<'a, 'b, P: swc_ecma_visit::Fold> PassBuilder<'a, 'b, P> {
),
Optional::new(
compat::es2022::es2022(
comments,
compat::es2022::Config {
class_properties: compat::es2022::class_properties::Config {
private_as_properties: assumptions.private_fields_as_properties,
Expand Down
4 changes: 0 additions & 4 deletions crates/swc/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1329,7 +1329,6 @@ impl ModuleConfig {
unresolved_mark,
config,
available_features,
comments,
))
} else {
let resolver = build_resolver(base_url, paths, config.resolve_fully);
Expand All @@ -1339,7 +1338,6 @@ impl ModuleConfig {
unresolved_mark,
config,
available_features,
comments,
))
}
}
Expand All @@ -1350,7 +1348,6 @@ impl ModuleConfig {
unresolved_mark,
config,
available_features,
comments,
))
} else {
let resolver = build_resolver(base_url, paths, config.config.resolve_fully);
Expand All @@ -1362,7 +1359,6 @@ impl ModuleConfig {
unresolved_mark,
config,
available_features,
comments,
))
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/issues-5xxx/5272/1/output/a.map
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"mappings": ";;;+BACaA;;;eAAAA;;;;;;;oBADQ;AACd,IAAA,AAAMA,oBAAD,AAAL;;gBAAMA;aAAAA;kCAAAA;mCAAAA;;oBAAAA;;YACTC,KAAAA;mBAAAA,SAAAA;gBACI,OAAO,IAAI,IAAI,CAACC,GAAG;YACvB;;;WAHSF;EAAYG,UAAI",
"mappings": ";;;+BACaA;;;eAAAA;;;;;;;oBADQ;AACd,IAAA,AAAMA,oBAAN;;gBAAMA;aAAAA;kCAAAA;mCAAAA;;oBAAAA;;YACTC,KAAAA;mBAAAA,SAAAA;gBACI,OAAO,IAAI,IAAI,CAACC,GAAG;YACvB;;;WAHSF;EAAYG,UAAI",
"names": [
"Foo",
"bar",
Expand Down
4 changes: 2 additions & 2 deletions crates/swc/tests/fixture/issues-8xxx/8375/1/output/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ Object.defineProperty(exports, "__esModule", {
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _hello = require("./src/hello");
const _node = _interop_require_wildcard._(require("@sentry/node"));
const _node = /*#__PURE__*/ _interop_require_wildcard._(require("@sentry/node"));
magic-akari marked this conversation as resolved.
Show resolved Hide resolved
_node;
(0, _hello.helloWorld)("SWC"); /*#__PURE__*/
(0, _hello.helloWorld)("SWC");
16 changes: 8 additions & 8 deletions crates/swc/tests/fixture/issues-9xxx/9527/output/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var Base = function Base() {
};
;
expect(function() {
return new /*#__PURE__*/ (function(Base) {
return new /*#__PURE__*/ (/*#__PURE__*/ function(Base) {
magic-akari marked this conversation as resolved.
Show resolved Hide resolved
"use strict";
_inherits._(_class, Base);
function _class() {
Expand All @@ -24,7 +24,7 @@ expect(function() {
}(Base));
}).toThrow();
expect(function() {
return new /*#__PURE__*/ (function(Base) {
return new /*#__PURE__*/ (/*#__PURE__*/ function(Base) {
"use strict";
_inherits._(_class, Base);
function _class() {
Expand All @@ -39,7 +39,7 @@ expect(function() {
}(Base));
}).toThrow();
expect(function() {
return new /*#__PURE__*/ (function(Base) {
return new /*#__PURE__*/ (/*#__PURE__*/ function(Base) {
"use strict";
_inherits._(_class, Base);
function _class() {
Expand All @@ -55,7 +55,7 @@ expect(function() {
}(Base));
}).toThrow();
expect(function() {
return new /*#__PURE__*/ (function(Base) {
return new /*#__PURE__*/ (/*#__PURE__*/ function(Base) {
"use strict";
_inherits._(_class, Base);
function _class() {
Expand All @@ -68,7 +68,7 @@ expect(function() {
}(Base));
}).toThrow();
expect(function() {
return new /*#__PURE__*/ (function(Base) {
return new /*#__PURE__*/ (/*#__PURE__*/ function(Base) {
"use strict";
_inherits._(_class, Base);
function _class() {
Expand All @@ -82,7 +82,7 @@ expect(function() {
}(Base));
}).toThrow();
expect(function() {
return new /*#__PURE__*/ (function(Base) {
return new /*#__PURE__*/ (/*#__PURE__*/ function(Base) {
"use strict";
_inherits._(_class, Base);
function _class() {
Expand All @@ -95,7 +95,7 @@ expect(function() {
}(Base));
}).toThrow();
expect(function() {
return new /*#__PURE__*/ (function(Base) {
return new /*#__PURE__*/ (/*#__PURE__*/ function(Base) {
"use strict";
_inherits._(_class, Base);
function _class() {
Expand All @@ -109,7 +109,7 @@ expect(function() {
}(Base));
}).toThrow();
expect(function() {
return new /*#__PURE__*/ (function(Base) {
return new /*#__PURE__*/ (/*#__PURE__*/ function(Base) {
"use strict";
_inherits._(_class, Base);
function _class() {
Expand Down
8 changes: 4 additions & 4 deletions crates/swc/tests/fixture/issues-9xxx/9527/output/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var Base = function Base() {
_class_call_check._(this, Base);
};
;
new /*#__PURE__*/ (function(Base) {
new /*#__PURE__*/ (/*#__PURE__*/ function(Base) {
"use strict";
_inherits._(_class, Base);
function _class() {
Expand All @@ -17,7 +17,7 @@ new /*#__PURE__*/ (function(Base) {
}
return _class;
}(Base));
new /*#__PURE__*/ (function(Base) {
new /*#__PURE__*/ (/*#__PURE__*/ function(Base) {
"use strict";
_inherits._(_class, Base);
function _class() {
Expand All @@ -29,7 +29,7 @@ new /*#__PURE__*/ (function(Base) {
}
return _class;
}(Base));
new /*#__PURE__*/ (function(Base) {
new /*#__PURE__*/ (/*#__PURE__*/ function(Base) {
"use strict";
_inherits._(_class, Base);
function _class() {
Expand All @@ -41,7 +41,7 @@ new /*#__PURE__*/ (function(Base) {
}
return _class;
}(Base));
new /*#__PURE__*/ (function(Base) {
new /*#__PURE__*/ (/*#__PURE__*/ function(Base) {
"use strict";
_inherits._(_class, Base);
function _class() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//// [ES5SymbolProperty3.ts]
var Symbol;
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
(new /*#__PURE__*/ (function() {
(new /*#__PURE__*/ (/*#__PURE__*/ function() {
magic-akari marked this conversation as resolved.
Show resolved Hide resolved
function C() {
_class_call_check(this, C);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//// [ES5SymbolProperty4.ts]
var Symbol;
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
(new /*#__PURE__*/ (function() {
(new /*#__PURE__*/ (/*#__PURE__*/ function() {
function C() {
_class_call_check(this, C);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//// [ES5SymbolProperty5.ts]
var Symbol;
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
(new /*#__PURE__*/ (function() {
(new /*#__PURE__*/ (/*#__PURE__*/ function() {
function C() {
_class_call_check(this, C);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//// [ES5SymbolProperty6.ts]
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
(new /*#__PURE__*/ (function() {
(new /*#__PURE__*/ (/*#__PURE__*/ function() {
function C() {
_class_call_check(this, C);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//// [ES5SymbolProperty7.ts]
var Symbol;
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
(new /*#__PURE__*/ (function() {
(new /*#__PURE__*/ (/*#__PURE__*/ function() {
function C() {
_class_call_check(this, C);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function _func() {
p
];
case 1:
D = /*#__PURE__*/ _.apply(void 0, [
D = /*#__PURE__*/ _./*#__PURE__*/ apply(void 0, [
_state.sent()
]);
return [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//// [callGenericFunctionWithZeroTypeArguments.ts]
var i, i2;
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
(void 0)(1), new /*#__PURE__*/ (function() {
(void 0)(1), new /*#__PURE__*/ (/*#__PURE__*/ function() {
function C() {
_class_call_check(this, C);
}
return C.prototype.f = function(x) {
return null;
}, C;
}())().f(1), i.f(1), new /*#__PURE__*/ (function() {
}())().f(1), i.f(1), new /*#__PURE__*/ (/*#__PURE__*/ function() {
function C2() {
_class_call_check(this, C2);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//// [callNonGenericFunctionWithTypeArguments.ts]
var i, i2, a, a2;
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
(void 0)(1), new /*#__PURE__*/ (function() {
(void 0)(1), new /*#__PURE__*/ (/*#__PURE__*/ function() {
function C() {
_class_call_check(this, C);
}
return C.prototype.f = function(x) {
return null;
}, C;
}())().f(1), i.f(1), new /*#__PURE__*/ (function() {
}())().f(1), i.f(1), new /*#__PURE__*/ (/*#__PURE__*/ function() {
function C2() {
_class_call_check(this, C2);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { _ as _call_super } from "@swc/helpers/_/_call_super";
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
import { _ as _inherits } from "@swc/helpers/_/_inherits";
new /*#__PURE__*/ (function(Component1) {
new /*#__PURE__*/ (/*#__PURE__*/ function(Component1) {
function C() {
return _class_call_check(this, C), _call_super(this, C, arguments);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//// [classAbstractAsIdentifier.ts]
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
new /*#__PURE__*/ (function() {
new /*#__PURE__*/ (/*#__PURE__*/ function() {
function abstract() {
_class_call_check(this, abstract);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Wagon.circle = function(wagons) {
}, Wagon.prototype.speed = function() {
return this.numberOxen / this.weight();
};
var db = new /*#__PURE__*/ (function(Wagon) {
var db = new /*#__PURE__*/ (/*#__PURE__*/ function(Wagon) {
function Sql() {
var _this;
return _class_call_check(this, Sql), (_this = _call_super(this, Sql)).foonly = 12, _this;
Expand All @@ -29,7 +29,7 @@ db.numberOxen = db.foonly, /*#__PURE__*/ Dragon;
import { _ as _call_super } from "@swc/helpers/_/_call_super";
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
import { _ as _inherits } from "@swc/helpers/_/_inherits";
var c = new /*#__PURE__*/ (function(Wagon1) {
var c = new /*#__PURE__*/ (/*#__PURE__*/ function(Wagon1) {
function Conestoga(drunkOO) {
var _this;
return _class_call_check(this, Conestoga), (_this = _call_super(this, Conestoga, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { _ as _call_super } from "@swc/helpers/_/_call_super";
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
import { _ as _inherits } from "@swc/helpers/_/_inherits";
var c = new /*#__PURE__*/ (function(_superClass) {
var c = new /*#__PURE__*/ (/*#__PURE__*/ function(_superClass) {
function C() {
var _this;
return _class_call_check(this, C), _this = _call_super(this, C, arguments), _this.c = 3, _this;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//// [classExpression5.ts]
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
new /*#__PURE__*/ (function() {
new /*#__PURE__*/ (/*#__PURE__*/ function() {
"use strict";
function _class() {
_class_call_check(this, _class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//// [classExpression5.ts]
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
new /*#__PURE__*/ (function() {
new /*#__PURE__*/ (/*#__PURE__*/ function() {
function _class() {
_class_call_check(this, _class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var C = function C() {
_class_call_check(this, C);
};
(function(param) {
var tmp = param[/*#__PURE__*/ (_class = function(C) {
var tmp = param[(_class = /*#__PURE__*/ function(C) {
"use strict";
_inherits(_class, C);
function _class() {
Expand All @@ -22,7 +22,7 @@ var C = function C() {
})();
var x = "";
(function(param) {
var tmp = param[/*#__PURE__*/ (_class1 = function(C) {
var tmp = param[(_class1 = /*#__PURE__*/ function(C) {
"use strict";
_inherits(_class, C);
function _class() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { _ as _inherits } from "@swc/helpers/_/_inherits";
var _class, _class1, C = function C() {
_class_call_check(this, C);
};
(void 0)[/*#__PURE__*/ ((_class = function(C) {
(void 0)[((_class = /*#__PURE__*/ function(C) {
function _class() {
return _class_call_check(this, _class), _call_super(this, _class, arguments);
}
return _inherits(_class, C), _class;
}(C)).x = 1, _class).x], function(param) {
param[/*#__PURE__*/ ((_class1 = function(C) {
param[((_class1 = /*#__PURE__*/ function(C) {
function _class() {
return _class_call_check(this, _class), _call_super(this, _class, arguments);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//// [genericCallTypeArgumentInference.ts]
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
var i, c = new /*#__PURE__*/ (function() {
var i, c = new /*#__PURE__*/ (/*#__PURE__*/ function() {
function C(t, u) {
_class_call_check(this, C), this.t = t, this.u = u;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { _ as _call_super } from "@swc/helpers/_/_call_super";
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
import { _ as _inherits } from "@swc/helpers/_/_inherits";
var b, d1, d2, i, c = new /*#__PURE__*/ (function() {
var b, d1, d2, i, c = new /*#__PURE__*/ (/*#__PURE__*/ function() {
function C(t, u) {
_class_call_check(this, C), this.t = t, this.u = u;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//// [genericClassWithFunctionTypedMemberArguments.ts]
var ImmediatelyFix, WithCandidates, c, c2, c1, c21;
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
ImmediatelyFix || (ImmediatelyFix = {}), (c = new /*#__PURE__*/ (function() {
ImmediatelyFix || (ImmediatelyFix = {}), (c = new /*#__PURE__*/ (/*#__PURE__*/ function() {
function C() {
_class_call_check(this, C);
}
Expand All @@ -14,7 +14,7 @@ ImmediatelyFix || (ImmediatelyFix = {}), (c = new /*#__PURE__*/ (function() {
return '';
}), c.foo(function(x) {
return '';
}), (c2 = new /*#__PURE__*/ (function() {
}), (c2 = new /*#__PURE__*/ (/*#__PURE__*/ function() {
function C2() {
_class_call_check(this, C2);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//// [indexersInClassType.ts]
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
var r = new /*#__PURE__*/ (function() {
var r = new /*#__PURE__*/ (/*#__PURE__*/ function() {
function C() {
_class_call_check(this, C);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//// [inferringClassMembersFromAssignments7.js]
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
var c = new /*#__PURE__*/ (function() {
var c = new /*#__PURE__*/ (/*#__PURE__*/ function() {
function C() {
_class_call_check(this, C);
var self = this;
Expand Down
Loading
Loading