Open History to see the last commit
1import { load as loadRsc } from 'react-server-dom-webpack/node-loader'
2β
3export { resolve } from 'react-server-dom-webpack/node-loader'
4β
5/** @type {import('node:module').LoadHook} */
6export async function load(url, context, nextLoad) {
7 return loadRsc(url, context, async (specifier, nextContext) => {
8 // React also loads relative source-map URLs through this callback.
9 const result = await nextLoad(new URL(specifier, url).href, nextContext)
10β
11 // React's loader accepts text; Node's default loader can return bytes.
12 if (result.format === 'module' && typeof result.source !== 'string') {
13 return { ...result, source: new TextDecoder().decode(result.source) }
14 }
15β
16 return result
17 })
18}