MCPcopy
hub / github.com/remarkjs/react-markdown / load

Function load

script/load-jsx.js:21–44  ·  view source on GitHub ↗

* @param {string} href * @param {unknown} context * @param {Function} defaultLoad

(href, context, defaultLoad)

Source from the content-addressed store, hash-verified

19 * @param {Function} defaultLoad
20 */
21 async function load(href, context, defaultLoad) {
22 const url = new URL(href)
23
24 if (!url.pathname.endsWith('.jsx')) {
25 return defaultLoad(href, context, defaultLoad)
26 }
27
28 const {code, warnings} = await transform(String(await fs.readFile(url)), {
29 format: 'esm',
30 loader: 'jsx',
31 sourcefile: fileURLToPath(url),
32 sourcemap: 'both',
33 target: 'esnext'
34 })
35
36 if (warnings) {
37 for (const warning of warnings) {
38 console.log(warning.location)
39 console.log(warning.text)
40 }
41 }
42
43 return {format: 'module', shortCircuit: true, source: code}
44 }
45
46 // Pre version 17.
47 /**

Callers

nothing calls this directly

Calls 1

transformFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…