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

Function transformSource

script/load-jsx.js:65–88  ·  view source on GitHub ↗

* @param {Buffer} value * @param {{url: string, [x: string]: unknown}} context * @param {Function} defaultTransformSource

(value, context, defaultTransformSource)

Source from the content-addressed store, hash-verified

63 * @param {Function} defaultTransformSource
64 */
65 async function transformSource(value, context, defaultTransformSource) {
66 const url = new URL(context.url)
67
68 if (!url.pathname.endsWith('.jsx')) {
69 return defaultTransformSource(value, context, defaultTransformSource)
70 }
71
72 const {code, warnings} = await transform(String(value), {
73 format: context.format === 'module' ? 'esm' : 'cjs',
74 loader: 'jsx',
75 sourcefile: fileURLToPath(url),
76 sourcemap: 'both',
77 target: 'esnext'
78 })
79
80 if (warnings) {
81 for (const warning of warnings) {
82 console.log(warning.location)
83 console.log(warning.text)
84 }
85 }
86
87 return {source: code}
88 }
89}

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…