-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add custom CLI option namespace and improve warnings #2063
Conversation
Seems this causes a lot of noise in the test output. I'll fix this tomorrow morning. |
Amazing, thanks for looking into this so soon. Just let me know when it's ready for review. |
When you start going down a rabbit whole... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A very important rabbit hole - great work diving into these nasty parts :)
-o, --output.file <output> Output (if absent, prints to stdout) | ||
-f, --output.format [es] Type of output (amd, cjs, es, iife, umd) | ||
-o, --file <output> Output (if absent, prints to stdout) | ||
-f, --format [es] Type of output (amd, cjs, es, iife, umd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!
src/utils/mergeOptions.ts
Outdated
); | ||
if (unknownOptions.length > 0) | ||
errors.push( | ||
`Unknown ${optionType} option: ${unknownOptions.join( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very minor point with the wording here for Unknown CLI option:
... perhaps make this Unknown ${optionType}:
where optionType
is 'CLI flag'
or 'input option'
or 'output option'
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
warnings++; | ||
assert.equal(warning.code, 'UNKNOWN_OPTION'); | ||
assert.equal(warning.message, | ||
'Unknown CLI option: unknownOption. Allowed options: acorn, acornInjectPlugins, amd, banner, c, cache, config, context, d, dir, e, entry, environment, experimentalCodeSplitting, experimentalDynamicImport, experimentalPreserveModules, exports, extend, external, f, file, footer, format, freeze, g, globals, h, i, indent, input, interop, intro, l, legacy, m, moduleContext, n, name, namespaceToStringTag, noConflict, o, onwarn, outro, paths, perf, plugins, preferConst, preserveSymlinks, silent, sourcemap, sourcemapFile, strict, treeshake, v, w, watch'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main reason I say this is that Allowed options
here may not immediately be clear to users that these are flags without using the word flag
(at least it was to me - I would have interpreted these as commands rollup c
etc instead of rollup -c
...).
* ignore CLI options that start with "config"
96461b8
to
e186781
Compare
As discussed in #1926:
config
i.e. these options can be safely used for custom functionalityUpdate: To not have lots of warnings in the tests, this soon turned into a much larger refactoring and cleanup of the option handling. These are the most prominent changes and improvements:
legacy
/output.legacy
was completely broken as some parts of the code assumed this to be an output option while others assumed it to be an input option. I have now turned this into an output option only (which means I should not forget to adjust the docs accordingly).output.
which is also much more in-line with the documentation. To avoid regressions, using theoutput.
prefix will still work but is not advertised e.g. in the CLI help. Will need to check the website for this as well.mergeOptions
which should make some unpleasant checks when boolean flags aretrue
by default much more pleasant.