Skip to content

Commit

Permalink
New: Add esbuild-register for typescript extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
hasparus committed Mar 31, 2022
1 parent 57cd597 commit c324303
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ var extensions = {
'typescript-register',
'typescript-require',
'sucrase/register/ts',
'esbuild-register',
{
module: '@babel/register',
register: function(hook) {
Expand All @@ -161,6 +162,7 @@ var extensions = {
'ts-node/register',
'typescript-node/register',
'sucrase/register',
'esbuild-register',
{
module: '@babel/register',
register: function(hook) {
Expand Down
6 changes: 6 additions & 0 deletions test/fixtures/ts/6/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dependencies": {
"esbuild": "^0.14.29",
"esbuild-register": "^3.3.2"
}
}
13 changes: 13 additions & 0 deletions test/fixtures/ts/6/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function add(x: number, y: number): number {
return x + y;
}

export default {
data: {
trueKey: true,
falseKey: false,
subKey: {
subProp: add(0.5, 0.5),
},
},
};
7 changes: 7 additions & 0 deletions test/fixtures/tsx/4/data.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const data = {
trueKey: true,
falseKey: false,
subKey: {
subProp: 1,
},
};
6 changes: 6 additions & 0 deletions test/fixtures/tsx/4/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dependencies": {
"esbuild": "^0.14.29",
"esbuild-register": "^3.3.2"
}
}
11 changes: 11 additions & 0 deletions test/fixtures/tsx/4/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} />;

0 comments on commit c324303

Please sign in to comment.