idyll-lang / idyll

Create explorable explanations and interactive essays.
http://idyll-lang.org/
MIT License
2.01k stars 87 forks source link

Add support for Typescript based React components #788

Open jimidle opened 2 years ago

jimidle commented 2 years ago

Is your feature request related to a problem? Please describe. Many graphical components are now written using typescript .tsx, and it can be awkward to create components that interface to them from .js - though I admit that a better React programmer than I am may find that to be fairly trivial.

Describe the solution you'd like Add support for components written in Typescript, with a few examples like the d3 examples and one practical interface such as one of the React graphing libraries.

Describe alternatives you've considered Learning how to interact with external tsx based components using .js.

Additional context Everything seems to be written using Typescript now and Idyll is a little behind. It would definitely be an upgrade to support .tsx based components.

mathisonian commented 2 years ago

Agreed this would be a nice thing to support. Under the hood Idyll uses esbuild, which does have support for loading typescript files. I believe we would need to update our component resolution logic to accept .ts or .tsx files (see here).

I would start by updating the component resolver, and testing if additional configuration changes to the esbuild invocation are needed.

jimidle commented 2 years ago

I have completed this work, but I cannot create a new pull request because the pull request for #748 requires merging first. Perhaps moving to use git flow as system would help with this. I guess that I should have done this myself.

I don't want to cancel the existing pull request and create a new one because then the PR will cover two features, which is not correct.

I will await your approval of the previous PR then I can submit the PR for this one. Github will notify me when you have done this I suspect.

mathisonian commented 2 years ago

I've just merged that PR --- thanks for the work on this!

jimidle commented 2 years ago

No worries - when I take advantage of someone else's good work, I think it is only polite to give a little bit back.