Webpack-cli: CLI: while importing some flags have pre-appended values

Created on 11 Jul 2020  路  9Comments  路  Source: webpack/webpack-cli


Bug report

While importing flags from core some flags are preappended with values , for example -

  • --module-no-parse
  • --module-no-parse-reset
  • --optimization-no-emit-on-errors



What is the current behavior?
These flags have pre appended values and seems we cant override .

Screenshot at 2020-07-11 14-03-34

If the current behavior is a bug, please provide the steps to reproduce.
Import flags and process them.






What is the expected behavior?

The flags should not have pre appended values.


Other relevant information:
webpack version:
Node.js version:
Operating System:
Additional tools:

Most helpful comment

I have sent a fix to commander.js, now we wait to merge and release.

All 9 comments

@snitin315 I think it is bug on our side, can you provide more information? Why compilers is undefined?

The new CLI arguments system will fix that as it has --module-no-parse-reset for these cases.

@snitin315 I think it is bug on our side, can you provide more information? Why compilers is undefined?

No idea :confused: , /cc @webpack/cli-team can anyone look into this? It is a major blocker for #1630

@snitin315 Can we try to test --optimization-no-emit-on-errors with pure setup without webpack-cli and check value?

@snitin315 Can we try to test --optimization-no-emit-on-errors with pure setup without webpack-cli and check value?

--optimization-no-emit-on-errors works fine on the webpack side. I don't know how but these 3 flags seem to be set to true by our arg-parser.
arg-parser should do this only if we have defaultValue: true for these which isn't the case here.

I think I found the bug, I can see defaultValue: true in parserInstance. Looking more into it.

Screenshot at 2020-07-16 20-28-38

I think it is a bug in commander.js, Actually, it sets defaultValue: true if the option starts with no-, but instead it is doing same for all options that include no-.
As mentioned in their docs - https://github.com/tj/commander.js/#other-option-types-negatable-boolean-and-flagvalue

You can specify a boolean option long name with a leading no- to set the option value to false when used. Defined alone this also makes the option true by default.

I will raise an issue there.

Good catch :+1:

I have sent a fix to commander.js, now we wait to merge and release.

Was this page helpful?
0 / 5 - 0 ratings