* @param {Buffer} value * @param {{url: string, [x: string]: unknown}} context * @param {Function} defaultTransformSource
(value, context, defaultTransformSource)
| 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…