Skip to content

[Feature request] metro-config should add support for react-native-macos and react-native-windows #3257

Closed
@shirakaba

Description

@shirakaba

What happened?

The docs suggest the following config:

// metro.config.js
const { makeMetroConfig } = require("@rnx-kit/metro-config");

module.exports = makeMetroConfig({
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: false,
      },
    }),
  },
});

This gives monorepo support, but it would be really helpful if it also made react-native-macos and react-native-windows "just work" by setting up whatever config they need, too.

Affected Package

@rnx-kit/metro-config

Version

0.6.8

Which platforms are you seeing this issue on?

  • Android
  • iOS
  • macOS
  • Windows
See system information

System Information

System:
  OS: macOS 14.5
  CPU: (16) arm64 Apple M3 Max
  Memory: 8.18 GB / 48.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.16.0
    path: ~/.volta/tools/image/node/20.16.0/bin/node
  Yarn:
    version: 1.22.19
    path: ~/.volta/tools/image/yarn/1.22.19/bin/yarn
  npm:
    version: 10.8.1
    path: ~/.volta/tools/image/node/20.16.0/bin/npm
  Watchman:
    version: 2024.06.10.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /Users/jamie/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK:
    API Levels:
      - "31"
      - "34"
    Build Tools:
      - 32.1.0
      - 33.0.0
      - 34.0.0
    Android NDK: Not Found
IDEs:
  Android Studio: 2021.2 AI-212.5712.43.2112.8609683
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.12
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /Users/jamie/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react: Not Found
  react-native: Not Found
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: false

Steps to Reproduce

  1. Set up a react-native project (whether in a monorepo or regular repo).
  2. Add react-native-macos and/or react-native-windows projects to it.
  3. Observe that Metro can't resolve files like node_modules/react-native-windows/Libraries/Image/Image.windows.js because it's still looking inside the react-native folder rather than substituting the react-native-windows folder when the platform is Windows.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions