Merge pull request #11135 from webpack/ci/stability

CI stability
This commit is contained in:
Tobias Koppers 2020-07-08 12:19:37 +02:00 committed by GitHub
commit 95120bdf98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 93 additions and 14 deletions

View File

@ -40,6 +40,7 @@ const { makePathsRelative } = require("./util/identifier");
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
/** @typedef {import("./util/fs").IntermediateFileSystem} IntermediateFileSystem */
/** @typedef {import("./util/fs").OutputFileSystem} OutputFileSystem */
/** @typedef {import("./util/fs").WatchFileSystem} WatchFileSystem */
/**
* @typedef {Object} CompilationParams
@ -146,7 +147,7 @@ class Compiler {
watchRun: new AsyncSeriesHook(["compiler"]),
/** @type {SyncHook<[Error]>} */
failed: new SyncHook(["error"]),
/** @type {SyncHook<[string, string]>} */
/** @type {SyncHook<[string, number]>} */
invalid: new SyncHook(["filename", "changeTime"]),
/** @type {SyncHook<[]>} */
watchClose: new SyncHook([]),
@ -183,6 +184,7 @@ class Compiler {
this.intermediateFileSystem = null;
/** @type {InputFileSystem} */
this.inputFileSystem = null;
/** @type {WatchFileSystem} */
this.watchFileSystem = null;
/** @type {string|null} */

View File

@ -21,6 +21,7 @@ const MultiWatching = require("./MultiWatching");
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
/** @typedef {import("./util/fs").IntermediateFileSystem} IntermediateFileSystem */
/** @typedef {import("./util/fs").OutputFileSystem} OutputFileSystem */
/** @typedef {import("./util/fs").WatchFileSystem} WatchFileSystem */
/** @typedef {number} CompilerStatus */
@ -129,6 +130,10 @@ module.exports = class MultiCompiler {
throw new Error("Cannot read outputFileSystem of a MultiCompiler");
}
get watchFileSystem() {
throw new Error("Cannot read watchFileSystem of a MultiCompiler");
}
get intermediateFileSystem() {
throw new Error("Cannot read outputFileSystem of a MultiCompiler");
}
@ -151,6 +156,15 @@ module.exports = class MultiCompiler {
}
}
/**
* @param {WatchFileSystem} value the new watch file system
*/
set watchFileSystem(value) {
for (const compiler of this.compilers) {
compiler.watchFileSystem = value;
}
}
/**
* @param {IntermediateFileSystem} value the new intermediate file system
*/

View File

