facebook / metro

🚇 The JavaScript bundler for React Native
https://metrobundler.dev
MIT License
5.15k stars 613 forks source link

API Proposal - Multi-platform resolution #135

Open rozele opened 6 years ago

rozele commented 6 years ago

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?

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 commented 6 years ago

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 commented 4 years ago

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