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

Implement new @swc/helpers #7182

Merged
merged 9 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _to_consumable_array from "@swc/helpers/src/_to_consumable_array.mjs";
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
function a(param) {
var _param_b = param.b, b = _param_b === void 0 ? [] : _param_b;
var t = useMemo(function() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ts_generator from "@swc/helpers/src/_ts_generator.mjs";
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
function gen() {
return _ts_generator(this, function(_state) {
switch(_state.label){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
const _interop_require_wildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
(async function() {
const { displayA } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("../packages/a/src/index")));
const { displayA } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard._(require("../packages/a/src/index")));
console.log(displayA());
})();
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import _type_of from "@swc/helpers/src/_type_of.mjs";
import { _ as _type_of } from "@swc/helpers/_/_type_of";
var window = "foo";
console.log(typeof window === "undefined" ? "undefined" : _type_of(window));
8 changes: 4 additions & 4 deletions crates/swc/tests/fixture/interop/babel/output/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ _export(exports, {
y: ()=>y,
default: ()=>_default
});
const _interop_require_default = require("@swc/helpers/lib/_interop_require_default.js").default;
const _interop_require_wildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
const _foo = /*#__PURE__*/ _interop_require_default(require("foo"));
const _bar = /*#__PURE__*/ _interop_require_wildcard(require("bar"));
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _foo = /*#__PURE__*/ _interop_require_default._(require("foo"));
const _bar = /*#__PURE__*/ _interop_require_wildcard._(require("bar"));
const x = {
foo: _foo.default,
bar: _bar.default
Expand Down
10 changes: 5 additions & 5 deletions crates/swc/tests/fixture/interop/node/output/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
x: _,
y: _,
default: _
x: null,
y: null,
default: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
Expand All @@ -18,9 +18,9 @@ _export(exports, {
y: ()=>y,
default: ()=>_default
});
const _interop_require_wildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _foo = require("foo");
const _bar = /*#__PURE__*/ _interop_require_wildcard(require("bar"), true);
const _bar = /*#__PURE__*/ _interop_require_wildcard._(require("bar"), true);
const x = {
foo: _foo,
bar: _bar.default
Expand Down
8 changes: 4 additions & 4 deletions crates/swc/tests/fixture/interop/swc/output/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ _export(exports, {
y: ()=>y,
default: ()=>_default
});
const _interop_require_default = require("@swc/helpers/lib/_interop_require_default.js").default;
const _interop_require_wildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
const _foo = /*#__PURE__*/ _interop_require_default(require("foo"));
const _bar = /*#__PURE__*/ _interop_require_wildcard(require("bar"));
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _foo = /*#__PURE__*/ _interop_require_default._(require("foo"));
const _bar = /*#__PURE__*/ _interop_require_wildcard._(require("bar"));
const x = {
foo: _foo.default,
bar: _bar.default
Expand Down
14 changes: 7 additions & 7 deletions crates/swc/tests/fixture/issues-0xxx/846/case1/output/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import _assert_this_initialized from "@swc/helpers/src/_assert_this_initialized.mjs";
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
import _decorate from "@swc/helpers/src/_decorate.mjs";
import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
import _inherits from "@swc/helpers/src/_inherits.mjs";
import _create_super from "@swc/helpers/src/_create_super.mjs";
import { _ as _assert_this_initialized } from "@swc/helpers/_/_assert_this_initialized";
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
import { _ as _decorate } from "@swc/helpers/_/_decorate";
import { _ as _get } from "@swc/helpers/_/_get";
import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of";
import { _ as _inherits } from "@swc/helpers/_/_inherits";
import { _ as _create_super } from "@swc/helpers/_/_create_super";
var SomeClass = _decorate([], function(_initialize) {
var SomeClass = function SomeClass() {
"use strict";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
export var Class1 = function Class1(param) {
"use strict";
var _param_name = param.name, name = _param_name === void 0 ? "" : _param_name;
Expand Down
4 changes: 2 additions & 2 deletions crates/swc/tests/fixture/issues-1xxx/1135/1/output/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", {
value: true
});
function _ts_decorate() {
const data = require("@swc/helpers/lib/_ts_decorate.js").default;
const data = require("@swc/helpers/_/_ts_decorate");
_ts_decorate = function() {
return data;
};
Expand All @@ -19,6 +19,6 @@ function _module() {
class MyClass extends _module().Class {
async method() {}
}
_ts_decorate()([
_ts_decorate()._([
_module().Class.Decorator()
], MyClass.prototype, "method", null);
12 changes: 6 additions & 6 deletions crates/swc/tests/fixture/issues-1xxx/1160/output/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
const _define_property = require("@swc/helpers/lib/_define_property.js").default;
const _ts_decorate = require("@swc/helpers/lib/_ts_decorate.js").default;
const _ts_metadata = require("@swc/helpers/lib/_ts_metadata.js").default;
const _define_property = require("@swc/helpers/_/_define_property");
const _ts_decorate = require("@swc/helpers/_/_ts_decorate");
const _ts_metadata = require("@swc/helpers/_/_ts_metadata");
var MyEnum;
(function(MyEnum) {
MyEnum["x"] = "xxx";
MyEnum["y"] = "yyy";
})(MyEnum || (MyEnum = {}));
class Xpto {
constructor(){
_define_property(this, "value", void 0);
_define_property._(this, "value", void 0);
}
}
_ts_decorate([
_ts_decorate._([
Decorator(),
_ts_metadata("design:type", String)
_ts_metadata._("design:type", String)
], Xpto.prototype, "value", void 0);
function Decorator() {
return function(...args) {};
Expand Down
4 changes: 2 additions & 2 deletions crates/swc/tests/fixture/issues-1xxx/1213/output/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Object.defineProperty(exports, "default", {
enumerable: true,
get: ()=>NotOK
});
const _interop_require_default = require("@swc/helpers/lib/_interop_require_default.js").default;
const _foo = /*#__PURE__*/ _interop_require_default(require("foo"));
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
const _foo = /*#__PURE__*/ _interop_require_default._(require("foo"));
class OK {
constructor(){
console.log(_foo.default);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs";
import _ts_generator from "@swc/helpers/src/_ts_generator.mjs";
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
var source = Math.random() < 2 ? "matilda" : "fred";
var details = {
_id: "1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs";
import _ts_generator from "@swc/helpers/src/_ts_generator.mjs";
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
var source = Math.random() < 2 ? "matilda" : "fred";
var details = {
_id: "1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ts_generator from "@swc/helpers/src/_ts_generator.mjs";
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
function foo() {
var val, _tmp;
return _ts_generator(this, function(_state) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _define_property from "@swc/helpers/src/_define_property.mjs";
import { _ as _define_property } from "@swc/helpers/_/_define_property";
class Foo {
constructor(){
_define_property(this, "static", 5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
var _interop_require_wildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
var _actions = /*#__PURE__*/ _interop_require_wildcard(require("./actions"));
var _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
var _actions = /*#__PURE__*/ _interop_require_wildcard._(require("./actions"));
console.log(_actions);
console.log(_actions.foo);
4 changes: 2 additions & 2 deletions crates/swc/tests/fixture/issues-1xxx/1259/output/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
var _tagged_template_literal = require("@swc/helpers/lib/_tagged_template_literal.js").default;
var _tagged_template_literal = require("@swc/helpers/_/_tagged_template_literal");
function _templateObject() {
var data = _tagged_template_literal([
var data = _tagged_template_literal._([
"'#ERROR'"
]);
_templateObject = function _templateObject() {
Expand Down
8 changes: 4 additions & 4 deletions crates/swc/tests/fixture/issues-1xxx/1278/output/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
const _ts_decorate = require("@swc/helpers/lib/_ts_decorate.js").default;
const _ts_metadata = require("@swc/helpers/lib/_ts_metadata.js").default;
const _ts_decorate = require("@swc/helpers/_/_ts_decorate");
const _ts_metadata = require("@swc/helpers/_/_ts_metadata");
function MyDecorator(klass) {
return ()=>{
// do something
Expand All @@ -12,8 +12,8 @@ function MyDecorator(klass) {
}
class MyClass {
}
_ts_decorate([
_ts_decorate._([
MyDecorator(MyClass),
_ts_metadata("design:type", String)
_ts_metadata._("design:type", String)
], MyClass.prototype, "prop", void 0);
console.log(new MyClass());
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _define_property from "@swc/helpers/src/_define_property.mjs";
import { _ as _define_property } from "@swc/helpers/_/_define_property";
export class Foo {
nested() {
let Foo = class Foo {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
import _class_private_field_get from "@swc/helpers/src/_class_private_field_get.mjs";
import _class_private_field_init from "@swc/helpers/src/_class_private_field_init.mjs";
import _class_private_field_set from "@swc/helpers/src/_class_private_field_set.mjs";
import _create_class from "@swc/helpers/src/_create_class.mjs";
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
import { _ as _class_private_field_get } from "@swc/helpers/_/_class_private_field_get";
import { _ as _class_private_field_init } from "@swc/helpers/_/_class_private_field_init";
import { _ as _class_private_field_set } from "@swc/helpers/_/_class_private_field_set";
import { _ as _create_class } from "@swc/helpers/_/_create_class";
var _name = /*#__PURE__*/ new WeakMap();
var Animal = /*#__PURE__*/ function() {
"use strict";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
import _class_private_field_get from "@swc/helpers/src/_class_private_field_get.mjs";
import _class_private_field_init from "@swc/helpers/src/_class_private_field_init.mjs";
import _class_private_field_set from "@swc/helpers/src/_class_private_field_set.mjs";
import _create_class from "@swc/helpers/src/_create_class.mjs";
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
import { _ as _class_private_field_get } from "@swc/helpers/_/_class_private_field_get";
import { _ as _class_private_field_init } from "@swc/helpers/_/_class_private_field_init";
import { _ as _class_private_field_set } from "@swc/helpers/_/_class_private_field_set";
import { _ as _create_class } from "@swc/helpers/_/_create_class";
var _name = /*#__PURE__*/ new WeakMap();
var Animal = /*#__PURE__*/ function() {
"use strict";
Expand Down
4 changes: 2 additions & 2 deletions crates/swc/tests/fixture/issues-1xxx/1307/output/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ Object.defineProperty(exports, "foo", {
enumerable: true,
get: ()=>_foo
});
const _interop_require_wildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
const _foo = /*#__PURE__*/ _interop_require_wildcard(require("./foo"));
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _foo = /*#__PURE__*/ _interop_require_wildcard._(require("./foo"));
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
const _class_private_field_get = require("@swc/helpers/lib/_class_private_field_get.js").default;
const _class_private_field_init = require("@swc/helpers/lib/_class_private_field_init.js").default;
const _class_private_field_get = require("@swc/helpers/_/_class_private_field_get");
const _class_private_field_init = require("@swc/helpers/_/_class_private_field_init");
var _ws = /*#__PURE__*/ new WeakMap(), _ws2 = /*#__PURE__*/ new WeakMap();
class Foo {
get connected() {
return _class_private_field_get(this, _ws2) && _class_private_field_get(this, _ws).readyState === _ws1.default.OPEN;
return _class_private_field_get._(this, _ws2) && _class_private_field_get._(this, _ws).readyState === _ws1.default.OPEN;
}
constructor(){
_class_private_field_init(this, _ws, {
_class_private_field_init._(this, _ws, {
writable: true,
value: void 0
});
_class_private_field_init(this, _ws2, {
_class_private_field_init._(this, _ws2, {
writable: true,
value: void 0
});
Expand Down