Next build fails due to webpack errors when using absolute imports in typescript & yarn PnP
open a new terminal in this demo
and run yarn build. the build will fail and give this error:
Failed to compile.
/sandbox/pages/day/index.tsx
ERROR in /sandbox/pages/day/index.tsx(1,22):
1:22 Cannot find module 'components/Test' or its corresponding type declarations.
> 1 | import { Test } from "components/Test";
| ^
2 |
3 | export default function DayPage() {
4 | return (
> Build error occurred
Error: > Build failed because of webpack errors
at build (/sandbox/.yarn/$$virtual/next-virtual-aefe307a8c/0/cache/next-npm-9.4.4-ce2a9d5b44-bcd3b7ade9.zip/node_modules/next/dist/build/index.js:13:917)
to build without webpack errors
We already unshift the resolveplugin to be before the pnp plugin 馃 https://github.com/vercel/next.js/blob/canary/packages/next/build/webpack-config.ts#L1011-L1013
Can you try next@canary just to be sure it wasn't fixed yet. If it still does not work feel free to investigate and apply a fix.
Just tried the canary version and it's working :smile:. Thank you @timneutkens!
Thanks for checking!