Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
馃煝 Approval recommended
The fix is narrowly scoped, correct, and covered by relevant regression tests.
0 open findings
What changed in this PR
Prevents directories with asset-like extensions from being incorrectly resolved as assets.
Changes:
- Restricts asset candidates to files.
- Adds package and relative-directory regression tests.
| File | Description |
|---|---|
createModuleResolver.js |
Filters non-file asset candidates. |
resolver-test.js |
Tests asset-extension directory resolution. |
馃 Review effort: Balanced
馃挕 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
|
@Abbondanzo has imported this pull request. If you are a Meta employee, you can view this in D124673317. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A package or directory whose name ends in one of
resolver.assetExtscan't be imported, because the resolver treats it as an asset file.require('lodash.zip')(a real package) fails with:Any asset extension causes this, and it also breaks relative imports of directories ending in an extension, eg
require('./icons.png')whereicons.pngis a directory containing anindex.js.This change only accepts asset candidates that are files (
type === 'f'), so directories fall through to package resolution as they would for any other name.Fixes: #441
Changelog:
Test plan:
New tests in
resolver-test.jsfor a package (lodash.zip) and a relative directory (icons.png), both failing before this change (resolving to the directory itself) and passing after.Also checked end-to-end by patching published
metro@0.87.1:require('lodash.zip')builds, and a real./assets/pic.pngstill resolves as an asset.