Skip to content

Commit 5cb07ab

Browse files
committed
Update docs on development option
1 parent caac5df commit 5cb07ab

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

packages/mdx/lib/plugin/recma-jsx-rewrite.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@
2424
* @property {string} [providerImportSource]
2525
* Place to import a provider from.
2626
* @property {boolean} [development=false]
27-
* Whether to add extra information to error messages in generated code (can
28-
* also be passed in Node.js by setting `NODE_ENV=development`).
27+
* Whether to add extra info to error messages in generated code.
28+
* This also results in the development automatic JSX runtime
29+
* (`/jsx-dev-runtime`, `jsxDEV`) being used, which passes positional info to
30+
* nodes.
31+
* The default can be set to `true` in Node.js through environment variables:
32+
* set `NODE_ENV=development`.
2933
*
3034
* @typedef StackEntry
3135
* @property {Array<string>} objects

packages/mdx/readme.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,10 @@ export default MDXContent
398398

399399
###### `options.development`
400400

401-
Whether to add extra information to error messages in generated code
401+
Whether to add extra info to error messages in generated code
402402
(`boolean?`, default: `false`).
403+
This also results in the development automatic JSX runtime (`/jsx-dev-runtime`,
404+
`jsxDEV`) being used, which passes positional info to nodes.
403405
The default can be set to `true` in Node.js through environment variables: set
404406
`NODE_ENV=development`.
405407

@@ -416,7 +418,7 @@ at runtime:
416418
And a module to evaluate that:
417419

418420
```js
419-
import {promises as fs} from 'node:fs'
421+
import fs from 'node:fs/promises'
420422
import * as runtime from 'react/jsx-runtime'
421423
import {evaluate} from '@mdx-js/mdx'
422424

@@ -441,6 +443,11 @@ But if we change add `development: true` to our example:
441443

442444
```diff
443445
@@ -7,6 +7,6 @@
446+
import fs from 'node:fs/promises'
447+
-import * as runtime from 'react/jsx-runtime'
448+
+import * as runtime from 'react/jsx-dev-runtime'
449+
import {evaluate} from '@mdx-js/mdx'
450+
444451
const path = 'example.mdx'
445452
const value = await fs.readFile(path)
446453
-const MDXContent = (await evaluate({path, value}, runtime)).default

packages/mdx/test/compile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,7 @@ test('compile', async () => {
551551
).value
552552
)
553553
)({})
554+
554555
assert.equal(
555556
// @ts-expect-error React attaches source information on this property,
556557
// but it’s private and untyped.

0 commit comments

Comments
 (0)