@ -62,7 +62,7 @@ class IgnoringWatchFileSystem {
return {
close: () => watcher.close(),
pause: () => watcher.pause(),
getContextInfoEntries: () => {
getContextTimeInfoEntries: () => {
const dirTimestamps = watcher.getContextInfoEntries();
for (const path of ignoredDirs) {
dirTimestamps.set(path, IGNORE_TIME_ENTRY);

View File

@ -8,14 +8,9 @@
const Watchpack = require("watchpack");
/** @typedef {import("../FileSystemInfo").FileSystemInfoEntry} FileSystemInfoEntry */
/**
* @typedef {Object} Watcher
* @property {function(): void} close
* @property {function(): void} pause
* @property {function(): Map<string, FileSystemInfoEntry>} getFileTimeInfoEntries
* @property {function(): Map<string, FileSystemInfoEntry>} getContextTimeInfoEntries
*/
/** @typedef {import("../util/fs").WatchFileSystem} WatchFileSystem */
/** @typedef {import("../util/fs").WatchMethod} WatchMethod */
/** @typedef {import("../util/fs").Watcher} Watcher */
class NodeWatchFileSystem {
constructor(inputFileSystem) {

View File

@ -8,6 +8,7 @@
const path = require("path");
/** @typedef {import("fs").Stats} NodeFsStats */
/** @typedef {import("../FileSystemInfo").FileSystemInfoEntry} FileSystemInfoEntry */
/** @typedef {function(NodeJS.ErrnoException=): void} Callback */
/** @typedef {function(NodeJS.ErrnoException=, Buffer=): void} BufferCallback */
@ -17,6 +18,26 @@ const path = require("path");
/** @typedef {function(NodeJS.ErrnoException=, NodeFsStats=): void} StatsCallback */
/** @typedef {function((NodeJS.ErrnoException | Error)=, any=): void} ReadJsonCallback */
/**
* @typedef {Object} Watcher
* @property {function(): void} close closes the watcher and all underlying file watchers
* @property {function(): void} pause closes the watcher, but keeps underlying file watchers alive until the next watch call
* @property {function(): Map<string, FileSystemInfoEntry>} getFileTimeInfoEntries get info about files
* @property {function(): Map<string, FileSystemInfoEntry>} getContextTimeInfoEntries get info about directories
*/
/**
* @callback WatchMethod
* @param {Iterable<string>} files watched files
* @param {Iterable<string>} directories watched directories
* @param {Iterable<string>} missing watched exitance entries
* @param {number} startTime timestamp of start time
* @param {TODO} options options object
* @param {function(Error=, Map<string, FileSystemInfoEntry>, Map<string, FileSystemInfoEntry>, Set<string>, Set<string>): void} callback aggregated callback
* @param {function(string, number): void} callbackUndelayed callback when the first change was detected
* @returns {Watcher} a watcher
*/
/**
* @typedef {Object} OutputFileSystem
* @property {function(string, Buffer|string, Callback): void} writeFile
@ -42,6 +63,11 @@ const path = require("path");
* @property {(function(string): string)=} dirname
*/
/**
* @typedef {Object} WatchFileSystem
* @property {WatchMethod} watch
*/
/**
* @typedef {Object} IntermediateFileSystemExtras
* @property {function(string): void} mkdirSync

View File

@ -16,6 +16,9 @@ const createMultiCompiler = () => {
}
]);
compiler.outputFileSystem = createFsFromVolume(new Volume());
compiler.watchFileSystem = {
watch(a, b, c, d, e, f, g) {}
};
return compiler;
};

View File

@ -176,5 +176,5 @@ export default ${files.map((_, i) => `f${i}`).join(" + ")};
});
await compile(configAdditions);
await expect(execute()).resolves.toEqual({ ok: true });
});
}, 60000);
}, 60000);
});

43
types.d.ts vendored
View File

@ -1327,7 +1327,7 @@ declare class Compiler {
afterCompile: AsyncSeriesHook<[Compilation]>;
watchRun: AsyncSeriesHook<[Compiler]>;
failed: SyncHook<[Error], void>;
invalid: SyncHook<[string, string], void>;
invalid: SyncHook<[string, number], void>;
watchClose: SyncHook<[], void>;
infrastructureLog: SyncBailHook<[string, string, any[]], true>;
environment: SyncHook<[], void>;
@ -1345,7 +1345,7 @@ declare class Compiler {
OutputFileSystem &
IntermediateFileSystemExtras;
inputFileSystem: InputFileSystem;
watchFileSystem: any;
watchFileSystem: WatchFileSystem;
recordsInputPath: string;
recordsOutputPath: string;
records: {};
@ -4319,6 +4319,7 @@ declare class MultiCompiler {
readonly outputPath: string;
inputFileSystem: InputFileSystem;
outputFileSystem: OutputFileSystem;
watchFileSystem: WatchFileSystem;
intermediateFileSystem: InputFileSystem &
OutputFileSystem &
IntermediateFileSystemExtras;
@ -7958,6 +7959,23 @@ declare abstract class VariableInfo {
freeName: string | true;
tagInfo: TagInfo;
}
declare interface WatchFileSystem {
watch: (
files: Iterable<string>,
directories: Iterable<string>,
missing: Iterable<string>,
startTime: number,
options: any,
callback: (
arg0: Error,
arg1: Map<string, FileSystemInfoEntry>,
arg2: Map<string, FileSystemInfoEntry>,
arg3: Set<string>,
arg4: Set<string>
) => void,
callbackUndelayed: (arg0: string, arg1: number) => void
) => Watcher;
}
declare class WatchIgnorePlugin {
constructor(options: WatchIgnorePluginOptions);
paths: [string | RegExp, ...(string | RegExp)[]];
@ -7998,6 +8016,27 @@ declare interface WatchOptions {
*/
stdin?: boolean;
}
declare interface Watcher {
/**
* closes the watcher and all underlying file watchers
*/
close: () => void;
/**
* closes the watcher, but keeps underlying file watchers alive until the next watch call
*/
pause: () => void;
/**
* get info about files
*/
getFileTimeInfoEntries: () => Map<string, FileSystemInfoEntry>;
/**
* get info about directories
*/
getContextTimeInfoEntries: () => Map<string, FileSystemInfoEntry>;
}
declare abstract class Watching {
startTime: number;
invalid: boolean;