-
-
Notifications
You must be signed in to change notification settings - Fork 3
Add support for the automatic dev runtime #2
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
Conversation
This was discussed in mdx-js/mdx#2035.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
source
is a reference to this
right? Not sure what it’s used for either but presumably it’s something, so if it’s easy to add?
Otherwise: can be a bit more spacious with blank lines between statements but everything looks good!
Oh before we forget: this also needs some docs! |
This comment has been minimized.
This comment has been minimized.
Babel does add it conditionally, but it’s added most of the time. If it’s defined, it’s always |
readme.md
Outdated
If the automatic runtime is used, this compiles JSX into automatic runtime | ||
development mode (`boolean`, default: `false`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the automatic runtime is used, this compiles JSX into automatic runtime | |
development mode (`boolean`, default: `false`). | |
Add location info on where a component originated from (`boolean`, default: | |
`false`). | |
This helps debugging but adds a lot of code that you don’t want in production. | |
Only used when `filePath` is and in the automatic runtime. |
Btw: does React still show somewhat useful info without a filePath
? Maybe we could still do something with line/column without and lift the restriction? Maybe more confusing but potentially we could default to '<source.js>'
or so even?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it doesn’t show anything?
And what if we use '<source.js>'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My screenshot was a bit unclear. This error view replaces what would normally be the part that display component details.
Anyway, showing <source.js>
looks fine. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I’m interested whether you have a screenshot that shows this, because I haven’t seen it yet!
Glad a fake name is somewhat useful!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!
I created the following Next.js page in recma-nextjs-static-props, then tweaked the source parameters:
import { jsxDEV } from 'react/jsx-dev-runtime'
export default function Foo() {
return jsxDEV(
'p',
{ children: 'Hello world!' },
'key',
false,
{
fileName: '/home/remco/Projects/recma-nextjs-static-props/pages/foo.jsx',
lineNumber: 35,
columnNumber: 42,
},
this,
)
}
Using the React devtools chrome extension, it looks like this:
The source copy button copies /home/remco/Projects/recma-nextjs-static-props/pages/foo.jsx:35
to the clipboard. This format can be copied directly into the VSCode file search for example
The Log this component data to the console button logs the following positional data to the console:
With removed positional information, it looks like this:
With a removed filename, it looks like this:
With source
set to undefined, it looks like this:
And just for you, a screenshot with fileName
set to <source.js>
. 😄
Same, if its not too hard, I’m 👍 |
Co-authored-by: Titus <tituswormer@gmail.com>
Co-authored-by: Titus <tituswormer@gmail.com>
Co-authored-by: Titus <tituswormer@gmail.com>
Co-authored-by: Titus <tituswormer@gmail.com>
This way positional info is still present.
Co-authored-by: Titus <tituswormer@gmail.com>
Initial checklist
Description of changes
This was discussed in mdx-js/mdx#2035. The only difference that wasn’t discussed is that the automatic runtime import is also changed from
/jsx-runtime
to/jsx-dev-runtime
.The
source
parameter is still missing, as its meaning is not clear to me. It’s not required anyway, so this should be fine.