mirror of https://github.com/webpack/webpack.git
track changes and removals correctly
purge filesystem correctly
This commit is contained in:
parent
11e71ed26b
commit
8e9daad216
|
@ -230,6 +230,8 @@ class Compiler {
|
||||||
this.fileTimestamps = undefined;
|
this.fileTimestamps = undefined;
|
||||||
/** @type {Map<string, FileSystemInfoEntry | "ignore" | null>} */
|
/** @type {Map<string, FileSystemInfoEntry | "ignore" | null>} */
|
||||||
this.contextTimestamps = undefined;
|
this.contextTimestamps = undefined;
|
||||||
|
/** @type {number} */
|
||||||
|
this.fsStartTime = undefined;
|
||||||
|
|
||||||
/** @type {ResolverFactory} */
|
/** @type {ResolverFactory} */
|
||||||
this.resolverFactory = new ResolverFactory();
|
this.resolverFactory = new ResolverFactory();
|
||||||
|
@ -952,6 +954,7 @@ ${other}`);
|
||||||
childCompiler.removedFiles = this.removedFiles;
|
childCompiler.removedFiles = this.removedFiles;
|
||||||
childCompiler.fileTimestamps = this.fileTimestamps;
|
childCompiler.fileTimestamps = this.fileTimestamps;
|
||||||
childCompiler.contextTimestamps = this.contextTimestamps;
|
childCompiler.contextTimestamps = this.contextTimestamps;
|
||||||
|
childCompiler.fsStartTime = this.fsStartTime;
|
||||||
childCompiler.cache = this.cache;
|
childCompiler.cache = this.cache;
|
||||||
childCompiler.compilerPath = `${this.compilerPath}${compilerName}|${compilerIndex}|`;
|
childCompiler.compilerPath = `${this.compilerPath}${compilerName}|${compilerIndex}|`;
|
||||||
|
|
||||||
|
|
|
@ -902,7 +902,7 @@ class NormalModule extends Module {
|
||||||
assetsInfo: undefined
|
assetsInfo: undefined
|
||||||
};
|
};
|
||||||
|
|
||||||
const startTime = Date.now();
|
const startTime = compilation.compiler.fsStartTime || Date.now();
|
||||||
|
|
||||||
return this.doBuild(options, compilation, resolver, fs, err => {
|
return this.doBuild(options, compilation, resolver, fs, err => {
|
||||||
// if we have an error mark module as failed and exit
|
// if we have an error mark module as failed and exit
|
||||||
|
|
|
@ -90,9 +90,13 @@ class Watching {
|
||||||
this.running = true;
|
this.running = true;
|
||||||
if (this.watcher) {
|
if (this.watcher) {
|
||||||
this.pausedWatcher = this.watcher;
|
this.pausedWatcher = this.watcher;
|
||||||
|
this.lastWatcherStartTime = Date.now();
|
||||||
this.watcher.pause();
|
this.watcher.pause();
|
||||||
this.watcher = null;
|
this.watcher = null;
|
||||||
|
} else if (!this.lastWatcherStartTime) {
|
||||||
|
this.lastWatcherStartTime = Date.now();
|
||||||
}
|
}
|
||||||
|
this.compiler.fsStartTime = Date.now();
|
||||||
this._mergeWithCollected(
|
this._mergeWithCollected(
|
||||||
changedFiles ||
|
changedFiles ||
|
||||||
(this.pausedWatcher &&
|
(this.pausedWatcher &&
|
||||||
|
@ -104,6 +108,19 @@ class Watching {
|
||||||
this.pausedWatcher.getAggregatedRemovals &&
|
this.pausedWatcher.getAggregatedRemovals &&
|
||||||
this.pausedWatcher.getAggregatedRemovals()))
|
this.pausedWatcher.getAggregatedRemovals()))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.compiler.modifiedFiles = this._collectedChangedFiles;
|
||||||
|
this._collectedChangedFiles = undefined;
|
||||||
|
this.compiler.removedFiles = this._collectedRemovedFiles;
|
||||||
|
this._collectedRemovedFiles = undefined;
|
||||||
|
|
||||||
|
this.compiler.fileTimestamps =
|
||||||
|
fileTimeInfoEntries ||
|
||||||
|
(this.pausedWatcher && this.pausedWatcher.getFileTimeInfoEntries());
|
||||||
|
this.compiler.contextTimestamps =
|
||||||
|
contextTimeInfoEntries ||
|
||||||
|
(this.pausedWatcher && this.pausedWatcher.getContextTimeInfoEntries());
|
||||||
|
|
||||||
const run = () => {
|
const run = () => {
|
||||||
if (this.compiler.idle) {
|
if (this.compiler.idle) {
|
||||||
return this.compiler.cache.endIdle(err => {
|
return this.compiler.cache.endIdle(err => {
|
||||||
|
@ -120,19 +137,6 @@ class Watching {
|
||||||
run();
|
run();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.compiler.modifiedFiles = this._collectedChangedFiles;
|
|
||||||
this._collectedChangedFiles = undefined;
|
|
||||||
this.compiler.removedFiles = this._collectedRemovedFiles;
|
|
||||||
this._collectedRemovedFiles = undefined;
|
|
||||||
|
|
||||||
this.compiler.fileTimestamps =
|
|
||||||
fileTimeInfoEntries ||
|
|
||||||
(this.pausedWatcher && this.pausedWatcher.getFileTimeInfoEntries());
|
|
||||||
this.compiler.contextTimestamps =
|
|
||||||
contextTimeInfoEntries ||
|
|
||||||
(this.pausedWatcher && this.pausedWatcher.getContextTimeInfoEntries());
|
|
||||||
|
|
||||||
this.invalid = false;
|
this.invalid = false;
|
||||||
this._invalidReported = false;
|
this._invalidReported = false;
|
||||||
this.compiler.hooks.watchRun.callAsync(this.compiler, err => {
|
this.compiler.hooks.watchRun.callAsync(this.compiler, err => {
|
||||||
|
@ -295,7 +299,7 @@ class Watching {
|
||||||
files,
|
files,
|
||||||
dirs,
|
dirs,
|
||||||
missing,
|
missing,
|
||||||
this.startTime,
|
this.lastWatcherStartTime,
|
||||||
this.watchOptions,
|
this.watchOptions,
|
||||||
(
|
(
|
||||||
err,
|
err,
|
||||||
|
@ -309,6 +313,7 @@ class Watching {
|
||||||
this.compiler.removedFiles = undefined;
|
this.compiler.removedFiles = undefined;
|
||||||
this.compiler.fileTimestamps = undefined;
|
this.compiler.fileTimestamps = undefined;
|
||||||
this.compiler.contextTimestamps = undefined;
|
this.compiler.contextTimestamps = undefined;
|
||||||
|
this.compiler.fsStartTime = undefined;
|
||||||
return this.handler(err);
|
return this.handler(err);
|
||||||
}
|
}
|
||||||
this._invalidate(
|
this._invalidate(
|
||||||
|
@ -357,6 +362,7 @@ class Watching {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.running) {
|
if (this.running) {
|
||||||
|
this._mergeWithCollected(changedFiles, removedFiles);
|
||||||
this.invalid = true;
|
this.invalid = true;
|
||||||
} else {
|
} else {
|
||||||
this._go(
|
this._go(
|
||||||
|
@ -399,6 +405,7 @@ class Watching {
|
||||||
this.compiler.removedFiles = undefined;
|
this.compiler.removedFiles = undefined;
|
||||||
this.compiler.fileTimestamps = undefined;
|
this.compiler.fileTimestamps = undefined;
|
||||||
this.compiler.contextTimestamps = undefined;
|
this.compiler.contextTimestamps = undefined;
|
||||||
|
this.compiler.fsStartTime = undefined;
|
||||||
const shutdown = () => {
|
const shutdown = () => {
|
||||||
this.compiler.cache.shutdown(err => {
|
this.compiler.cache.shutdown(err => {
|
||||||
this.compiler.hooks.watchClose.call();
|
this.compiler.hooks.watchClose.call();
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
"schema-utils": "^3.0.0",
|
"schema-utils": "^3.0.0",
|
||||||
"tapable": "^2.1.1",
|
"tapable": "^2.1.1",
|
||||||
"terser-webpack-plugin": "^5.1.1",
|
"terser-webpack-plugin": "^5.1.1",
|
||||||
"watchpack": "^2.0.0",
|
"watchpack": "^2.2.0",
|
||||||
"webpack-sources": "^2.1.1"
|
"webpack-sources": "^2.1.1"
|
||||||
},
|
},
|
||||||
"peerDependenciesMeta": {
|
"peerDependenciesMeta": {
|
||||||
|
|
|
@ -1830,6 +1830,7 @@ declare class Compiler {
|
||||||
removedFiles: Set<string>;
|
removedFiles: Set<string>;
|
||||||
fileTimestamps: Map<string, null | FileSystemInfoEntry | "ignore">;
|
fileTimestamps: Map<string, null | FileSystemInfoEntry | "ignore">;
|
||||||
contextTimestamps: Map<string, null | FileSystemInfoEntry | "ignore">;
|
contextTimestamps: Map<string, null | FileSystemInfoEntry | "ignore">;
|
||||||
|
fsStartTime: number;
|
||||||
resolverFactory: ResolverFactory;
|
resolverFactory: ResolverFactory;
|
||||||
infrastructureLogger: any;
|
infrastructureLogger: any;
|
||||||
options: WebpackOptionsNormalized;
|
options: WebpackOptionsNormalized;
|
||||||
|
@ -11453,6 +11454,7 @@ declare abstract class Watching {
|
||||||
running: boolean;
|
running: boolean;
|
||||||
watcher?: null | Watcher;
|
watcher?: null | Watcher;
|
||||||
pausedWatcher?: null | Watcher;
|
pausedWatcher?: null | Watcher;
|
||||||
|
lastWatcherStartTime?: number;
|
||||||
watch(
|
watch(
|
||||||
files: Iterable<string>,
|
files: Iterable<string>,
|
||||||
dirs: Iterable<string>,
|
dirs: Iterable<string>,
|
||||||
|
|
|
@ -6740,10 +6740,10 @@ wast-loader@^1.11.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
wabt "1.0.0-nightly.20180421"
|
wabt "1.0.0-nightly.20180421"
|
||||||
|
|
||||||
watchpack@^2.0.0:
|
watchpack@^2.2.0:
|
||||||
version "2.1.1"
|
version "2.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.1.1.tgz#e99630550fca07df9f90a06056987baa40a689c7"
|
resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.2.0.tgz#47d78f5415fe550ecd740f99fe2882323a58b1ce"
|
||||||
integrity sha512-Oo7LXCmc1eE1AjyuSBmtC3+Wy4HcV8PxWh2kP6fOl8yTlNS7r0K9l1ao2lrrUza7V39Y3D/BbJgY8VeSlc5JKw==
|
integrity sha512-up4YAn/XHgZHIxFBVCdlMiWDj6WaLKpwVeGQk2I5thdYxF/KmF0aaz6TfJZ/hfl1h/XlcDr7k1KH7ThDagpFaA==
|
||||||
dependencies:
|
dependencies:
|
||||||
glob-to-regexp "^0.4.1"
|
glob-to-regexp "^0.4.1"
|
||||||
graceful-fs "^4.1.2"
|
graceful-fs "^4.1.2"
|
||||||
|
|
Loading…
Reference in New Issue