Unverified Commit 18f81989 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Prevent node inspect from causing webpack check to fail (#25876)

parent 583b5b9d
...@@ -23,13 +23,21 @@ function reasonMessage(reason: CheckReasons) { ...@@ -23,13 +23,21 @@ function reasonMessage(reason: CheckReasons) {
export async function loadWebpackHook(phase: string, dir: string) { export async function loadWebpackHook(phase: string, dir: string) {
let useWebpack5 = true let useWebpack5 = true
let usesRemovedFlag = false let usesRemovedFlag = false
const worker: any = new Worker( const worker = new Worker(
path.resolve(__dirname, './config-utils-worker.js'), path.resolve(__dirname, './config-utils-worker.js'),
{ {
enableWorkerThreads: false, enableWorkerThreads: false,
numWorkers: 1, numWorkers: 1,
forkOptions: {
env: {
...process.env,
NODE_OPTIONS: '',
},
},
} }
) ) as Worker & {
shouldLoadWithWebpack5: typeof import('./config-utils-worker').shouldLoadWithWebpack5
}
try { try {
const result: CheckResult = await worker.shouldLoadWithWebpack5(phase, dir) const result: CheckResult = await worker.shouldLoadWithWebpack5(phase, dir)
if (result.reason === 'future-flag') { if (result.reason === 'future-flag') {
......
...@@ -19,8 +19,20 @@ jest.setTimeout(1000 * 60 * 5) ...@@ -19,8 +19,20 @@ jest.setTimeout(1000 * 60 * 5)
describe('Configuration', () => { describe('Configuration', () => {
beforeAll(async () => { beforeAll(async () => {
context.output = ''
const handleOutput = (msg) => {
context.output += msg
}
context.appPort = await findPort() context.appPort = await findPort()
context.server = await launchApp(join(__dirname, '../'), context.appPort) context.server = await launchApp(join(__dirname, '../'), context.appPort, {
env: {
NODE_OPTIONS: '--inspect',
},
onStdout: handleOutput,
onStderr: handleOutput,
})
// pre-build all pages at the start // pre-build all pages at the start
await Promise.all([ await Promise.all([
...@@ -40,6 +52,12 @@ describe('Configuration', () => { ...@@ -40,6 +52,12 @@ describe('Configuration', () => {
return cheerio.load(html) return cheerio.load(html)
} }
it('should log webpack version correctly', async () => {
expect(context.output).toContain(
`Using webpack 4. Reason: webpack5 flag is set to false in next.config.js`
)
})
it('should disable X-Powered-By header support', async () => { it('should disable X-Powered-By header support', async () => {
const url = `http://localhost:${context.appPort}/` const url = `http://localhost:${context.appPort}/`
const header = (await fetch(url)).headers.get('X-Powered-By') const header = (await fetch(url)).headers.get('X-Powered-By')
......
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