-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[docs] Update on-demand docs to avoid DEV JSX runtime #2204
Conversation
The example code above will (since version 2.2) throw an error because `_jsxDEV is not a function`. To avoid that, we need to pass the `development: false` option, so I've updated these docs to do so.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov ReportBase: 100.00% // Head: 100.00% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## main #2204 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 22 22
Lines 2064 2064
=========================================
Hits 2064 2064 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
const code = String(await compile('# hi', {outputFormat: 'function-body' /* …otherOptions */ })) | ||
const code = String(await compile('# hi', { | ||
outputFormat: 'function-body', | ||
development: false, // Avoid use of the jsxDEV runtime |
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.
I’m thinking maybe something like this? It’s a bit annoying, because it’s all very situational.
development: false, // Avoid use of the jsxDEV runtime | |
// development: false, // Use this to avoid use of jsx-dev-runtime during development |
Maybe for the client we can use:
import {run} from '@mdx-js/mdx'
import * as runtime from 'react/jsx-runtime'
import * as devRuntime from 'react/jsx-dev-runtime'
const code = '' // To do: get `code` from server somehow.
const deveopment = process.env.NODE_ENV // To do: determine development mode for your setup.
const {default: Content} = await run(code, development ? devRuntime : runtime)
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 are many more places where run
is shown. Perhaps good to extend what you want to change here, to those places too, as it applies to them too?
const code = String(await compile('# hi', {outputFormat: 'function-body' /* …otherOptions */ })) | ||
const code = String(await compile('# hi', { | ||
outputFormat: 'function-body', | ||
development: false, // Avoid use of the jsxDEV runtime |
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.
development: false, // Avoid use of the jsxDEV runtime | |
development: false, // Generate code for production. |
I’d suggest this: better to document what this does, instead of double negatives.
Alternatively, you can show both dev and prod versions
development: false, // Avoid use of the jsxDEV runtime | |
development: false, // Generate code for production. | |
// developmment: true, // Pass this to generate development code. |
And then use the following below:
import * as runtime from 'react/jsx-runtime' // Production.
// import * as runtime from 'react/jsx-dev-runtime' // Development.
await compile('# hi', {outputFormat: 'function-body' /* …otherOptions */}) | ||
await compile('# hi', { | ||
outputFormat: 'function-body', | ||
development: false, // Avoid use of the jsxDEV runtime |
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.
Same as above
The example code above will (since version 2.2) throw an error because
_jsxDEV is not a function
.To avoid that, we need to pass the
development: false
option, so I've updated these docs to do so.See: #2203