Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Proposal - Multi-platform resolution #135

Open
rozele opened this issue Feb 6, 2018 · 2 comments
Open

API Proposal - Multi-platform resolution #135

rozele opened this issue Feb 6, 2018 · 2 comments

Comments

@rozele
Copy link
Contributor

rozele commented Feb 6, 2018

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.js and Foo.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.js and Foo.iphone.js or Foo.xbox.js and Foo.hololens.js. Similarly, we may also want to support arbitrary sharing of code across native platforms with similar device families, e.g., Foo.mobile.js or Foo.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

@raarts
Copy link

raarts commented Mar 12, 2018

I'm currently trying to get react-native-web integrated. But it looks like that would require a different transform configuration, in which case metro should be running on a different port.

@csath
Copy link

csath commented Oct 31, 2019

I'm also currently trying to achieve above proposed bundle resolution for custom platforms. Anyone found a solution or a workaround?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants