react / react/metro

Bug in resolving .(android | ios).js files accessed directly without index.js

Open
#741 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
5.6k
Forks
696
Avg merge
8m
Merged PRs (30d)
7

Description

I think there's a little bug in current metro-resolver.
Steps to reproduce :
Let say i have folder named folderA/ and inside it I have 2 files someFile.android.js and someFile.ios.js. And now I am using that file by importing like
import Something from 'folderA/someFile'.
But metro resolver always picks ios file in android.
If i add one index.js and access files through it like
import Something from 'folderA' then it works fine.
(Assuming index.js is added in folderA and its content is export default from ./someFile)

If this is indeed a bug and reproducible by others as well, I can raise a PR for the same.
Thanks :)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the metro-resolver entry point and reproduce the import from folderA/someFile using the provided Android and iOS filenames. Compare direct-file resolution with resolution through folderA/index.js; done means the direct import selects someFile.android.js on Android and someFile.ios.js on iOS.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.