webpack-cli
Advanced tools
Comparing version 5.1.3 to 5.1.4
import { type Compiler } from "webpack"; | ||
import { type CLIPluginOptions } from "../types"; | ||
export declare class CLIPlugin { | ||
#private; | ||
logger: ReturnType<Compiler["getInfrastructureLogger"]>; | ||
@@ -5,0 +6,0 @@ options: CLIPluginOptions; |
"use strict"; | ||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); | ||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); | ||
}; | ||
var _a, _CLIPlugin_progressStates; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -19,7 +25,23 @@ exports.CLIPlugin = void 0; | ||
const progressPlugin = Boolean(compiler.options.plugins.find((plugin) => plugin instanceof ProgressPlugin)); | ||
if (!progressPlugin) { | ||
new ProgressPlugin({ | ||
profile: this.options.progress === "profile", | ||
}).apply(compiler); | ||
if (progressPlugin) { | ||
return; | ||
} | ||
const isProfile = this.options.progress === "profile"; | ||
const options = { | ||
profile: isProfile, | ||
}; | ||
if (this.options.isMultiCompiler && ProgressPlugin.createDefaultHandler) { | ||
const handler = ProgressPlugin.createDefaultHandler(isProfile, compiler.getInfrastructureLogger("webpack.Progress")); | ||
const idx = __classPrivateFieldGet(CLIPlugin, _a, "f", _CLIPlugin_progressStates).length; | ||
__classPrivateFieldGet(CLIPlugin, _a, "f", _CLIPlugin_progressStates)[idx] = [0]; | ||
options.handler = (p, msg, ...args) => { | ||
__classPrivateFieldGet(CLIPlugin, _a, "f", _CLIPlugin_progressStates)[idx] = [p, msg, ...args]; | ||
let sum = 0; | ||
for (const [p] of __classPrivateFieldGet(CLIPlugin, _a, "f", _CLIPlugin_progressStates)) { | ||
sum += p; | ||
} | ||
handler(sum / __classPrivateFieldGet(CLIPlugin, _a, "f", _CLIPlugin_progressStates).length, `[${compiler.name ? compiler.name : idx}] ${msg}`, ...args); | ||
}; | ||
} | ||
new ProgressPlugin(options).apply(compiler); | ||
} | ||
@@ -85,2 +107,4 @@ setupHelpfulOutput(compiler) { | ||
exports.CLIPlugin = CLIPlugin; | ||
_a = CLIPlugin; | ||
_CLIPlugin_progressStates = { value: [] }; | ||
module.exports = CLIPlugin; |
@@ -152,2 +152,3 @@ /// <reference types="node" /> | ||
interface WebpackRunOptions extends WebpackOptionsNormalized { | ||
progress?: boolean | "profile"; | ||
json?: boolean; | ||
@@ -176,2 +177,3 @@ argv?: Argv; | ||
interface CLIPluginOptions { | ||
isMultiCompiler?: boolean; | ||
configPath?: string[]; | ||
@@ -178,0 +180,0 @@ helpfulOutput: boolean; |
{ | ||
"name": "webpack-cli", | ||
"version": "5.1.3", | ||
"version": "5.1.4", | ||
"description": "CLI for webpack & friends", | ||
@@ -68,3 +68,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "7899c3927926b191d0aca4ed52795b9c3885abfb" | ||
"gitHead": "e07f0e58df103011435524d757102534b75a6796" | ||
} |
Sorry, the diff of this file is too big to display
110451
2301