Skip to content

Commit 48e97b7

Browse files
committed
fix(webpack-cli): make default config discovery matching case-insensitive
The readdir-based discovery matched entry names case-sensitively, which differed from the previous `fs.access` behavior on case-insensitive filesystems (a config named e.g. `Webpack.Config.js` would no longer be found). Lowercase the directory entries for the membership check and rely on the existing `access` confirm for exact existence semantics, so behavior matches the old `fs.access` on both case-sensitive and case-insensitive filesystems while keeping the fast no-config path. https://claude.ai/code/session_01PEtzv6Xqv2yXQaQsZaeoSF
1 parent cb24a16 commit 48e97b7

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2381,13 +2381,18 @@ class WebpackCLI {
23812381
// Read each candidate directory once and match in-memory instead of
23822382
// probing every `<name><ext>` combination with a separate `fs.access`
23832383
// call (which is up to ~100 sequential syscalls when no config exists).
2384+
// Entries are lowercased so the membership check is case-insensitive; the
2385+
// actual existence is then confirmed with `access`, which keeps exact
2386+
// filesystem semantics (case-sensitive or not) identical to before.
23842387
const directoryEntriesCache = new Map<string, Set<string> | null>();
23852388
const readDirectoryEntries = async (directory: string) => {
23862389
let entries = directoryEntriesCache.get(directory);
23872390

23882391
if (typeof entries === "undefined") {
23892392
try {
2390-
entries = new Set(await fs.promises.readdir(directory));
2393+
entries = new Set(
2394+
(await fs.promises.readdir(directory)).map((entry) => entry.toLowerCase()),
2395+
);
23912396
} catch {
23922397
entries = null;
23932398
}
@@ -2412,7 +2417,7 @@ class WebpackCLI {
24122417
const basename = path.basename(resolvedBase);
24132418

24142419
for (const ext of orderedExtensions) {
2415-
if (!entries.has(basename + ext)) {
2420+
if (!entries.has((basename + ext).toLowerCase())) {
24162421
continue;
24172422
}
24182423

0 commit comments

Comments
 (0)