5532b6a93f
Currently if a file or folder (that contains an entry) is renamed in app dir, the dev server will stop working because we never remove the old entry. Since all client entries in app dir are created as child entries programmatically via the RSC plugin, they're different and not handled by our existing hot reloader logic:
f0cbe84e4c/packages/next/src/server/dev/hot-reloader.ts (L666-L677)
This PR adds a file path to child entries as well (it can be layout, page and other entries) so in the entry generation step we can prune the invalid ones.
Fixes #46379, fixes NEXT-650.
## Bug
- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
## Feature
- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] [e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
## Documentation / Examples
- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { createNextDescribe } from 'e2e-utils'
|
|
import { check } from 'next-test-utils'
|
|
|
|
createNextDescribe(
|
|
`app-dir-hmr`,
|
|
{
|
|
files: __dirname,
|
|
},
|
|
({ next }) => {
|
|
describe('filesystem changes', () => {
|
|
it('should not break when renaming a folder', async () => {
|
|
console.log(next.url)
|
|
const browser = await next.browser('/folder')
|
|
const text = await browser.elementByCss('h1').text()
|
|
expect(text).toBe('Hello')
|
|
|
|
// Rename folder
|
|
await next.renameFolder('app/folder', 'app/folder-renamed')
|
|
|
|
try {
|
|
// Should be 404 in a few seconds
|
|
await check(async () => {
|
|
const body = await browser.elementByCss('body').text()
|
|
expect(body).toContain('404')
|
|
return 'success'
|
|
}, 'success')
|
|
|
|
// The new page should be rendered
|
|
const newHTML = await next.render('/folder-renamed')
|
|
expect(newHTML).toContain('Hello')
|
|
} finally {
|
|
// Rename it back
|
|
await next.renameFolder('app/folder-renamed', 'app/folder')
|
|
}
|
|
})
|
|
})
|
|
}
|
|
)
|