Skip to content

Add support to @swc-node/register the new version of @swc/register #99

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: Fix tests
From fork codermarcos/interpret
On branch master
Changes to be committed:
	modified:   test/fixtures/swc.js/0/package.json
	new file:   test/fixtures/swc.js/1/package.json
	new file:   test/fixtures/swc.js/1/test.swc.js
	modified:   test/fixtures/swc.jsx/0/package.json
	new file:   test/fixtures/swc.jsx/1/package.json
	new file:   test/fixtures/swc.jsx/1/test.swc.jsx
	modified:   test/fixtures/swc.ts/0/package.json
	new file:   test/fixtures/swc.ts/1/package.json
	new file:   test/fixtures/swc.ts/1/test.swc.ts
	modified:   test/fixtures/swc.tsx/0/package.json
	new file:   test/fixtures/swc.tsx/1/package.json
	new file:   test/fixtures/swc.tsx/1/test.swc.tsx
	modified:   test/fixtures/ts/4/package.json
	new file:   test/fixtures/ts/5/package.json
	new file:   test/fixtures/ts/5/test.ts
	modified:   test/fixtures/tsx/4/package.json
	new file:   test/fixtures/tsx/5/package.json
	new file:   test/fixtures/tsx/5/test.tsx
	modified:   test/index.js
  • Loading branch information
codermarcos committed Mar 28, 2024
commit 94097d216466a3a98064fd0cb4d904d68efa4fcd
2 changes: 1 addition & 1 deletion test/fixtures/swc.js/0/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"@swc/core": "^1.2.110",
"@swc/register": "^0.1.7"
"@swc-node/register": "^1.9.0"
}
}
6 changes: 6 additions & 0 deletions test/fixtures/swc.js/1/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dependencies": {
"@swc/core": "^1.2.110",
"@swc/register": "^0.1.7"
}
}
14 changes: 14 additions & 0 deletions test/fixtures/swc.js/1/test.swc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class Foo {
#x = 1;
#y = 2;
}

export default {
data: {
trueKey: true,
falseKey: false,
subKey: {
subProp: 1,
},
},
};
2 changes: 1 addition & 1 deletion test/fixtures/swc.jsx/0/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"@swc/core": "^1.2.110",
"@swc/register": "^0.1.7"
"@swc-node/register": "^1.9.0"
}
}
6 changes: 6 additions & 0 deletions test/fixtures/swc.jsx/1/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dependencies": {
"@swc/core": "^1.2.110",
"@swc/register": "^0.1.7"
}
}
28 changes: 28 additions & 0 deletions test/fixtures/swc.jsx/1/test.swc.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const React = {
createElement(Component) {
return Component();
},
};

class Foo {
#x = 1;
#y = 2;
}

function Bar() {
const foo = new Foo();

return foo;
}

const a = <Bar />;

export default {
data: {
trueKey: true,
falseKey: false,
subKey: {
subProp: 1,
},
},
};
2 changes: 1 addition & 1 deletion test/fixtures/swc.ts/0/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"@swc/core": "^1.2.110",
"@swc/register": "^0.1.7"
"@swc-node/register": "^1.9.0"
}
}
6 changes: 6 additions & 0 deletions test/fixtures/swc.ts/1/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dependencies": {
"@swc/core": "^1.2.110",
"@swc/register": "^0.1.7"
}
}
14 changes: 14 additions & 0 deletions test/fixtures/swc.ts/1/test.swc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class Foo {
#x: number = 1;
#y: number = 2;
}

export default {
data: {
trueKey: true as boolean,
falseKey: false as boolean,
subKey: {
subProp: 1,
},
},
} as const;
2 changes: 1 addition & 1 deletion test/fixtures/swc.tsx/0/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"@swc/core": "^1.2.110",
"@swc/register": "^0.1.7"
"@swc-node/register": "^1.9.0"
}
}
6 changes: 6 additions & 0 deletions test/fixtures/swc.tsx/1/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dependencies": {
"@swc/core": "^1.2.110",
"@swc/register": "^0.1.7"
}
}
18 changes: 18 additions & 0 deletions test/fixtures/swc.tsx/1/test.swc.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const React = {
createElement(Component: () => any) {
return Component();
},
};

// Test harmony arrow functions.
const Component = () => {
var trueKey: boolean = true;
var falseKey: boolean = false;
var subKey = { subProp: 1 };

// Test harmony object short notation.
return { data: { trueKey, falseKey, subKey } };
};

// Test TSX syntax.
export default <Component />;
2 changes: 1 addition & 1 deletion test/fixtures/ts/4/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"@swc/core": "^1.2.110",
"@swc/register": "^0.1.7"
"@swc-node/register": "^1.9.0"
}
}
6 changes: 6 additions & 0 deletions test/fixtures/ts/5/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dependencies": {
"@swc/core": "^1.2.110",
"@swc/register": "^0.1.7"
}
}
15 changes: 15 additions & 0 deletions test/fixtures/ts/5/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var test = {
data: {
trueKey: true,
falseKey: false,
subKey: {
subProp: 1,
},
},
};

var main = {
default: test,
};

export = main;
2 changes: 1 addition & 1 deletion test/fixtures/tsx/4/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"@swc/core": "^1.2.110",
"@swc/register": "^0.1.7"
"@swc-node/register": "^1.9.0"
}
}
6 changes: 6 additions & 0 deletions test/fixtures/tsx/5/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dependencies": {
"@swc/core": "^1.2.110",
"@swc/register": "^0.1.7"
}
}
18 changes: 18 additions & 0 deletions test/fixtures/tsx/5/test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const React = {
createElement(Component: () => any) {
return Component();
},
};

// Test harmony arrow functions.
const Component = () => {
var trueKey: boolean = true;
var falseKey: boolean = false;
var subKey = { subProp: 1 };

// Test harmony object short notation.
return { data: { trueKey, falseKey, subKey } };
};

// Test TSX syntax.
export default <Component />;
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ describe('interpret.extensions', function () {
}

// Skip any swc test on linux due to https://github.com/swc-project/swc/issues/4107
if (name === '@swc/register' && process.platform === 'linux') {
if ((name === '@swc/register' || '@swc-node/register') && process.platform === 'linux') {
this.skip();
}

Expand Down