6d4f263121
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)
18 lines
498 B
TypeScript
18 lines
498 B
TypeScript
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)()
|
|
}
|