Skip to content

Support for Yarn Plug 'n Play #27

@empyrical

Description

@empyrical

This is a meta issue to keep track of the things that need to be tweaked to give RN-CLI support for Yarn Plug 'n Play. This is probably non-exhaustive, more things might be found as others are tweaked.

  • Global CLI: Support for finding react-native and react-native-local-cli when PnP is enabled (in progress: Add (very basic) Yarn Plug 'n Play support #26 )

  • react-native bundle: Support for bundling dependencies with PnP. (Metro team is working on open sourcing its PnP support: Support for resolving Yarn Plug 'n Play modules facebook/metro#308)

  • findPlugins: Plugin discovery code will need to be adapted to support PnP

  • Xcode pbxproj files all have paths hardcoded in like this:

    path = "../node_modules/react-native/React/React.xcodeproj";

    There is, as far as I know, no way to have this path be dynamic. Ideally there would be some kind of way to have Xcode call a subprocess (like node resolve-dependency.js or something) and use it as the path's prefix, but I don't think there's a way. So I think a script might need to be made to refresh these paths and keep them up to date.

    This is also relevant for user libraries and react-native link for iOS dependencies

  • Gradle scripts will need to be updated along with react-native link's Gradle output. Here's an example bit out output for react-native-webview:

    project(':react-native-webview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview/android')

    The path to it is hardcoded to look in node_modules. I think a new helper function could be written, that would look something like:

    npm_dependency('react-native-webview', 'android')

    Where the first argument is the name of the node module, and the second is a pathname within the node_module. If PnP isn't present, then it will simply output an old-style path to node_modules. A similar function could be made for BUCK.

  • Paths to node_modules/react-native are hardcoded in these files and will need to be updated. They could all use util/findReactNativePath, potentially.

    • local-cli/library/library.js
    • local-cli/eject/eject.js
    • local-cli/generator/templates.js
    • local-cli/link/__tests__/ios/getHeaderSearchPath.spec.js
    • local-cli/upgrade/upgrade.js
    • local-cli/util/findReactNativeScripts.js

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions