Skip to content

Commit b8d2fb8

Browse files
authored
feat(es/helpers): Import only used helpers (#4767)
1 parent 5be6661 commit b8d2fb8

File tree

4,894 files changed

+29214
-25169
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

4,894 files changed

+29214
-25169
lines changed

crates/swc/tests/fixture/codegen/comment-1/es5/output/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import * as swcHelpers from "@swc/helpers";
1+
import _to_consumable_array from "@swc/helpers/lib/_to_consumable_array.js";
22
function a(param) {
33
var _b = param.b, b = _b === void 0 ? [] : _b;
44
var t = useMemo(function() {
55
return(// Cmt1
6-
swcHelpers.toConsumableArray(a.slice(0, 1)).concat(// Cmt2
7-
swcHelpers.toConsumableArray(b), // Cmt3
8-
swcHelpers.toConsumableArray(c.slice(1))));
6+
_to_consumable_array(a.slice(0, 1)).concat(// Cmt2
7+
_to_consumable_array(b), // Cmt3
8+
_to_consumable_array(c.slice(1))));
99
}, [
1010
frameworks
1111
]);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"use strict";
2-
var swcHelpers = require("@swc/helpers");
2+
var _interop_require_wildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
33
(async function() {
44
const { displayA } = await Promise.resolve().then(function() {
5-
return swcHelpers.interopRequireWildcard(require("../packages/a/src/index"));
5+
return _interop_require_wildcard(require("../packages/a/src/index"));
66
});
77
console.log(displayA());
88
})();
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import * as swcHelpers from "@swc/helpers";
1+
import _type_of from "@swc/helpers/lib/_type_of.js";
22
var window = "foo";
3-
console.log(typeof window === "undefined" ? "undefined" : swcHelpers.typeOf(window));
3+
console.log(typeof window === "undefined" ? "undefined" : _type_of(window));

crates/swc/tests/fixture/issues-0xxx/846/case1/output/index.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
import * as swcHelpers from "@swc/helpers";
2-
var SomeClass = swcHelpers.decorate([], function(_initialize) {
1+
import _assert_this_initialized from "@swc/helpers/lib/_assert_this_initialized.js";
2+
import _class_call_check from "@swc/helpers/lib/_class_call_check.js";
3+
import _decorate from "@swc/helpers/lib/_decorate.js";
4+
import _get from "@swc/helpers/lib/_get.js";
5+
import _get_prototype_of from "@swc/helpers/lib/_get_prototype_of.js";
6+
import _inherits from "@swc/helpers/lib/_inherits.js";
7+
import _create_super from "@swc/helpers/lib/_create_super.js";
8+
var SomeClass = _decorate([], function(_initialize) {
39
var SomeClass = function SomeClass() {
410
"use strict";
5-
swcHelpers.classCallCheck(this, SomeClass);
11+
_class_call_check(this, SomeClass);
612
_initialize(this);
713
};
814
return {
@@ -19,16 +25,16 @@ var SomeClass = swcHelpers.decorate([], function(_initialize) {
1925
]
2026
};
2127
});
22-
var OtherClass = swcHelpers.decorate([], function(_initialize, _SomeClass1) {
28+
var OtherClass = _decorate([], function(_initialize, _SomeClass1) {
2329
var OtherClass = /*#__PURE__*/ function(_SomeClass) {
2430
"use strict";
25-
swcHelpers.inherits(OtherClass, _SomeClass);
26-
var _super = swcHelpers.createSuper(OtherClass);
31+
_inherits(OtherClass, _SomeClass);
32+
var _super = _create_super(OtherClass);
2733
function OtherClass() {
28-
swcHelpers.classCallCheck(this, OtherClass);
34+
_class_call_check(this, OtherClass);
2935
var _this;
3036
_this = _super.apply(this, arguments);
31-
_initialize(swcHelpers.assertThisInitialized(_this));
37+
_initialize(_assert_this_initialized(_this));
3238
return _this;
3339
}
3440
return OtherClass;
@@ -43,7 +49,7 @@ var OtherClass = swcHelpers.decorate([], function(_initialize, _SomeClass1) {
4349
],
4450
key: "anotherMethod",
4551
value: function anotherMethod() {
46-
swcHelpers.get(swcHelpers.getPrototypeOf(OtherClass.prototype), "someMethod", this).call(this);
52+
_get(_get_prototype_of(OtherClass.prototype), "someMethod", this).call(this);
4753
}
4854
}
4955
]
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import * as swcHelpers from "@swc/helpers";
1+
import _class_call_check from "@swc/helpers/lib/_class_call_check.js";
22
export var Class1 = function Class1(param) {
33
"use strict";
44
var _name = param.name, name = _name === void 0 ? "" : _name;
5-
swcHelpers.classCallCheck(this, Class1);
5+
_class_call_check(this, Class1);
66
console.log(name);
77
};
88
export var Class2 = function Class2(param) {
99
"use strict";
1010
var _name = param.name, name = _name === void 0 ? "" : _name;
11-
swcHelpers.classCallCheck(this, Class2);
11+
_class_call_check(this, Class2);
1212
console.log(name);
1313
};

crates/swc/tests/fixture/issues-1xxx/1160/output/entry.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
"use strict";
2-
var swcHelpers = require("@swc/helpers");
2+
var _ts_decorate = require("@swc/helpers/lib/_ts_decorate.js").default;
3+
var _ts_metadata = require("@swc/helpers/lib/_ts_metadata.js").default;
34
var MyEnum;
45
(function(MyEnum) {
56
MyEnum["x"] = "xxx";
67
MyEnum["y"] = "yyy";
78
})(MyEnum || (MyEnum = {}));
89
class Xpto {
910
}
10-
swcHelpers.__decorate([
11+
_ts_decorate([
1112
Decorator(),
12-
swcHelpers.__metadata("design:type", String)
13+
_ts_metadata("design:type", String)
1314
], Xpto.prototype, "value", void 0);
1415
function Decorator() {
1516
return function(...args) {};

crates/swc/tests/fixture/issues-1xxx/1213/output/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", {
33
value: true
44
});
55
exports.default = void 0;
6-
var swcHelpers = require("@swc/helpers");
7-
var _foo = swcHelpers.interopRequireDefault(require("foo"));
6+
var _interop_require_default = require("@swc/helpers/lib/_interop_require_default.js").default;
7+
var _foo = _interop_require_default(require("foo"));
88
class NotOK {
99
constructor(){
1010
console.log(_foo.default);

crates/swc/tests/fixture/issues-1xxx/1216/case-1/output/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as swcHelpers from "@swc/helpers";
1+
import _async_to_generator from "@swc/helpers/lib/_async_to_generator.js";
22
import regeneratorRuntime from "regenerator-runtime";
33
var source = Math.random() < 2 ? "matilda" : "fred";
44
var details = {
@@ -8,7 +8,7 @@ function request(path) {
88
return _request.apply(this, arguments);
99
}
1010
function _request() {
11-
_request = swcHelpers.asyncToGenerator(regeneratorRuntime.mark(function _callee(path) {
11+
_request = _async_to_generator(regeneratorRuntime.mark(function _callee(path) {
1212
return regeneratorRuntime.wrap(function _callee$(_ctx) {
1313
while(1)switch(_ctx.prev = _ctx.next){
1414
case 0:
@@ -21,7 +21,7 @@ function _request() {
2121
}));
2222
return _request.apply(this, arguments);
2323
}
24-
swcHelpers.asyncToGenerator(regeneratorRuntime.mark(function _callee() {
24+
_async_to_generator(regeneratorRuntime.mark(function _callee() {
2525
var obj;
2626
return regeneratorRuntime.wrap(function _callee$(_ctx) {
2727
while(1)switch(_ctx.prev = _ctx.next){

crates/swc/tests/fixture/issues-1xxx/1216/case-2/output/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as swcHelpers from "@swc/helpers";
1+
import _async_to_generator from "@swc/helpers/lib/_async_to_generator.js";
22
import regeneratorRuntime from "regenerator-runtime";
33
var source = Math.random() < 2 ? "matilda" : "fred";
44
var details = {
@@ -8,7 +8,7 @@ function request(path) {
88
return _request.apply(this, arguments);
99
}
1010
function _request() {
11-
_request = swcHelpers.asyncToGenerator(regeneratorRuntime.mark(function _callee(path) {
11+
_request = _async_to_generator(regeneratorRuntime.mark(function _callee(path) {
1212
return regeneratorRuntime.wrap(function _callee$(_ctx) {
1313
while(1)switch(_ctx.prev = _ctx.next){
1414
case 0:
@@ -21,7 +21,7 @@ function _request() {
2121
}));
2222
return _request.apply(this, arguments);
2323
}
24-
swcHelpers.asyncToGenerator(regeneratorRuntime.mark(function _callee() {
24+
_async_to_generator(regeneratorRuntime.mark(function _callee() {
2525
var obj;
2626
return regeneratorRuntime.wrap(function _callee$(_ctx) {
2727
while(1)switch(_ctx.prev = _ctx.next){
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"use strict";
2-
var swcHelpers = require("@swc/helpers");
3-
var action = swcHelpers.interopRequireWildcard(require("./actions"));
2+
var _interop_require_wildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
3+
var action = _interop_require_wildcard(require("./actions"));
44
console.log(action);
55
console.log(action.foo);

0 commit comments

Comments
 (0)