-
Notifications
You must be signed in to change notification settings - Fork 27.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: HMR not works when
assetPrefix
set to URL (#68622)
- Loading branch information
1 parent
604e68a
commit 01a3f98
Showing
5 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
test/development/app-dir/hmr-asset-prefix-full-url/app/layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function Root({ children }) { | ||
return ( | ||
<html> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
3 changes: 3 additions & 0 deletions
3
test/development/app-dir/hmr-asset-prefix-full-url/app/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Page() { | ||
return <p>before edit</p> | ||
} |
32 changes: 32 additions & 0 deletions
32
test/development/app-dir/hmr-asset-prefix-full-url/asset-prefix.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { createNext } from 'e2e-utils' | ||
import { findPort, retry } from 'next-test-utils' | ||
|
||
describe('app-dir assetPrefix full URL', () => { | ||
let next, forcedPort | ||
beforeAll(async () => { | ||
forcedPort = ((await findPort()) ?? '54321').toString() | ||
|
||
next = await createNext({ | ||
files: __dirname, | ||
forcedPort, | ||
nextConfig: { | ||
assetPrefix: `http://localhost:${forcedPort}`, | ||
}, | ||
}) | ||
}) | ||
afterAll(() => next.destroy()) | ||
|
||
it('should not break HMR when asset prefix set to full URL', async () => { | ||
const browser = await next.browser('/') | ||
const text = await browser.elementByCss('p').text() | ||
expect(text).toBe('before edit') | ||
|
||
await next.patchFile('app/page.tsx', (content) => { | ||
return content.replace('before', 'after') | ||
}) | ||
|
||
await retry(async () => { | ||
expect(await browser.elementByCss('p').text()).toContain('after edit') | ||
}) | ||
}) | ||
}) |