Repository navigation
Conversation
flattenBlockList joined no patterns into new RegExp(''), which matches
every path, so an empty blockList array produced an empty file map.
Return a pattern that never matches for an empty array.
Metro review: Looks goodRisk: low · Commit: With No findings. Verified
Not run: No benchmark: the change only runs once at file map construction, and only for an empty array, so it can't plausibly affect cost. I didn't run Automated review by Claude. Advisory only: it never approves or blocks, and a maintainer makes the call. |
Summary
flattenBlockListturns ablockListarray into a single RegExp by joining the sources of its patterns with|. For an empty array the result isnew RegExp(''), which matches every string.metro-file-mapthen adds its VCS directory pattern ((?:)|[/\\]\.(git|hg)[/\\]), and that still matches every path. Soresolver: {blockList: []}gives an empty file map, and the first build fails withFailed to get the SHA-1 for: <projectRoot>/index.js.The docs say setting
blockListreplaces the default, so an empty list should mean that nothing is blocked.Server-test.jsalready usesblockList: []that way; it only passes because it mocksDependencyGraph. The existingregexes[0]?.flags ?? ''shows that an empty array was expected here.This returns a pattern that never matches (
/.^/, the same oneresolver-test.jsuses) for an empty array. Non-empty arrays and single RegExps are unchanged.Changelog: [Fix]
resolver.blockList: []no longer hides every file from MetroTest plan
I added a
blockList config paramblock topackages/metro/src/DeltaBundler/__tests__/resolver-test.js. It builds a realDependencyGraphon the in-memory fs (linux and win32):Before:
After:
Other checks:
I also checked it end to end with
Metro.runBuildon a two-file project. WithblockList: []the build failed withFailed to get the SHA-1 for: .../index.jsbefore this change. After it, the bundle builds and runs, and the default, a one-pattern array and a single RegExp give the same results as before.This change was drafted with Claude Code (claude-opus-5-5); the test results above are from the runs described.