diff --git a/docs/guides/mdx-on-demand.mdx b/docs/guides/mdx-on-demand.mdx
index e8b7111f8..33efee3f0 100644
--- a/docs/guides/mdx-on-demand.mdx
+++ b/docs/guides/mdx-on-demand.mdx
@@ -30,10 +30,6 @@ On the server:
import {compile} from '@mdx-js/mdx'
const code = String(await compile('# hi', {
- development: false
- // ^-- Generate code for production.
- // `false` if you use `/jsx-runtime` on client, `true` if you use
- // `/jsx-dev-runtime`.
outputFormat: 'function-body',
/* …otherOptions */
}))
@@ -93,10 +89,6 @@ export default function Page({code}) {
export async function getStaticProps() {
const code = String(
await compile('# hi', {
- development: false,
- // ^-- Generate code for production.
- // `false` if you use `/jsx-runtime` on client, `true` if you use
- // `/jsx-dev-runtime`.
outputFormat: 'function-body',
/* …otherOptions */
})
diff --git a/docs/migrating/v2.mdx b/docs/migrating/v2.mdx
index ed02eaf3e..b955939bb 100644
--- a/docs/migrating/v2.mdx
+++ b/docs/migrating/v2.mdx
@@ -386,7 +386,7 @@ You can update your code as follows:
const components = {/* … */}
const value = '# hi'
- const {default: Content} = await evaluate(value, {...provider, ...runtime, development: false})
+ const {default: Content} = await evaluate(value, {...provider, ...runtime})
export default function () {
return
diff --git a/packages/mdx/lib/condition.node.js b/packages/mdx/lib/condition.node.js
deleted file mode 100644
index 5bf0a4465..000000000
--- a/packages/mdx/lib/condition.node.js
+++ /dev/null
@@ -1,3 +0,0 @@
-import process from 'node:process'
-
-export const development = process.env.NODE_ENV === 'development'
diff --git a/packages/mdx/lib/core.js b/packages/mdx/lib/core.js
index f5d0ac0c8..4ffc60827 100644
--- a/packages/mdx/lib/core.js
+++ b/packages/mdx/lib/core.js
@@ -52,7 +52,6 @@ import {rehypeRecma} from './plugin/rehype-recma.js'
import {rehypeRemoveRaw} from './plugin/rehype-remove-raw.js'
import {remarkMarkAndUnravel} from './plugin/remark-mark-and-unravel.js'
import {nodeTypes} from './node-types.js'
-import {development as defaultDevelopment} from '#condition'
const removedOptions = [
'compilers',
@@ -91,10 +90,6 @@ export function createProcessor(options) {
SourceMapGenerator,
...rest
} = options || {}
- const dev =
- development === null || development === undefined
- ? defaultDevelopment
- : development
let index = -1
while (++index < removedOptions.length) {
@@ -144,13 +139,13 @@ export function createProcessor(options) {
.use(rehypeRecma, {elementAttributeNameCase, stylePropertyNameCase})
.use(recmaDocument, {...rest, outputFormat})
.use(recmaJsxRewrite, {
- development: dev,
+ development,
providerImportSource,
outputFormat
})
if (!jsx) {
- pipeline.use(recmaJsxBuild, {development: dev, outputFormat})
+ pipeline.use(recmaJsxBuild, {development, outputFormat})
}
pipeline.use(recmaStringify, {SourceMapGenerator}).use(recmaPlugins || [])
diff --git a/packages/mdx/package.json b/packages/mdx/package.json
index 00cc3c52a..6ac5b9332 100644
--- a/packages/mdx/package.json
+++ b/packages/mdx/package.json
@@ -37,12 +37,6 @@
"./internal-extnames-to-regex": "./lib/util/extnames-to-regex.js",
"./internal-resolve-evaluate-options": "./lib/util/resolve-evaluate-options.js"
},
- "imports": {
- "#condition": {
- "node": "./lib/condition.node.js",
- "default": "./lib/condition.default.js"
- }
- },
"files": [
"lib/",
"index.d.ts",
diff --git a/packages/mdx/readme.md b/packages/mdx/readme.md
index eb2d420f7..be738b595 100644
--- a/packages/mdx/readme.md
+++ b/packages/mdx/readme.md
@@ -789,8 +789,6 @@ Typically, `import` (or `export … from`) do not work here.
They can be compiled to dynamic `import()` by passing
[`options.useDynamicImport`][usedynamicimport].
-> ☢️ **Danger**: you likely must set `development: boolean`.
-
###### `file`
See [`compile`][compile].
@@ -814,7 +812,7 @@ exceptions:
###### `options.Fragment`
These options are required: `Fragment` always, when `development: true`
-then `jsx` and `jsxs`, when `development: false` then `jsxDEV`.
+then `jsxDEV`, when `development: false` then `jsx` and `jsxs`.
They come from an automatic JSX runtime that you must import yourself.
@@ -823,11 +821,7 @@ They come from an automatic JSX runtime that you must import yourself.
```tsx
import * as runtime from 'react/jsx-runtime'
-const {default: Content} = await evaluate('# hi', {
- development: false,
- ...otherOptions,
- ...runtime
-})
+const {default: Content} = await evaluate('# hi', {...otherOptions, ...runtime})
```
@@ -844,7 +838,6 @@ import * as provider from '@mdx-js/react'
import * as runtime from 'react/jsx-runtime'
const {default: Content} = await evaluate('# hi', {
- development: false,
...otherOptions,
...provider,
...runtime
@@ -868,7 +861,7 @@ Assuming the contents of `example.mdx` from [§ Use][use] was in `file`, then:
import * as runtime from 'react/jsx-runtime'
import {evaluate} from '@mdx-js/mdx'
-console.log(await evaluate(file, {...runtime, development: false}))
+console.log(await evaluate(file, runtime))
```
…yields:
@@ -930,10 +923,7 @@ On the server:
```tsx
import {compile} from '@mdx-js/mdx'
-const code = String(await compile('# hi', {
- development: false,
- outputFormat: 'function-body'
-}))
+const code = String(await compile('# hi', {outputFormat: 'function-body'}))
// To do: send `code` to the client somehow.
```
diff --git a/packages/mdx/lib/condition.default.js b/packages/node-loader/lib/condition.default.js
similarity index 100%
rename from packages/mdx/lib/condition.default.js
rename to packages/node-loader/lib/condition.default.js
diff --git a/packages/node-loader/lib/condition.development.js b/packages/node-loader/lib/condition.development.js
new file mode 100644
index 000000000..799ace68d
--- /dev/null
+++ b/packages/node-loader/lib/condition.development.js
@@ -0,0 +1 @@
+export const development = true
diff --git a/packages/node-loader/lib/index.js b/packages/node-loader/lib/index.js
index 71bd240d4..89d59179d 100644
--- a/packages/node-loader/lib/index.js
+++ b/packages/node-loader/lib/index.js
@@ -6,6 +6,7 @@ import fs from 'node:fs/promises'
import {createFormatAwareProcessors} from '@mdx-js/mdx/internal-create-format-aware-processors'
import {extnamesToRegex} from '@mdx-js/mdx/internal-extnames-to-regex'
import {VFile} from 'vfile'
+import {development as defaultDevelopment} from '#condition'
/**
* Create a loader to handle markdown and MDX.
@@ -17,7 +18,10 @@ import {VFile} from 'vfile'
*/
export function createLoader(options) {
const options_ = options || {}
- const {extnames, process} = createFormatAwareProcessors(options_)
+ const {extnames, process} = createFormatAwareProcessors({
+ development: defaultDevelopment,
+ ...options_
+ })
const regex = extnamesToRegex(extnames)
return {load}
diff --git a/packages/node-loader/package.json b/packages/node-loader/package.json
index 771b5e9e8..76554283a 100644
--- a/packages/node-loader/package.json
+++ b/packages/node-loader/package.json
@@ -30,6 +30,12 @@
"type": "module",
"sideEffects": false,
"exports": "./index.js",
+ "imports": {
+ "#condition": {
+ "development": "./lib/condition.development.js",
+ "default": "./lib/condition.default.js"
+ }
+ },
"files": [
"lib/",
"index.d.ts",