Description
Description
While building a React Native app, I encountered an issue where Metro fails to resolve a module located in a folder ending with 'test'. Specifically, the error message indicates that the file index.tsx
in the BoardContest
folder (which is under Screens/Main/BoardContest
) cannot be found:
Unable to resolve module ../../Screens/Main/BoardContest/index.tsx from C:\Users\ARB\AndroidStudioProjects\PokketApplication\packages\challenger-mobile\app\Navigators\AppNavigator\index.tsx: C:\Users\ARB\AndroidStudioProjects\PokketApplication\packages\challenger-mobile\app\Navigators\AppNavigator\index.tsx None of these files exist: * app\Screens\Main\BoardContest\index.tsx(.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx) * app\Screens\Main\BoardContest\index.tsx
> 8 | import BoardContestScreen from '@screen/Main/BoardContest/index.tsx'; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Through debugging the Metro Node Haste and inspecting the watcher, I traced the issue to the ignoreForCrawl
function in the FileMap
class. The function appears to match an ignore pattern against the file path, and it seems to ignore files when their parent folder ends with 'test'. In my case, the path C:\Users\ARB\AndroidStudioProjects\PokketApplication\packages\challenger-mobile\app\Screens\Main\BoardContest
triggered this behavior, likely due to the 'test' suffix in 'BoardContest'.
Request for Help
I am not familiar with the internal workings of Metro to propose a fix, but it seems the ignore pattern might be overly aggressive when dealing with folder names ending in 'test'. Could the Metro team please investigate and adjust the ignore logic to ensure valid files in such folders are not excluded? This would help prevent similar issues for other users who might have folder names ending with 'test' for legitimate reasons.