forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move
HtmlContext
(vercel#34482)
The shared utils file included an import from `react` (because it was using `createContext`) which seems to be unnecessary in the Middleware bundle. With this PR and steps vercel#34425 laid out, the bundle size did decrease without breaking functionality. ![image](https://user-images.githubusercontent.com/18369201/154508389-0a813e3e-1e07-4c45-8b71-444cc54a7f9e.png) Fixes vercel#34425 ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `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` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `yarn lint`
- Loading branch information
1 parent
d4eea75
commit eddabd9
Showing
6 changed files
with
85 additions
and
81 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import type { BuildManifest } from '../../server/get-page-files' | ||
import type { NEXT_DATA, MaybeDeferContentHook } from './utils' | ||
|
||
import { createContext } from 'react' | ||
|
||
export type HtmlProps = { | ||
__NEXT_DATA__: NEXT_DATA | ||
dangerousAsPath: string | ||
docComponentsRendered: { | ||
Html?: boolean | ||
Main?: boolean | ||
Head?: boolean | ||
NextScript?: boolean | ||
} | ||
buildManifest: BuildManifest | ||
ampPath: string | ||
inAmpMode: boolean | ||
hybridAmp: boolean | ||
isDevelopment: boolean | ||
dynamicImports: string[] | ||
assetPrefix?: string | ||
canonicalBase: string | ||
headTags: any[] | ||
unstable_runtimeJS?: false | ||
unstable_JsPreload?: false | ||
devOnlyCacheBusterQueryString: string | ||
scriptLoader: { afterInteractive?: string[]; beforeInteractive?: any[] } | ||
locale?: string | ||
disableOptimizedLoading?: boolean | ||
styles?: React.ReactElement[] | React.ReactFragment | ||
head?: Array<JSX.Element | null> | ||
useMaybeDeferContent: MaybeDeferContentHook | ||
crossOrigin?: string | ||
optimizeCss?: boolean | ||
optimizeFonts?: boolean | ||
runtime?: 'edge' | 'nodejs' | ||
} | ||
|
||
export const HtmlContext = createContext<HtmlProps>(null as any) | ||
if (process.env.NODE_ENV !== 'production') { | ||
HtmlContext.displayName = 'HtmlContext' | ||
} |
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