rsnext/packages/next/server/initialize-require-hook.ts
Jiachi Liu 1fa0068610
Disable esm resolving for appDir and alias react (#41687)
When esm package that depending on react is used between `pages/` and
`app/`, it's loading the user installed react through esm loader which
doesn't go through require hook, so we cannot intercept it with
require-hook.

Disable esm resolving when `appDir` is enabled for now, prefering to
pick the cjs bundle so that react import is intercepted by require hook
and pointing to the built-in react

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-10-23 20:04:23 -07:00

12 lines
202 B
TypeScript

import {
loadRequireHook,
overrideBuiltInReactPackages,
} from '../build/webpack/require-hook'
loadRequireHook()
const isPrebundled = false
if (isPrebundled) {
overrideBuiltInReactPackages()
}