question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Design problem in new JSX transformation

See original GitHub issue

React 17 introduces a new JSX transform. I found there is some problem in the TypeScript implementation

Hi! @weswigham I think this is wrong. You should not treat it as a “base” of the import. It should be a fully qualified import specifier. With the current behavior, it is impossible to make it emit like: import { jsx as _jsx } from “//cdn.example.com/my-jsx-lib/jsx-runtime.js” cause it is not possible to add a “.js” at the end of the import specifier.

This also requires the imported file to name exactly as “jsx-runtime”.

And @weswigham answered me that:

…Yeah, so that wasn’t really my choice - it’s how the react maintainers implemented the same option in the babel transform. (And we just want to match the functionality provided by babel here, without overstepping.) The runtime being accessible at ${source}/jsx-runtime and ${source}/jsx-dev-runtime, based on how the options are presented, is part of the API contract for these endpoints (probably so the import can be swapped between dev/non-dev without explicitly reconfiguring the import? I dunno, I’m guessing.).

So I believe I should post my concerns here. The current interpretation of the option importSource in the babel (or jsxImportSource in TypeScript) are not allowing import {jsx} from '//cdn.example.com/my-jsx-lib/jsx-runtime.js' because it is forcing the end of the import path to be jsx-runtime or jsx-dev-runtime

Maybe I think I should also cc @lunaruan who implemented this in babel

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
lunaruancommented, Sep 25, 2020

Hey, thanks for reporting! It seems like at some point Node will require file extensions be added to ES imports, so we’ll have to fix the import regardless. Will put up a fix for this issue soon.

1reaction
Jack-Workscommented, Oct 1, 2020

I think most of the problem has been resolved. Thanks. But I still want to remove the hardcoded jsx-runtime and jsx-dev-runtime

Read more comments on GitHub >

github_iconTop Results From Across the Web

Support for new JSX transform approach · Issue #37496
I would like support for this new approach to JSX transpilation to be present in TypeScript.
Read more >
How to Use New JSX Transform IN REACT - Aspire Blogs
New JSX Transform in React blog presents what and why new JSX Transform use, JSX advantages, disadvantages and JSX hook examples.
Read more >
Updating JSX transform breaks React - Stack Overflow
When I remove import React from a component, the page crashes with an error (only when rendering that component).
Read more >
Introducing the New JSX Transform – React Blog
Instead of transforming JSX to React.createElement , the new JSX transform automatically imports special functions from those new entry points ...
Read more >
New JSX Enhancements in React 17 - Bits and Pieces
New JSX Transform with React 17 ... When we look at the new react/jsx-runtime it brings a few design changes to avoid the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found