11/**
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
163 */
174
185import fs from 'node:fs/promises'
@@ -32,14 +19,6 @@ export function createLoader(options) {
3219 const options_ = options || { }
3320 const { extnames, process} = createFormatAwareProcessors ( options_ )
3421 const regex = extnamesToRegex ( extnames )
35- let fixRuntimeWithoutExportMap = options_ . fixRuntimeWithoutExportMap
36-
37- if (
38- fixRuntimeWithoutExportMap === null ||
39- fixRuntimeWithoutExportMap === undefined
40- ) {
41- fixRuntimeWithoutExportMap = true
42- }
4322
4423 return { load, getFormat, transformSource}
4524
@@ -60,14 +39,8 @@ export function createLoader(options) {
6039 if ( url . protocol === 'file:' && regex . test ( url . pathname ) ) {
6140 const value = await fs . readFile ( url )
6241 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- }
6942
70- return { format : 'module' , shortCircuit : true , source}
43+ return { format : 'module' , shortCircuit : true , source : String ( file ) }
7144 }
7245
7346 return defaultLoad ( href , context , defaultLoad )
@@ -113,13 +86,7 @@ export function createLoader(options) {
11386
11487 if ( url . protocol === 'file:' && regex . test ( url . pathname ) ) {
11588 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 ) }
12390 }
12491
12592 return defaultTransformSource ( value , context , defaultTransformSource )
0 commit comments