-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
misc: refactor build context/webpack build step (4/6) (#45458)
Refactoring the ugliness of the previous diff into a more manageable build context. This will let us avoid passing down 10 params at a time. <!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change that you're making: --> ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/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` - [ ] [e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md) ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm build && pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
- Loading branch information
1 parent
074b7e4
commit 0a8a143
Showing
5 changed files
with
285 additions
and
169 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { LoadedEnvFiles } from '@next/env' | ||
import { Ora } from 'next/dist/compiled/ora' | ||
import { Rewrite } from '../lib/load-custom-routes' | ||
import { __ApiPreviewProps } from '../server/api-utils' | ||
import { NextConfigComplete } from '../server/config-shared' | ||
import { Span } from '../trace' | ||
import { TelemetryPlugin } from './webpack/plugins/telemetry-plugin' | ||
|
||
// a global object to store context for the current build | ||
// this is used to pass data between different steps of the build without having | ||
// to pass it through function arguments. | ||
// Not exhaustive, but should be extended to as needed whilst refactoring | ||
export const NextBuildContext: Partial<{ | ||
// core fields | ||
dir: string | ||
buildId: string | ||
config: NextConfigComplete | ||
appDir: string | ||
pagesDir: string | ||
rewrites: { | ||
fallback: Rewrite[] | ||
afterFiles: Rewrite[] | ||
beforeFiles: Rewrite[] | ||
} | ||
loadedEnvFiles: LoadedEnvFiles | ||
previewProps: __ApiPreviewProps | ||
mappedPages: | ||
| { | ||
[page: string]: string | ||
} | ||
| undefined | ||
mappedAppPages: | ||
| { | ||
[page: string]: string | ||
} | ||
| undefined | ||
mappedRootPaths: { | ||
[page: string]: string | ||
} | ||
|
||
// misc fields | ||
telemetryPlugin: TelemetryPlugin | ||
buildSpinner: Ora | ||
nextBuildSpan: Span | ||
|
||
// cli fields | ||
reactProductionProfiling: boolean | ||
noMangling: boolean | ||
appDirOnly: boolean | ||
}> = {} |
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
Oops, something went wrong.