mirror of https://github.com/webpack/webpack.git
fix: types
This commit is contained in:
parent
be975d9e2c
commit
5c28ea39a5
|
|
@ -86,7 +86,9 @@ class RuntimeTemplate {
|
|||
this.compilation = compilation;
|
||||
this.outputOptions = outputOptions || {};
|
||||
this.requestShortener = requestShortener;
|
||||
this.globalObject = getGlobalObject(outputOptions.globalObject);
|
||||
this.globalObject =
|
||||
/** @type {string} */
|
||||
(getGlobalObject(outputOptions.globalObject));
|
||||
this.contentHashReplacement = "X".repeat(
|
||||
/** @type {NonNullable<OutputOptions["hashDigestLength"]>} */
|
||||
(outputOptions.hashDigestLength)
|
||||
|
|
|
|||
|
|
@ -95,19 +95,32 @@ class WebpackLogger {
|
|||
this[LOG_SYMBOL](LogType.groupEnd, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string=} label label
|
||||
*/
|
||||
profile(label) {
|
||||
this[LOG_SYMBOL](LogType.profile, [label]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string=} label label
|
||||
*/
|
||||
profileEnd(label) {
|
||||
this[LOG_SYMBOL](LogType.profileEnd, [label]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} label label
|
||||
*/
|
||||
time(label) {
|
||||
/** @type {Map<string | undefined, [number, number]>} */
|
||||
this[TIMERS_SYMBOL] = this[TIMERS_SYMBOL] || new Map();
|
||||
this[TIMERS_SYMBOL].set(label, process.hrtime());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string=} label label
|
||||
*/
|
||||
timeLog(label) {
|
||||
const prev = this[TIMERS_SYMBOL] && this[TIMERS_SYMBOL].get(label);
|
||||
if (!prev) {
|
||||
|
|
@ -117,16 +130,23 @@ class WebpackLogger {
|
|||
this[LOG_SYMBOL](LogType.time, [label, ...time]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string=} label label
|
||||
*/
|
||||
timeEnd(label) {
|
||||
const prev = this[TIMERS_SYMBOL] && this[TIMERS_SYMBOL].get(label);
|
||||
if (!prev) {
|
||||
throw new Error(`No such label '${label}' for WebpackLogger.timeEnd()`);
|
||||
}
|
||||
const time = process.hrtime(prev);
|
||||
this[TIMERS_SYMBOL].delete(label);
|
||||
/** @type {Map<string | undefined, [number, number]>} */
|
||||
(this[TIMERS_SYMBOL]).delete(label);
|
||||
this[LOG_SYMBOL](LogType.time, [label, ...time]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string=} label label
|
||||
*/
|
||||
timeAggregate(label) {
|
||||
const prev = this[TIMERS_SYMBOL] && this[TIMERS_SYMBOL].get(label);
|
||||
if (!prev) {
|
||||
|
|
@ -135,7 +155,9 @@ class WebpackLogger {
|
|||
);
|
||||
}
|
||||
const time = process.hrtime(prev);
|
||||
this[TIMERS_SYMBOL].delete(label);
|
||||
/** @type {Map<string | undefined, [number, number]>} */
|
||||
(this[TIMERS_SYMBOL]).delete(label);
|
||||
/** @type {Map<string | undefined, [number, number]>} */
|
||||
this[TIMERS_AGGREGATES_SYMBOL] =
|
||||
this[TIMERS_AGGREGATES_SYMBOL] || new Map();
|
||||
const current = this[TIMERS_AGGREGATES_SYMBOL].get(label);
|
||||
|
|
@ -151,6 +173,9 @@ class WebpackLogger {
|
|||
this[TIMERS_AGGREGATES_SYMBOL].set(label, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string=} label label
|
||||
*/
|
||||
timeAggregateEnd(label) {
|
||||
if (this[TIMERS_AGGREGATES_SYMBOL] === undefined) return;
|
||||
const time = this[TIMERS_AGGREGATES_SYMBOL].get(label);
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ const { LogType } = require("./Logger");
|
|||
|
||||
/**
|
||||
* @param {FilterItemTypes} item an input item
|
||||
* @returns {FilterFunction} filter function
|
||||
* @returns {FilterFunction | undefined} filter function
|
||||
*/
|
||||
const filterToFunction = item => {
|
||||
if (typeof item === "string") {
|
||||
|
|
@ -81,11 +81,14 @@ const LogLevel = {
|
|||
*/
|
||||
module.exports = ({ level = "info", debug = false, console }) => {
|
||||
const debugFilters =
|
||||
typeof debug === "boolean"
|
||||
? [() => debug]
|
||||
: /** @type {FilterItemTypes[]} */ ([])
|
||||
.concat(debug)
|
||||
.map(filterToFunction);
|
||||
/** @type {FilterFunction[]} */
|
||||
(
|
||||
typeof debug === "boolean"
|
||||
? [() => debug]
|
||||
: /** @type {FilterItemTypes[]} */ ([])
|
||||
.concat(debug)
|
||||
.map(filterToFunction)
|
||||
);
|
||||
/** @type {number} */
|
||||
const loglevel = LogLevel[`${level}`] || 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,9 @@ class NodeEnvironmentPlugin {
|
|||
nodeConsole({
|
||||
colors: infrastructureLogging.colors,
|
||||
appendOnly: infrastructureLogging.appendOnly,
|
||||
stream: infrastructureLogging.stream
|
||||
stream:
|
||||
/** @type {NodeJS.WritableStream} */
|
||||
(infrastructureLogging.stream)
|
||||
})
|
||||
});
|
||||
compiler.inputFileSystem = new CachedInputFileSystem(fs, 60000);
|
||||
|
|
|
|||
|
|
@ -8,12 +8,29 @@
|
|||
const util = require("util");
|
||||
const truncateArgs = require("../logging/truncateArgs");
|
||||
|
||||
/** @typedef {import("../logging/createConsoleLogger").LoggerConsole} LoggerConsole */
|
||||
|
||||
/**
|
||||
* @param {Object} options options
|
||||
* @param {boolean=} options.colors colors
|
||||
* @param {boolean=} options.appendOnly append only
|
||||
* @param {NodeJS.WritableStream} options.stream stream
|
||||
* @returns {LoggerConsole} logger function
|
||||
*/
|
||||
module.exports = ({ colors, appendOnly, stream }) => {
|
||||
/** @type {string[] | undefined} */
|
||||
let currentStatusMessage = undefined;
|
||||
let hasStatusMessage = false;
|
||||
let currentIndent = "";
|
||||
let currentCollapsed = 0;
|
||||
|
||||
/**
|
||||
* @param {string} str string
|
||||
* @param {string} prefix prefix
|
||||
* @param {string} colorPrefix color prefix
|
||||
* @param {string} colorSuffix color suffix
|
||||
* @returns {string} indented string
|
||||
*/
|
||||
const indent = (str, prefix, colorPrefix, colorSuffix) => {
|
||||
if (str === "") return str;
|
||||
prefix = currentIndent + prefix;
|
||||
|
|
@ -38,7 +55,7 @@ module.exports = ({ colors, appendOnly, stream }) => {
|
|||
|
||||
const writeStatusMessage = () => {
|
||||
if (!currentStatusMessage) return;
|
||||
const l = stream.columns || 40;
|
||||
const l = /** @type {TODO} */ (stream).columns || 40;
|
||||
const args = truncateArgs(currentStatusMessage, l - 1);
|
||||
const str = args.join(" ");
|
||||
const coloredStr = `\u001b[1m${str}\u001b[39m\u001b[22m`;
|
||||
|
|
@ -46,6 +63,12 @@ module.exports = ({ colors, appendOnly, stream }) => {
|
|||
hasStatusMessage = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} prefix prefix
|
||||
* @param {string} colorPrefix color prefix
|
||||
* @param {string} colorSuffix color suffix
|
||||
* @returns {(function(...any[]): void)} function to write with colors
|
||||
*/
|
||||
const writeColored = (prefix, colorPrefix, colorSuffix) => {
|
||||
return (...args) => {
|
||||
if (currentCollapsed > 0) return;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,10 @@
|
|||
/** @typedef {import("./RuleSetCompiler").RuleCondition} RuleCondition */
|
||||
|
||||
class ObjectMatcherRulePlugin {
|
||||
/**
|
||||
* @param {string} ruleProperty the rule property
|
||||
* @param {string=} dataProperty the data property
|
||||
*/
|
||||
constructor(ruleProperty, dataProperty) {
|
||||
this.ruleProperty = ruleProperty;
|
||||
this.dataProperty = dataProperty || ruleProperty;
|
||||
|
|
|
|||
|
|
@ -12383,7 +12383,7 @@ declare abstract class RuntimeTemplate {
|
|||
compilation: Compilation;
|
||||
outputOptions: OutputNormalized;
|
||||
requestShortener: RequestShortener;
|
||||
globalObject?: string;
|
||||
globalObject: string;
|
||||
contentHashReplacement: string;
|
||||
isIIFE(): undefined | boolean;
|
||||
isModule(): undefined | boolean;
|
||||
|
|
@ -14377,13 +14377,13 @@ declare abstract class WebpackLogger {
|
|||
group(...args: any[]): void;
|
||||
groupCollapsed(...args: any[]): void;
|
||||
groupEnd(...args: any[]): void;
|
||||
profile(label?: any): void;
|
||||
profileEnd(label?: any): void;
|
||||
time(label?: any): void;
|
||||
timeLog(label?: any): void;
|
||||
timeEnd(label?: any): void;
|
||||
timeAggregate(label?: any): void;
|
||||
timeAggregateEnd(label?: any): void;
|
||||
profile(label?: string): void;
|
||||
profileEnd(label?: string): void;
|
||||
time(label: string): void;
|
||||
timeLog(label?: string): void;
|
||||
timeEnd(label?: string): void;
|
||||
timeAggregate(label?: string): void;
|
||||
timeAggregateEnd(label?: string): void;
|
||||
}
|
||||
declare class WebpackOptionsApply extends OptionsApply {
|
||||
constructor();
|
||||
|
|
|
|||
Loading…
Reference in New Issue