API Proposal - Multi-platform resolution
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5.6k
- Forks
- 696
- Avg merge
- 8m
- Merged PRs (30d)
- 7
Description
Do you want to request a feature or report a bug?
Feature
What is the current behavior?
Metro only supports module resolution for a single platform. I.e., you provide a single platform to Metro as an option, and Metro will return files and assets matching Foo.platform.js, Foo.native.js, and Foo.js.
If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install and yarn test.
N/A
What is the expected behavior?
- There are some cases where we want to share code across platforms, and specialize where necessary. E.g., WPF and UWP (see react-native-windows).
- Similarly, there may be cases where we want to share code across versions of a platform, but do not want to use conditional version checks inside the source code. E.g.,
Foo.androidm.jsandFoo.androidn.js. - Lastly, there are cases where you're using a single native platform, but may want to customize the module resolution based on device family. E.g.,
Foo.ipad.jsandFoo.iphone.jsorFoo.xbox.jsandFoo.hololens.js. Similarly, we may also want to support arbitrary sharing of code across native platforms with similar device families, e.g.,Foo.mobile.jsorFoo.desktop.js.
To do this, I'd like to have an option to resolve multiple platforms in preferential order. For example, rather than providing a single platform, e.g., 'ios', I may provide an ordered list of platforms, e.g., ['ipad', 'ios'] or ['uwp', 'windows'].
This could be implemented as an optional parameter to keep backward compatibility. We could also use such a feature to simplify the code paths for .native.js extensions (e.g., ['uwp', 'windows', 'native']).
Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.
N/A
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue proposes ordered, multi-platform module resolution for Metro, but names no files, tests, or specific entry points. Start by locating Metro's current platform-resolution API and configuration handling; done would include a backward-compatible option supporting preferential platform lists and the described sharing cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react-native
- Domain
- build-system, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100