Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved bundling strategy for the server graph (#40739)
This PR changes the external module resolution to eagerly bundle node_modules, and some specific Next.js internal modules, if on the `WEBPACK_LAYERS.server` layer. While resolving corresponding packages, we use the `react-server` export condition (fallbacks to default). A follow-up PR will be adding a Next.js option to opt-out specific packages from being bundled on the server layer. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a 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` - [x] Integration 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` ## Documentation / Examples - [ ] Make sure the linting passes by running `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
Showing
25 changed files
with
260 additions
and
89 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 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
18 changes: 18 additions & 0 deletions
18
packages/next/client/components/static-generation-async-storage.ts
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,18 @@ | ||
import type { AsyncLocalStorage } from 'async_hooks' | ||
|
||
export interface StaticGenerationStore { | ||
inUse?: boolean | ||
pathname?: string | ||
revalidate?: number | ||
fetchRevalidate?: number | ||
isStaticGeneration?: boolean | ||
} | ||
|
||
export let staticGenerationAsyncStorage: | ||
| AsyncLocalStorage<StaticGenerationStore> | ||
| StaticGenerationStore = {} | ||
|
||
if (process.env.NEXT_RUNTIME !== 'edge' && typeof window === 'undefined') { | ||
staticGenerationAsyncStorage = | ||
new (require('async_hooks').AsyncLocalStorage)() | ||
} |
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.