Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor hot-reloader client for app #41598

Merged
merged 25 commits into from Oct 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5d6780a
Rename conflicting file
timneutkens Oct 20, 2022
e15c59b
Move client.ts into hot-reloader-client
timneutkens Oct 20, 2022
2dbd736
Remove exports for internal code
timneutkens Oct 20, 2022
9f62312
Refactor websocket connection
timneutkens Oct 20, 2022
7a6aea2
Split out additional hooks
timneutkens Oct 20, 2022
4812dfd
Remove hadRootlayoutError
timneutkens Oct 20, 2022
c00eab8
Disable root layout error test
timneutkens Oct 20, 2022
85b55b0
Remove unused import
timneutkens Oct 20, 2022
4a4f90c
Remove unused import
timneutkens Oct 20, 2022
c61da61
router.refresh when payload is invalid
timneutkens Oct 20, 2022
33002b9
Trigger router.refresh for added and removed page
timneutkens Oct 20, 2022
6836475
Copy acceptance tests for Fast Refresh
timneutkens Oct 20, 2022
6dd1546
Remove initialFiles
timneutkens Oct 20, 2022
4d1f0ff
Port builtins test
timneutkens Oct 20, 2022
17b647a
Port scss test
timneutkens Oct 20, 2022
3d8728c
Port logbox test
timneutkens Oct 20, 2022
ea68713
Port /ReactRefreshLogBoxMisc.test.ts
timneutkens Oct 21, 2022
82a9b71
Add missing use client
timneutkens Oct 21, 2022
d102a23
Port ReactRefreshModule
timneutkens Oct 21, 2022
d767117
Port ReactRefreshRegression
timneutkens Oct 21, 2022
9b88c5c
Port ReactRefreshRequire
timneutkens Oct 21, 2022
eb2369e
Skip failing snapshots
timneutkens Oct 21, 2022
e029856
Update snapshots
timneutkens Oct 21, 2022
c77ded2
Disable for React 17
timneutkens Oct 21, 2022
cb68912
Merge branch 'canary' into add/error-overlay-refactor
ijjk Oct 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 18 additions & 8 deletions packages/next/client/app-index.tsx
Expand Up @@ -8,7 +8,8 @@ import { createFromReadableStream } from 'next/dist/compiled/react-server-dom-we

import measureWebVitals from './performance-relayer'
import { HeadManagerContext } from '../shared/lib/head-manager-context'
import HotReload from './components/react-dev-overlay/hot-reloader'
import HotReload from './components/react-dev-overlay/hot-reloader-client'
import { GlobalLayoutRouterContext } from '../shared/lib/app-router-context'

/// <reference types="react-dom/experimental" />

Expand Down Expand Up @@ -186,15 +187,24 @@ export function hydrate() {
const reactRoot = (ReactDOMClient as any).createRoot(reactRootElement)

reactRoot.render(
<HotReload
assetPrefix={rootLayoutMissingTagsError.assetPrefix}
initialState={{
rootLayoutMissingTagsError: {
missingTags: rootLayoutMissingTagsError.missingTags,
<GlobalLayoutRouterContext.Provider
value={{
tree: rootLayoutMissingTagsError.tree,
changeByServerResponse: () => {},
focusAndScrollRef: {
apply: false,
},
}}
initialTree={rootLayoutMissingTagsError.tree}
/>
>
<HotReload
assetPrefix={rootLayoutMissingTagsError.assetPrefix}
// initialState={{
// rootLayoutMissingTagsError: {
// missingTags: rootLayoutMissingTagsError.missingTags,
// },
// }}
/>
</GlobalLayoutRouterContext.Provider>
)

return
Expand Down
6 changes: 3 additions & 3 deletions packages/next/client/components/app-router.tsx
Expand Up @@ -37,12 +37,12 @@ function urlToUrlWithoutFlightMarker(url: string): URL {
}

const HotReloader:
| typeof import('./react-dev-overlay/hot-reloader').default
| typeof import('./react-dev-overlay/hot-reloader-client').default
| null =
process.env.NODE_ENV === 'production'
? null
: (require('./react-dev-overlay/hot-reloader')
.default as typeof import('./react-dev-overlay/hot-reloader').default)
: (require('./react-dev-overlay/hot-reloader-client')
.default as typeof import('./react-dev-overlay/hot-reloader-client').default)

/**
* Fetch the flight data for the provided url. Takes in the current router state to decide what to render server-side.
Expand Down
71 changes: 0 additions & 71 deletions packages/next/client/components/react-dev-overlay/client.ts

This file was deleted.