Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf659624

Browse files
fix: multi compiler progress output
1 parent0d1ff01 commitf659624

File tree

5 files changed

+48
-10
lines changed

5 files changed

+48
-10
lines changed

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
"ts-loader":"^9.3.1",
9494
"ts-node":"^10.9.1",
9595
"typescript":"^5.0.4",
96-
"webpack":"^5.72.0",
96+
"webpack":"^5.86.0",
9797
"webpack-bundle-analyzer":"^4.5.0",
9898
"webpack-dev-server":"^4.8.1"
9999
}

‎packages/webpack-cli/src/plugins/cli-plugin.ts‎

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import{typeCompiler}from"webpack";
1+
import{typeCompiler,ProgressPlugin}from"webpack";
22
import{typeCLIPluginOptions}from"../types";
33

44
exportclassCLIPlugin{
@@ -21,17 +21,51 @@ export class CLIPlugin {
2121
}
2222
}
2323

24+
static #progressStates:[number, ...string[]][]=[];
25+
2426
setupProgressPlugin(compiler:Compiler){
2527
const{ ProgressPlugin}=compiler.webpack||require("webpack");
2628
constprogressPlugin=Boolean(
2729
compiler.options.plugins.find((plugin)=>plugininstanceofProgressPlugin),
2830
);
2931

30-
if(!progressPlugin){
31-
newProgressPlugin({
32-
profile:this.options.progress==="profile",
33-
}).apply(compiler);
32+
if(progressPlugin){
33+
return;
3434
}
35+
36+
constisProfile=this.options.progress==="profile";
37+
38+
constoptions:ConstructorParameters<typeofProgressPlugin>[0]={
39+
profile:isProfile,
40+
};
41+
42+
if(this.options.isMultiCompiler&&ProgressPlugin.createDefaultHandler){
43+
consthandler=ProgressPlugin.createDefaultHandler(
44+
isProfile,
45+
compiler.getInfrastructureLogger("webpack.Progress"),
46+
);
47+
constidx=CLIPlugin.#progressStates.length;
48+
49+
CLIPlugin.#progressStates[idx]=[0];
50+
51+
options.handler=(p:number,msg:string, ...args:string[])=>{
52+
CLIPlugin.#progressStates[idx]=[p,msg, ...args];
53+
54+
letsum=0;
55+
56+
for(const[p]ofCLIPlugin.#progressStates){
57+
sum+=p;
58+
}
59+
60+
handler(
61+
sum/CLIPlugin.#progressStates.length,
62+
`[${compiler.name ?compiler.name :idx}]${msg}`,
63+
...args,
64+
);
65+
};
66+
}
67+
68+
newProgressPlugin(options).apply(compiler);
3569
}
3670

3771
setupHelpfulOutput(compiler:Compiler){

‎packages/webpack-cli/src/types.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type {
1111
Argument,
1212
AssetEmittedInfo,
1313
FileCacheOptions,
14+
WebpackPluginInstance,
1415
}from"webpack";
1516
importtypewebpackfrom"webpack";
1617

@@ -210,6 +211,7 @@ type ProcessedArguments = Record<string, BasicPrimitive | RegExp | (BasicPrimiti
210211
typeCommandAction=Parameters<WebpackCLICommand["action"]>[0];
211212

212213
interfaceWebpackRunOptionsextendsWebpackOptionsNormalized{
214+
progress?:boolean|"profile";
213215
json?:boolean;
214216
argv?:Argv;
215217
env:Env;
@@ -237,6 +239,7 @@ interface BasicPackageJsonContent {
237239
*/
238240

239241
interfaceCLIPluginOptions{
242+
isMultiCompiler?:boolean;
240243
configPath?:string[];
241244
helpfulOutput:boolean;
242245
hot?:boolean|"only";

‎packages/webpack-cli/src/webpack-cli.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2348,6 +2348,7 @@ class WebpackCLI implements IWebpackCLI {
23482348
helpfulOutput:!options.json,
23492349
progress:options.progress,
23502350
analyze:options.analyze,
2351+
isMultiCompiler:Array.isArray(config.options),
23512352
}),
23522353
);
23532354
};

‎yarn.lock‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11138,10 +11138,10 @@ webpack-sources@^3.2.3:
1113811138
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde"
1113911139
integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==
1114011140

11141-
webpack@^5.72.0:
11142-
version "5.85.1"
11143-
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.85.1.tgz#d77406352f8f14ec847c54e4dcfb80b28c776b3f"
11144-
integrity sha512-xTb7MRf4LY8Z5rzn7aIx4TDrwYJrjcHnIfU1TqtyZOoObyuGSpAUwIvVuqq5wPnv7WEgQr8UvO1q/dgoGG4HjA==
11141+
webpack@^5.86.0:
11142+
version "5.86.0"
11143+
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.86.0.tgz#b0eb81794b62aee0b7e7eb8c5073495217d9fc6d"
11144+
integrity sha512-3BOvworZ8SO/D4GVP+GoRC3fVeg5MO4vzmq8TJJEkdmopxyazGDxN8ClqN12uzrZW9Tv8EED8v5VSb6Sqyi0pg==
1114511145
dependencies:
1114611146
"@types/eslint-scope" "^3.7.3"
1114711147
"@types/estree" "^1.0.0"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp