Unverified Commit c24643ec authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

Only once for the next/head usage in app dir (#44233)

Follow up for #43885

* only warn once for `next/head` usage in the loader
* add `Warning:` prefix
parent e27c7fa6
import { RSC_MODULE_TYPES } from '../../../../shared/lib/constants'
import { warnOnce } from '../../../../shared/lib/utils/warn-once'
import { getRSCModuleType } from '../../../analysis/get-page-static-info'
import { getModuleBuildInfo } from '../get-module-build-info'
const noopHeadPath = require.resolve('next/dist/client/components/noop-head')
export default async function transformSource(
this: any,
source: string,
......@@ -24,5 +27,10 @@ export default async function transformSource(
return callback(null, source, sourceMap)
}
if (noopHeadPath === this.resourcePath) {
warnOnce(
`Warning: You're using \`next/head\` inside app directory, please migrate to \`head.js\`. Checkout https://beta.nextjs.org/docs/api-reference/file-conventions/head for details.`
)
}
return callback(null, source, sourceMap)
}
import { warnOnce } from '../../shared/lib/utils/warn-once'
if (process.env.NODE_ENV !== 'production') {
warnOnce(
`You're using \`next/head\` inside app directory, please migrate to \`head.js\`. Checkout https://beta.nextjs.org/docs/api-reference/file-conventions/head for details.`
)
}
export default function NoopHead() {
return null
}
......@@ -102,12 +102,12 @@ createNextDescribe(
if (globalThis.isNextDev) {
expect(
errors.some(
errors.filter(
(output) =>
output ===
`You're using \`next/head\` inside app directory, please migrate to \`head.js\`. Checkout https://beta.nextjs.org/docs/api-reference/file-conventions/head for details.\n`
)
).toBe(true)
`Warning: You're using \`next/head\` inside app directory, please migrate to \`head.js\`. Checkout https://beta.nextjs.org/docs/api-reference/file-conventions/head for details.\n`
).length
).toBe(1)
const dynamicChunkPath = path.join(
next.testDir,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment