Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

feat: support .tsx files with JSX syntax #96

Merged
merged 3 commits into from
Jan 28, 2020

Conversation

ryanwilsonperkin
Copy link
Contributor

@ryanwilsonperkin ryanwilsonperkin commented Jan 18, 2020

Fixes oclif/oclif#309

Provides support for .tsx files that contain JSX syntax in them in an attempt to make oclif compatible with ink and solve vadimdemedes/ink#239

Configures the pattern discovery in the plugin module to also search for .tsx files. Instructs ts-node to use "react" mode when dealing with JSX, based on the options in https://www.typescriptlang.org/docs/handbook/jsx.html

This allows oclif to parse jsx found in .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.
@ryanwilsonperkin
Copy link
Contributor Author

This should just work out of the box, I'm working on an example repo that uses this branch to confirm as much.

@codecov
Copy link

codecov bot commented Jan 18, 2020

Codecov Report

Merging #96 into master will decrease coverage by 66.81%.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #96       +/-   ##
========================================
- Coverage   66.81%    0%   -66.82%     
========================================
  Files           7     2        -5     
  Lines         452    12      -440     
  Branches      127     3      -124     
========================================
- Hits          302     0      -302     
+ Misses        101    12       -89     
+ Partials       49     0       -49
Impacted Files Coverage Δ
src/index.ts 0% <0%> (-100%) ⬇️
src/debug.ts 0% <0%> (-45.46%) ⬇️
src/util.ts
src/config.ts
src/command.ts

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b7c6c78...cdb4876. Read the comment docs.

@@ -75,6 +75,7 @@ function registerTSNode(root: string) {
sourceMap: true,
rootDirs,
typeRoots,
jsx: 'react',
Copy link
Contributor

Choose a reason for hiding this comment

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

jsx: tsconfig.compilerOptions.jsx || 'react' Is anyone going to want to use preserve mode?

https://www.typescriptlang.org/docs/handbook/jsx.html#basic-usage

Copy link
Contributor Author

Choose a reason for hiding this comment

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

preserve mode would typically be used if

  • Your JS environment has native support for JSX syntax
  • You're going to pass it through another transpile step

Since oclif is managing the transpilation here, I don't think it's something that we have to worry about. Anyone who would currently be using JSX with Oclif would have had to put their own transpilation process in front of it anyways, and so would be unaffected.

@RasPhilCo RasPhilCo changed the title Support .tsx files with JSX syntax feat: support .tsx files with JSX syntax Jan 28, 2020
Copy link
Contributor

@RasPhilCo RasPhilCo left a comment

Choose a reason for hiding this comment

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

🏄

@RasPhilCo RasPhilCo merged commit 6c800f2 into oclif:master Jan 28, 2020
@ryanwilsonperkin ryanwilsonperkin deleted the support-tsx branch January 28, 2020 21:58
@endquote
Copy link

endquote commented Feb 6, 2020

What’s the best way to use this in practice? Do I replace the oclif/config dependency with a git URL to get the latest? Or will there be a release?

@RasPhilCo
Copy link
Contributor

I'll release this tomorrow.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Command not found if using ".tsx" extension
3 participants