Skip to content

Commit 32e0158

Browse files
committed
Add note to node-loader on how to use w/ react 18
1 parent 13a4648 commit 32e0158

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

packages/node-loader/lib/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
*
44
* @typedef LoaderOptions
55
* @property {boolean} [fixRuntimeWithoutExportMap=true]
6-
* Several JSX runtimes, notably React and Emotion, don’t yet have a proper
7-
* export map set up.
6+
* Several JSX runtimes, notably React below 18 and Emotion below 11.10.0,
7+
* don’t yet have a proper export map set up.
88
* Export maps are needed to map `xxx/jsx-runtime` to an actual file in ESM.
99
* This option fixes React et al by turning those into `xxx/jsx-runtime.js`.
1010
*

packages/node-loader/readme.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,24 @@ It also exports the following identifier: `createLoader`.
105105

106106
Create a Node ESM loader to compile MDX to JS.
107107

108-
###### `options`
108+
##### `options`
109109

110110
`options` are the same as [`compile` from `@mdx-js/mdx`][options].
111+
One extra field is supported:
112+
113+
###### `options.fixRuntimeWithoutExportMap`
114+
115+
Fix broken export maps (`boolean`, default: `true`).
116+
117+
Several JSX runtimes, notably React below 18 and Emotion below 11.10.0, don’t
118+
have a proper export map set up.
119+
Export maps are needed to map `xxx/jsx-runtime` to an actual file in ESM.
120+
This option fixes React et al by turning those into `xxx/jsx-runtime.js`.
121+
122+
> 👉 **Note**: If you are using recent React, or other proper packages, you
123+
> have to turn this field off.
124+
> See the example below on how to configure your loader.
125+
> Pass `fixRuntimeWithoutExportMap: false` in options to it.
111126
112127
###### Example
113128

@@ -122,7 +137,7 @@ const {load, getFormat, transformSource} = createLoader(/* Options… */)
122137
export {load, getFormat, transformSource}
123138
```
124139

125-
This example can then be used with `node --experimental-loader=my-loader.js`.
140+
This example can then be used with `node --experimental-loader=./my-loader.js`.
126141

127142
Node itself does not yet support multiple loaders but it is possible to combine
128143
multiple loaders with [`@node-loader/core`][node-loader-core].

0 commit comments

Comments
 (0)