[Appdir] Using app directory inside src directory cause First Load JS shared by all equal 0kb
Verify canary release
- [X] I verified that the issue exists in the latest Next.js canary release
Provide environment information
- Operating System:
- Platform: win32
- Arch: x64
- Version: Windows 10 Home Single Language
- Binaries:
- Node: 18.12.1
- npm: N/A
- Yarn: N/A
- pnpm: 7.15.0
- Relevant packages:
- next: 13.0.3
- eslint-config-next: 13.0.3
- react: 18.2.0
- react-dom: 18.2.0
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
Put app directory inside src directory cause First Load JS shared by all equal 0kb on build
Expected Behavior
First Load JS shared by all not equal 0kb
Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster
https://stackblitz.com/edit/vercel-next-js-m3shiy
To Reproduce
- Init project with create-next-app with --experimental-app flag
- Move both pages and app into src directory
- Run next build
The reason is that the app-build-manifest.json is empty when using a src dir. When using a src dir the entrypoint.name gets named src/app/page here https://github.com/vercel/next.js/blob/canary/packages/next/build/webpack/plugins/build-manifest-plugin.ts#L198, which cuases the regex in getAppRouteFromEntrypoint to not include the file.
The entrypoints are named the same with or without the srcdir when using pages. https://github.com/vercel/next.js/blob/canary/packages/next/build/webpack/plugins/build-manifest-plugin.ts#L198
Probably same issue #42792
I've recently run into this issue myself & has actually caused me to revert my initial PR beginning an incremental migration to the app directory as this it causes all app directory routes in production builds to throw client-side errors when using some Next.js components.
In my case It is mainly being caused by the use of the Link component but I am unsure if this includes / affects other components that require extra JS logic that is not being built.
Stackblitz to reproduce / show the issue
- Run
npm run build - Run
npm run start - Navigate to
/test
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.