Skip to content
This repository was archived by the owner on Dec 1, 2019. It is now read-only.

Commit 149ce3d

Browse files
stevenrosss-panferov
authored andcommitted
Fixes for Webpack 4, contributes towards #534 (#546)
* Stop fileDependencies being added to compiledFiles * Use new Tapable API in instance.ts * Use new Tapable API in watch-mode.ts
1 parent 30795f7 commit 149ce3d

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

src/instance.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -364,14 +364,14 @@ const filterMtimes = (mtimes: any) => {
364364
}
365365

366366
function setupWatchRun(compiler, instanceName: string) {
367-
compiler.plugin('watch-run', function(watching, callback) {
368-
const instance = resolveInstance(watching.compiler, instanceName)
367+
compiler.hooks.watchRun.tap('at-loader', function (compiler, callback) {
368+
const instance = resolveInstance(compiler, instanceName)
369369
const checker = instance.checker
370370
const watcher =
371-
watching.compiler.watchFileSystem.watcher ||
372-
watching.compiler.watchFileSystem.wfs.watcher
371+
compiler.watchFileSystem.watcher ||
372+
compiler.watchFileSystem.wfs.watcher
373373

374-
const startTime = instance.startTime || watching.startTime
374+
const startTime = instance.startTime || compiler.startTime
375375
const times = filterMtimes(watcher.getTimes())
376376
const lastCompiled = instance.compiledFiles
377377

@@ -442,7 +442,7 @@ function isWatching(compiler: any): WatchMode {
442442
}
443443

444444
function setupAfterCompile(compiler, instanceName, forkChecker = false) {
445-
compiler.plugin('after-compile', function(compilation, callback) {
445+
compiler.hooks.afterCompile.tap('at-loader', function (compilation, callback) {
446446
// Don"t add errors for child compilations
447447
if (compilation.compiler.isChild()) {
448448
callback()
@@ -467,12 +467,7 @@ function setupAfterCompile(compiler, instanceName, forkChecker = false) {
467467
}
468468

469469
const files = instance.checker.getFiles().then(({ files }) => {
470-
const normalized = files.map(file => {
471-
const rpath = path.normalize(file)
472-
instance.compiledFiles[file] = true
473-
return rpath
474-
})
475-
Array.prototype.push.apply(compilation.fileDependencies, normalized)
470+
Array.prototype.push.apply(compilation.fileDependencies, files.map(path.normalize))
476471
})
477472

478473
const timeStart = +new Date()

src/watch-mode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ export const WatchModeSymbol = Symbol('WatchMode')
22

33
export class CheckerPlugin {
44
apply(compiler) {
5-
compiler.plugin('run', function(params, callback) {
5+
compiler.hooks.run.tap('at-loader', function (params, callback) {
66
compiler[WatchModeSymbol] = false
77
callback()
88
})
99

10-
compiler.plugin('watch-run', function(params, callback) {
10+
compiler.hooks.watchRun.tap('at-loader', function (params, callback) {
1111
compiler[WatchModeSymbol] = true
1212
callback()
1313
})

0 commit comments

Comments
 (0)