From 6c800f2966f7d1d5846ca7ffda8955b4b2aa6400 Mon Sep 17 00:00:00 2001 From: Ryan Wilson-Perkin Date: Tue, 28 Jan 2020 16:13:00 -0500 Subject: [PATCH] feat: support .tsx files with JSX syntax (#96) * Configure ts-node to transpile JSX for React This allows oclif to parse jsx found in .tsx files. * Allow oclif to discover .tsx files Notably does _not_ add support for .jsx files yet since this will require a separate tool chain to work with something like Babel as a transpiler for JSX in Javascript files. Also ensures that test files that are .tsx are still ignored. --- src/plugin.ts | 4 ++-- src/ts-node.ts | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugin.ts b/src/plugin.ts index 58126d8f..4aef4eed 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -224,8 +224,8 @@ export class Plugin implements IPlugin { } this._debug(`loading IDs from ${this.commandsDir}`) const patterns = [ - '**/*.+(js|ts)', - '!**/*.+(d.ts|test.ts|test.js|spec.ts|spec.js)', + '**/*.+(js|ts|tsx)', + '!**/*.+(d.ts|test.ts|test.js|spec.ts|spec.js)?(x)', ] const ids = globby.sync(patterns, {cwd: this.commandsDir}) .map(file => { diff --git a/src/ts-node.ts b/src/ts-node.ts index ca59cc5f..5af5c394 100644 --- a/src/ts-node.ts +++ b/src/ts-node.ts @@ -75,6 +75,7 @@ function registerTSNode(root: string) { sourceMap: true, rootDirs, typeRoots, + jsx: 'react', }, }) } finally {