1
1
/**
2
- * @typedef {import('@mdx-js/mdx/lib/compile.js').CompileOptions } CompileOptions
3
- */
4
-
5
- /**
6
- * @typedef LoaderOptions
7
- * Extra configuration.
8
- * @property {boolean | null | undefined } [fixRuntimeWithoutExportMap=true]
9
- * Several JSX runtimes, notably React below 18 and Emotion below 11.10.0,
10
- * don’t yet have a proper export map set up (default: `true`).
11
- * Export maps are needed to map `xxx/jsx-runtime` to an actual file in ESM.
12
- * This option fixes React et al by turning those into `xxx/jsx-runtime.js`.
13
- *
14
- * @typedef {CompileOptions & LoaderOptions } Options
15
- * Configuration.
2
+ * @typedef {import('@mdx-js/mdx/lib/compile.js').CompileOptions } Options
16
3
*/
17
4
18
5
import fs from 'node:fs/promises'
@@ -32,14 +19,6 @@ export function createLoader(options) {
32
19
const options_ = options || { }
33
20
const { extnames, process} = createFormatAwareProcessors ( options_ )
34
21
const regex = extnamesToRegex ( extnames )
35
- let fixRuntimeWithoutExportMap = options_ . fixRuntimeWithoutExportMap
36
-
37
- if (
38
- fixRuntimeWithoutExportMap === null ||
39
- fixRuntimeWithoutExportMap === undefined
40
- ) {
41
- fixRuntimeWithoutExportMap = true
42
- }
43
22
44
23
return { load, getFormat, transformSource}
45
24
@@ -60,14 +39,8 @@ export function createLoader(options) {
60
39
if ( url . protocol === 'file:' && regex . test ( url . pathname ) ) {
61
40
const value = await fs . readFile ( url )
62
41
const file = await process ( new VFile ( { value, path : url } ) )
63
- let source = String ( file )
64
-
65
- /* c8 ignore next 3 -- to do: remove. */
66
- if ( fixRuntimeWithoutExportMap ) {
67
- source = String ( file ) . replace ( / \/ j s x - r u n t i m e (? = [ " ' ] ) / , '$&.js' )
68
- }
69
42
70
- return { format : 'module' , shortCircuit : true , source}
43
+ return { format : 'module' , shortCircuit : true , source : String ( file ) }
71
44
}
72
45
73
46
return defaultLoad ( href , context , defaultLoad )
@@ -113,13 +86,7 @@ export function createLoader(options) {
113
86
114
87
if ( url . protocol === 'file:' && regex . test ( url . pathname ) ) {
115
88
const file = await process ( new VFile ( { path : new URL ( context . url ) , value} ) )
116
- let source = String ( file )
117
-
118
- if ( fixRuntimeWithoutExportMap ) {
119
- source = String ( file ) . replace ( / \/ j s x - r u n t i m e (? = [ " ' ] ) / , '$&.js' )
120
- }
121
-
122
- return { source}
89
+ return { source : String ( file ) }
123
90
}
124
91
125
92
return defaultTransformSource ( value , context , defaultTransformSource )
0 commit comments