Skip to content

Commit 1d130ba

Browse files
committed
docs(webpack-cli): condense comments to single sentences
https://claude.ai/code/session_01PEtzv6Xqv2yXQaQsZaeoSF
1 parent edef29d commit 1d130ba

1 file changed

Lines changed: 6 additions & 27 deletions

File tree

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

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -654,9 +654,7 @@ class WebpackCLI {
654654
commandOptions = options.options;
655655
}
656656

657-
// Keep all option names (including the `no-` negated forms commander
658-
// registers) for "did you mean" suggestions on unknown options, since not
659-
// every option is registered on commander below.
657+
// Keep all option names (including `no-` negated forms) for "did you mean" suggestions, since not every option is registered below.
660658
const allOptionNames: string[] = [];
661659

662660
for (const option of commandOptions) {
@@ -669,9 +667,7 @@ class WebpackCLI {
669667

670668
(command as Command & { allOptionNames?: string[] }).allOptionNames = allOptionNames;
671669

672-
// For help we register every option (help lists them all). Otherwise we
673-
// register only the options actually present in argv, avoiding the cost of
674-
// building ~850 commander Options per run. Unrecognized flags still error.
670+
// Register every option for help, otherwise only the ones present in argv.
675671
const neededOptions = forHelp ? undefined : this.#neededOptionNames();
676672

677673
for (const option of commandOptions) {
@@ -723,10 +719,7 @@ class WebpackCLI {
723719
names.add(name.slice(3));
724720
}
725721
} else {
726-
// Short option(s): either a single option with an attached value
727-
// (`-d<value>`) or combined boolean flags (`-abc` => `-a -b -c`). Since
728-
// we can't tell which without the option definitions, register every
729-
// letter; over-registering an unused option is harmless.
722+
// Register every letter of a short token to cover both attached values (`-d<value>`) and combined flags (`-abc`); over-registering is harmless.
730723
for (const char of token.slice(1).split("=", 1)[0]) {
731724
names.add(char);
732725
}
@@ -1009,12 +1002,7 @@ class WebpackCLI {
10091002
return (error as Error).name === "ValidationError";
10101003
}
10111004

1012-
// Building arguments from the webpack/dev-server schema walks a large JSON
1013-
// schema and is repeated within a single run (e.g. once per command and again
1014-
// in `loadConfig`). Cache the result per webpack module and schema. The values
1015-
// are large (~1MB each) and only needed while setting up a command, so they are
1016-
// held via `WeakRef` to let the GC reclaim them afterwards (important for
1017-
// long-running `serve`/`watch`); a miss simply rebuilds them.
1005+
// Cache the expensive schema-to-arguments walk per webpack module and schema, held via `WeakRef` so the GC can reclaim the ~1MB result after command setup (a miss simply rebuilds it).
10181006
#argumentsCache = new WeakMap<
10191007
object,
10201008
Map<Schema, WeakRef<ReturnType<(typeof webpack)["cli"]["getArguments"]>>>
@@ -2296,14 +2284,7 @@ class WebpackCLI {
22962284
await this.program.parseAsync(args, parseOptions);
22972285
}
22982286

2299-
// Finds the highest-priority default configuration file (used when no
2300-
// `--config` is passed). Reads each candidate directory once and matches
2301-
// in-memory instead of probing every `<name><ext>` combination with a
2302-
// separate `fs.access` call (up to ~100 sequential syscalls when no config
2303-
// exists). Entries are lowercased so the membership check is case-insensitive;
2304-
// the actual existence is confirmed with `access`, which keeps exact
2305-
// filesystem semantics (case-sensitive or not). When a directory can't be
2306-
// listed (e.g. execute-only permissions), every candidate is probed directly.
2287+
// Finds the highest-priority default config file by reading each candidate directory once (case-insensitively) and confirming with `access`, instead of probing every `<name><ext>` combination separately.
23072288
async #findDefaultConfigFile(): Promise<string | undefined> {
23082289
const interpret = await import("interpret");
23092290
// Prioritize popular extensions first to avoid unnecessary fs calls
@@ -2351,9 +2332,7 @@ class WebpackCLI {
23512332
const basename = path.basename(resolvedBase);
23522333

23532334
for (const ext of orderedExtensions) {
2354-
// Fast path: skip candidates absent from the directory listing. When the
2355-
// directory can't be listed, `entries` is `null`, so probe every
2356-
// candidate directly with `access`.
2335+
// Skip candidates absent from the listing, but when the directory can't be listed (`entries` is `null`) probe every candidate directly.
23572336
if (entries && !entries.has((basename + ext).toLowerCase())) {
23582337
continue;
23592338
}

0 commit comments

Comments
 (0)