Skip to content

Commit

Permalink
tune cond
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Aug 29, 2023
1 parent 07b1507 commit 5c7b01f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/next/src/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2035,7 +2035,7 @@ export default async function getBaseWebpackConfig(
alias: {
// Alias next/head component to noop for RSC
[require.resolve('next/head')]: require.resolve(
'next/dist/client/components/noop'
'next/dist/client/components/noop-head'
),
// Alias next/dynamic
[require.resolve('next/dynamic')]: require.resolve(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { warnOnce } from '../../../../shared/lib/utils/warn-once'
import { getRSCModuleInformation } from '../../../analysis/get-page-static-info'
import { getModuleBuildInfo } from '../get-module-build-info'

const noopComponentPath = require.resolve('next/dist/client/components/noop')
const noopHeadPath = require.resolve('next/dist/client/components/noop-head')
// For edge runtime it will be aliased to esm version by webpack
const MODULE_PROXY_PATH =
'next/dist/build/webpack/loaders/next-flight-loader/module-proxy'
Expand Down Expand Up @@ -91,7 +91,7 @@ export { e${cnt++} as ${ref} };`
}

if (buildInfo.rsc?.type !== RSC_MODULE_TYPES.client) {
if (noopComponentPath === this.resourcePath) {
if (noopHeadPath === this.resourcePath) {
warnOnce(
`Warning: You're using \`next/head\` inside the \`app\` directory, please migrate to the Metadata API. See https://nextjs.org/docs/app/building-your-application/upgrading/app-router-migration#step-3-migrating-nexthead for more details.`
)
Expand Down
3 changes: 3 additions & 0 deletions packages/next/src/client/components/noop-head.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function NoopHead() {
return null
}
3 changes: 0 additions & 3 deletions packages/next/src/client/components/noop.tsx

This file was deleted.

25 changes: 14 additions & 11 deletions packages/next/src/server/dev/hot-reloader-webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1239,19 +1239,22 @@ export default class HotReloader implements NextJsHotReloaderInterface {
// since react bundle is different it will effect the chunk hash.
// So we diff the chunk changes, if there's only new app page chunk joins,
// then we don't trigger a reload by checking pages/_document chunk change.
const chunkNames = new Set(compilation.namedChunks.keys())
const diffChunkNames = difference<string>(
this.serverChunkNames || new Set(),
chunkNames
)
if (this.appDir) {
const chunkNames = new Set(compilation.namedChunks.keys())
const diffChunkNames = difference<string>(
this.serverChunkNames || new Set(),
chunkNames
)

if (
diffChunkNames.length > 0 &&
diffChunkNames.every((chunkName) => chunkName.startsWith('app/'))
) {
return
if (
diffChunkNames.length === 0 ||
diffChunkNames.every((chunkName) => chunkName.startsWith('app/'))
) {
return
}
this.serverChunkNames = chunkNames
}
this.serverChunkNames = chunkNames

this.serverPrevDocumentHash = documentChunk.hash || null

// Notify reload to reload the page, as _document.js was changed (different hash)
Expand Down

0 comments on commit 5c7b01f

Please sign in to comment.