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: add tsx support #96

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ var extensions = {
);
},
},
'tsx/dist/cjs/index.cjs',
evenstensberg marked this conversation as resolved.
Show resolved Hide resolved
],
'.cts': ['ts-node/register'],
'.tsx': [
Expand Down Expand Up @@ -498,6 +499,7 @@ var extensions = {
);
},
},
'tsx/dist/cjs/index.cjs',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also add it to:

  • .tsx
  • .cts
  • .mjs - tsx will compile it down to CommonJS; minor caveat is that it won't handle TLA but this caveat exists with any ESM -> CommonJS compiler.

],
'.yaml': 'yaml-hook/register',
'.yml': 'yaml-hook/register',
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"author": "Gulp Team <team@gulpjs.com> (https://gulpjs.com/)",
"contributors": [
"Blaine Bublitz <blaine.bublitz@gmail.com>",
"Tyler Kellen <tyler@sleekcode.net> (http://goingslowly.com/)"
"Tyler Kellen <tyler@sleekcode.net> (http://goingslowly.com/)",
"Even Stensberg <evenstensberg@gmail.com>"
],
"repository": "gulpjs/interpret",
"license": "MIT",
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/ts/5/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"tsx": "^4.7.0"
}
}
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;
13 changes: 13 additions & 0 deletions test/fixtures/tsx/5/data.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export const data: {
trueKey: boolean
falseKey: boolean
subKey: {
subProp: number
}
} = {
trueKey: true,
falseKey: false,
subKey: {
subProp: 1
}
}
5 changes: 5 additions & 0 deletions test/fixtures/tsx/5/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"tsx": "^4.7.0"
}
}
11 changes: 11 additions & 0 deletions test/fixtures/tsx/5/test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @jsx jsx */

import { data } from './data'

const Component = (props: object) => ({ data: props })

function jsx (element: typeof Component, props: object) {
return element(props)
}

export default <Component {...data} />
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ describe('interpret.extensions', function () {
this.skip();
}
}

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

// if (name === '')
this.timeout(0);

var expected;
Expand Down