Repository navigation
Conversation
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.
Summary
When a Haste name has more than one provider,
DependencyGraphturns theDuplicateHasteCandidatesErrorfrom metro-file-map into anAmbiguousModuleResolutionError.formatBundlingError(the error sent to the app) andTerminalReporter._logBundlingError(the terminal output) both build their own message for it, and list the candidates withObject.keys(he.duplicatesSet). ButduplicatesSetis aMap(DuplicatesSet = Map<string, number>in metro-file-map, andHastePluginthrows with aMap), andObject.keys()of aMapis[]. So both messages end with "You can delete or fix them:" and nothing after it.The dev server hits this when two files share a Haste name, for example with
resolver.enableGlobalPackagesand twopackage.jsonfiles outsidenode_moduleswith the samename(the "multiple packages with the same name" case inresolver-test.js). Calling the formatter directly shows it:The fix reads the paths from the map keys (
[...he.duplicatesSet.keys()]) in both places. InformatBundlingErrorthis also drops a.map()that only turned each path into the same string.Changelog: [Fix] Ambiguous module resolution errors list the conflicting files instead of an empty list, in the terminal and in the app
Test plan
Added an
AmbiguousModuleResolutionErrortest topackages/metro/src/lib/__tests__/formatBundlingError-test.js. It builds the error from a realDuplicateHasteCandidatesErrorwith two paths and checks the whole message.TerminalReporterhas no test file, so I checked it with a throwaway test that calls_logBundlingErrorwith the same error. Before the fix nothing follows "fix them:", after it the output lists* `/root/a.js`and* `/root/b.js`.yarn jest packages/metro/src/lib/__tests__ packages/metro/src/__tests__/HmrServer-test.js packages/metro/src/Server/__tests__/Server-test.js: 20 suites, 274 tests pass.eslintandprettier --checkon the three changed files: clean.flow focus-checkon the three files: no new errors. My local flow-bin is still 0.333, so I ran it with--ignore-version; the only error it reports (theassertssyntax inflow-typed/npm/invariant_v2.x.x.js) is the same onmain.