Webpack-cli: [ENHANCEMENT]: Prettify err in case the supplied flag(s) is/are unknown

Created on 18 Aug 2019  ยท  12Comments  ยท  Source: webpack/webpack-cli

Describe the bug
Presently thrown err are simply logged in case of unknown flag, maybe we can present it nicely and show a message to use help flag for proper usage

What is the current behavior?
Stacktrace is printed in case of unknown flag.

To Reproduce
Invoke cli with an unknown flag

Expected behavior
concise message of supplying an unknown flag should be displayed. something like -
image

Screenshots
If applicable, add screenshots to help explain your problem.
image

Please paste the results of webpack-cli info here, and mention other relevant information

Additional context
Looking for feedback on this before starting work.

enhancement

Most helpful comment

baller af

All 12 comments

@evenstensberg @ematipico @rishabh3112 thoughts are appreciated. ๐Ÿ˜„

Yep we definitely need to do this

On it then!

baller af

โžœ  webpack-cli git:(next) webpack-cli --init
โฌข webpack: Unknown argument: --init

 Compilation Results

 Version: 5.0.0-beta.12
 Built: Thu Jan 23 2020 21:39:54 GMT+0530 (India Standard Time)
 Compile Time: 186ms
 Output Directory: /home/james-the-hacker/CodeSpace/GitHub-Projects/webpack-cli/dist

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Bundle emitted     โ”‚ Bundle name                                 โ”‚ Bundle size   โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ failed             โ”‚ main.js                                     โ”‚ 0.00 kb       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โฌข webpack: configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/

โฌข webpack: NoModeWarning: configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/
    at /home/james-the-hacker/CodeSpace/GitHub-Projects/webpack-cli/node_modules/webpack/lib/WarnNoModeSetPlugin.js:20:30
    at Hook.eval [as call] (eval at create (/home/james-the-hacker/CodeSpace/GitHub-Projects/webpack-cli/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:13:1)
    at Hook.CALL_DELEGATE [as _call] (/home/james-the-hacker/CodeSpace/GitHub-Projects/webpack-cli/node_modules/webpack/node_modules/tapable/lib/Hook.js:14:14)
    at Compiler.newCompilation (/home/james-the-hacker/CodeSpace/GitHub-Projects/webpack-cli/node_modules/webpack/lib/Compiler.js:857:30)
    at /home/james-the-hacker/CodeSpace/GitHub-Projects/webpack-cli/node_modules/webpack/lib/Compiler.js:898:29
    at Hook.eval [as callAsync] (eval at create (/home/james-the-hacker/CodeSpace/GitHub-Projects/webpack-cli/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/home/james-the-hacker/CodeSpace/GitHub-Projects/webpack-cli/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)
    at Compiler.compile (/home/james-the-hacker/CodeSpace/GitHub-Projects/webpack-cli/node_modules/webpack/lib/Compiler.js:893:28)
    at /home/james-the-hacker/CodeSpace/GitHub-Projects/webpack-cli/node_modules/webpack/lib/Compiler.js:424:12
    at Compiler.readRecords (/home/james-the-hacker/CodeSpace/GitHub-Projects/webpack-cli/node_modules/webpack/lib/Compiler.js:736:11)


โฌข webpack: Module not found: Error: Can't resolve './src' in '/home/james-the-hacker/CodeSpace/GitHub-Projects/webpack-cli'

\cc @ematipico

@jamesgeorge007 could you please argument your comment? I don't understand why ๐Ÿ˜…

Oops!

Passing in an unknown flag results in the logs as given above in my case. We can avoid those unnecessary logs by performing an exit here:-
https://github.com/webpack/webpack-cli/blob/a0ac134ff0d0a17c10387da99f5e96443e48bb15/lib/bootstrap.js#L69

What about passing a valid flag then an unvalid flag?

I think we can execute for the valid flag and log about the other parameter being invalid.

Can do whatever everyone agrees with. โœจ

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AjayPoshak picture AjayPoshak  ยท  5Comments

heyalbert picture heyalbert  ยท  3Comments

evenstensberg picture evenstensberg  ยท  5Comments

fokusferit picture fokusferit  ยท  4Comments

RobotnickIsrael picture RobotnickIsrael  ยท  5Comments