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

Support new JSX transforms #8440

Closed
kitsonk opened this issue Nov 19, 2020 · 8 comments · Fixed by #12631
Closed

Support new JSX transforms #8440

kitsonk opened this issue Nov 19, 2020 · 8 comments · Fixed by #12631
Assignees
Labels
cli related to cli/ dir feat new feature (which has been agreed to/accepted) swc related to swc (bundling/transpiling)
Milestone

Comments

@kitsonk
Copy link
Contributor

kitsonk commented Nov 19, 2020

React 17 introduced new JSX transforms and they are available in TypeScript 4.1. There are two new options for "jsx" in TypeScript:

  • "react-jsx"
  • "react-jsxdev"

Currently with check these should be supported without any further changes, but are unsupported in --no-check and deno bundle.

We need support from swc before integrating. Ref: swc-project/swc#1103

cc/ @kdy1

@kitsonk kitsonk added feat new feature (which has been agreed to/accepted) cli related to cli/ dir swc related to swc (bundling/transpiling) labels Nov 19, 2020
@ry ry added this to the 1.6.0 milestone Nov 19, 2020
@kitsonk kitsonk modified the milestones: 1.6.0, 1.7.0 Dec 7, 2020
@kitsonk kitsonk mentioned this issue Dec 31, 2020
22 tasks
@lucacasonato lucacasonato modified the milestones: 1.7.0, 1.8.0 Jan 17, 2021
@kitsonk kitsonk modified the milestones: 1.8.0, 1.9.0 Mar 1, 2021
@shadowtime2000
Copy link

It seems support has been added to SWC, just wondering - what exactly is left that is blocking support for this?

@kitsonk
Copy link
Contributor Author

kitsonk commented Mar 6, 2021

A fair amount, as we need to integrate it and test it. It landed too close to 1.8 for us to do the remaining work, so it will likely be in 1.9.

@kitsonk
Copy link
Contributor Author

kitsonk commented Jul 8, 2021

I have kept kicking this down the road, but I have started this now. A couple notes so far...

  • tsc "blindly" take whatever is in --jsxImportSource and appends onto it /react-runtime or /react-dev-runtime. Same behaviour with swc. This causes a bit of a problem, because we always expect specifiers to end in an extension. We can insert some "magic" based on the settings/configuration, but it means we need to add it to the dependency analysis as well, to pickup the @jsxImportSource pragmas.
  • Both tsc and swc support @jsxImportSource pragmas.
  • swc doesn't appear to be changing the import with react-jsxdev setting. I am not 100% sure if that is my code or not, need to investigate more.

@kdy1
Copy link

kdy1 commented Jul 8, 2021

If required, I'm open to accepting a trait to override logic for determining import sources.

@kitsonk
Copy link
Contributor Author

kitsonk commented Jul 8, 2021

If required, I'm open to accepting a trait to override logic for determining import sources.

Thank you. At the moment, swc is "behaving" like I expect. Considering the behaviour is consistent between swc and tsc, it feels like it would be better to have the Deno module graph do the "magical" resolution.

@bartlomieju bartlomieju modified the milestones: 1.12.0, 1.13.0 Jul 13, 2021
@kitsonk
Copy link
Contributor Author

kitsonk commented Jul 19, 2021

Need swc-project/swc#1933 resolved, but there are other challenges beyond that (mostly how to deal with the types when using the transforms).

@kitsonk
Copy link
Contributor Author

kitsonk commented Aug 4, 2021

swc-project/swc#1933 has been fixed now... will get back to this soon-ish

@bartlomieju bartlomieju modified the milestones: 1.13.0, 1.14.0 Aug 11, 2021
@kitsonk kitsonk modified the milestones: 1.14.0, 1.15.0 Sep 3, 2021
@kitsonk
Copy link
Contributor Author

kitsonk commented Sep 3, 2021

Not going to be able to address this for 1.14. There are still some barriers in how we deal with resolving auto-imported specifiers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli related to cli/ dir feat new feature (which has been agreed to/accepted) swc related to swc (bundling/transpiling)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants