-
Notifications
You must be signed in to change notification settings - Fork 26.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: exclude _app from _document bundle for pages
- Loading branch information
Showing
10 changed files
with
70 additions
and
29 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
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
This file was deleted.
Oops, something went wrong.
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 NoopComponent() { | ||
return null | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { createNextDescribe } from 'e2e-utils' | ||
import { check } from 'next-test-utils' | ||
|
||
createNextDescribe( | ||
'custom-app-hmr', | ||
{ | ||
files: __dirname, | ||
}, | ||
({ next }) => { | ||
it('should not do full reload when simply editing _app.js', async () => { | ||
const customAppFilePath = 'pages/_app.js' | ||
const browser = await next.browser('/') | ||
await browser.eval('window.hmrConstantValue = "should-not-change"') | ||
|
||
const customAppContent = await next.readFile(customAppFilePath) | ||
const newCustomAppContent = customAppContent.replace( | ||
'hmr text origin', | ||
'hmr text changed' | ||
) | ||
await next.patchFile(customAppFilePath, newCustomAppContent) | ||
|
||
await check(async () => { | ||
const pText = await browser.elementByCss('h1').text() | ||
expect(pText).toBe('hmr text changed') | ||
|
||
// Should keep the value on window, which indicates there's no full reload | ||
const hmrConstantValue = await browser.eval('window.hmrConstantValue') | ||
expect(hmrConstantValue).toBe('should-not-change') | ||
|
||
return 'success' | ||
}, 'success') | ||
|
||
await next.patchFile(customAppFilePath, customAppContent) | ||
await check(async () => { | ||
const pText = await browser.elementByCss('h1').text() | ||
expect(pText).toBe('hmr text origin') | ||
|
||
// Should keep the value on window, which indicates there's no full reload | ||
const hmrConstantValue = await browser.eval('window.hmrConstantValue') | ||
expect(hmrConstantValue).toBe('should-not-change') | ||
|
||
return 'success' | ||
}, 'success') | ||
}) | ||
} | ||
) |
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,8 @@ | ||
export default function App({ Component, pageProps }) { | ||
return ( | ||
<> | ||
<h1>hmr text origin</h1> | ||
<Component {...pageProps} /> | ||
</> | ||
) | ||
} |
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>index page</p> | ||
} |