Skip to content

Commit

Permalink
Refactor hot-reloader client for app (vercel#41598)
Browse files Browse the repository at this point in the history
Co-authored-by: JJ Kasper <jj@jjsweb.site>
  • Loading branch information
2 people authored and shuding committed Oct 23, 2022
1 parent 90b9ec6 commit dfbc720
Show file tree
Hide file tree
Showing 24 changed files with 3,272 additions and 362 deletions.
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.

0 comments on commit dfbc720

Please sign in to comment.