* @param {string} href * @param {unknown} context * @param {Function} defaultLoad
(href, context, defaultLoad)
| 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 | /** |
nothing calls this directly
no test coverage detected
searching dependent graphs…