Skip to content

Commit

Permalink
Ensure async_hooks are not resolved for client (#41778)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Oct 25, 2022
1 parent e7f97c3 commit a090b5c
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/next/build/webpack/loaders/next-app-loader.ts
Expand Up @@ -243,7 +243,7 @@ const nextAppLoader: webpack.LoaderDefinitionFunction<{
export const LayoutRouter = require('next/dist/client/components/layout-router.js').default
export const RenderFromTemplateContext = require('next/dist/client/components/render-from-template-context.js').default
export const staticGenerationAsyncStorage = require('next/dist/client/components/static-generation-async-storage.js').staticGenerationAsyncStorage
export const staticGenerationAsyncStorage = require('next/dist/client/components/static-generation-async-storage').staticGenerationAsyncStorage
export const requestAsyncStorage = require('next/dist/client/components/request-async-storage.js').requestAsyncStorage
export const serverHooks = require('next/dist/client/components/hooks-server-context.js')
Expand Down
@@ -0,0 +1,13 @@
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 = {}
@@ -0,0 +1,4 @@
{
"browser": "./browser.js",
"main": "./node.js"
}
29 changes: 28 additions & 1 deletion packages/next/taskfile.js
Expand Up @@ -2109,7 +2109,11 @@ export async function compile(task, opts) {
],
opts
)
await task.serial(['ncc_react_refresh_utils', 'ncc_next__react_dev_overlay'])
await task.serial([
'ncc_react_refresh_utils',
'ncc_next__react_dev_overlay',
'copy_package_json',
])
}

export async function bin(task, opts) {
Expand Down Expand Up @@ -2196,6 +2200,29 @@ export async function nextbuildjest(task, opts) {
notify('Compiled build/jest files')
}

export async function copy_package_json(task, opts) {
await fs.copy(
join(
__dirname,
'client/components/static-generation-async-storage/package.json'
),
join(
__dirname,
'dist/client/components/static-generation-async-storage/package.json'
)
)
await fs.copy(
join(
__dirname,
'client/components/static-generation-async-storage/package.json'
),
join(
__dirname,
'dist/esm/client/components/static-generation-async-storage/package.json'
)
)
}

export async function client(task, opts) {
await task
.source(opts.src || 'client/**/*.+(js|ts|tsx)')
Expand Down

0 comments on commit a090b5c

Please sign in to comment.