enhanced-resolve: Webpack 5 pnpapi not found
I’m currently upgrading Next.js to Webpack 5 and running into this issue. When I try and run a serverless build. I’m not sure if this is an enhanced resolve issue or a problem on my side.
Heres the Webpack config. https://github.com/module-federation/next.js/blob/a4653af43d10b67bab77d53943ba27ab155d8c1e/packages/next/build/webpack-config.ts which uses pnp-webpack-plugin
import resolve from 'next/dist/compiled/resolve/index.js'
import path from 'path'
export function resolveRequest(req: string, issuer: string) {
// The `resolve` package is prebuilt through ncc, which prevents
// PnP from being able to inject itself into it. To circumvent
// this, we simply use PnP directly when available.
if (process.versions.pnp) {
const { resolveRequest } = require(`pnpapi`)
return resolveRequest(req, issuer, { considerBuiltins: false })
} else {
const basedir =
issuer.endsWith(path.posix.sep) || issuer.endsWith(path.win32.sep)
? issuer
: path.dirname(issuer)
return resolve.sync(req, { basedir })
}
}
"errors": [
{
"moduleIdentifier": "/Users/zjackson/ramdisk/dev/next.js/node_modules/enhanced-resolve/lib/ResolverFactory.js",
"moduleName": "../../node_modules/enhanced-resolve/lib/ResolverFactory.js",
"loc": "74:11-28",
"message": "Module not found: Error: Can't resolve 'pnpapi' in '/Users/zjackson/ramdisk/dev/next.js/node_modules/enhanced-resolve/lib'"
}
]
}
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 3
- Comments: 18 (9 by maintainers)
webpack@5 support pnp out of box, can you disable
pnp-webpack-plugin
?