Skip to content

Commit

Permalink
Remove bugfix needed for webpack 4 when webpack 5 is used (vercel#23886)
Browse files Browse the repository at this point in the history
Tobias has fixed the `compiler.hooks.invalid.call()` bug in webpack 5 so this is no longer needed



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added

## 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`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.

## Documentation / Examples

- [ ] Make sure the linting passes
  • Loading branch information
timneutkens authored Apr 11, 2021
1 parent 2c2ac2e commit 2b48670
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"runtimeExecutable": "yarn",
"runtimeArgs": ["run", "debug", "dev", "test/integration/basic"],
"skipFiles": ["<node_internals>/**"],
"outFiles": ["${workspaceFolder}/packages/next/dist/**/*"],
"port": 9229
},
{
Expand Down
14 changes: 8 additions & 6 deletions packages/next/server/on-demand-entry-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { EventEmitter } from 'events'
import { IncomingMessage, ServerResponse } from 'http'
import { join, posix } from 'path'
import { parse } from 'url'
import { webpack } from 'next/dist/compiled/webpack/webpack'
import { webpack, isWebpack5 } from 'next/dist/compiled/webpack/webpack'
import * as Log from '../build/output/log'
import {
normalizePagePath,
Expand Down Expand Up @@ -293,12 +293,14 @@ class Invalidator {
}

this.building = true
// Work around a bug in webpack, calling `invalidate` on Watching.js
// doesn't trigger the invalid call used to keep track of the `.done` hook on multiCompiler
for (const compiler of this.multiCompiler.compilers) {
// @ts-ignore TODO: Check if this is still needed with webpack 5
compiler.hooks.invalid.call()
if (!isWebpack5) {
// Work around a bug in webpack, calling `invalidate` on Watching.js
// doesn't trigger the invalid call used to keep track of the `.done` hook on multiCompiler
for (const compiler of this.multiCompiler.compilers) {
compiler.hooks.invalid.call()
}
}

this.watcher.invalidate()
}

Expand Down

0 comments on commit 2b48670

Please sign in to comment.