Skip to content

Conversation

tido64
Copy link
Contributor

@tido64 tido64 commented May 20, 2022

Summary:

Resolves #1612.

Test Plan:

  1. Clone and check out the branch with a repro:
    git clone https://github.com/microsoft/react-native-test-app.git
    cd react-native-test-app
    git checkout tido/enable-turbomodule
    
  2. Apply below diff to make @react-native-community/cli think that react-native-test-app has native modules to link:
    diff --git a/android/app/src/turbomodule/java/com/microsoft/reacttestapp/turbomodule/TurboModuleManagerDelegate.kt b/android/app/src/turbomodule/java/com/microsoft/reacttestapp/turbomodule/TurboModuleManagerDelegate.kt
    index 2b02ad7..5ef4977 100644
    --- a/android/app/src/turbomodule/java/com/microsoft/reacttestapp/turbomodule/TurboModuleManagerDelegate.kt
    +++ b/android/app/src/turbomodule/java/com/microsoft/reacttestapp/turbomodule/TurboModuleManagerDelegate.kt
    @@ -20,7 +20,7 @@ typealias ReactTurboModuleManagerDelegate = ReactPackageTurboModuleManagerDelega
      */
     class TurboModuleManagerDelegate protected constructor(
         reactApplicationContext: ReactApplicationContext?,
    -    packages: PackagesList?
    +    packages: List<ReactPackage?>?
     ) : ReactTurboModuleManagerDelegate(reactApplicationContext, packages) {
    
         protected external fun initHybrid(): HybridData?
  3. Run react-native config and note that the output contains both Android and iOS modules:
    cd example
    yarn react-native config
    
  4. Disable autolinking for Android:
    diff --git a/react-native.config.js b/react-native.config.js
    index 833fe69..be3e6c5 100644
    --- a/react-native.config.js
    +++ b/react-native.config.js
    @@ -102,6 +102,7 @@ module.exports = {
       ],
       dependency: {
         platforms: {
    +      android: null,
           windows: null,
         },
       },
  5. Run react-native config and verify that the output only contains iOS modules
  6. Disable autolinking for iOS:
    diff --git a/react-native.config.js b/react-native.config.js
    index 833fe69..be3e6c5 100644
    --- a/react-native.config.js
    +++ b/react-native.config.js
    @@ -102,6 +102,7 @@ module.exports = {
       ],
       dependency: {
         platforms: {
    -      android: null,
    +      ios: null,
           windows: null,
         },
       },
  7. Run react-native config and verify that the output only contains Android modules
  8. Disable autolinking for both Android and iOS:
    diff --git a/react-native.config.js b/react-native.config.js
    index 833fe69..be3e6c5 100644
    --- a/react-native.config.js
    +++ b/react-native.config.js
    @@ -102,6 +102,7 @@ module.exports = {
       ],
       dependency: {
         platforms: {
    +      android: null,
           ios: null,
           windows: null,
         },
       },
  9. Run react-native config and verify that the output contains no native modules

@thymikee thymikee merged commit 504405d into react-native-community:master May 20, 2022
thymikee added a commit that referenced this pull request May 20, 2022
* fix: allow `dependency.platforms.[platform]` to be `null` again

* chore: add test

Co-authored-by: Michał Pierzchała <[email protected]>
@thymikee
Copy link
Member

Released in 8.0.2

@tido64 tido64 deleted the tido/fix-dependency-platform-null branch May 20, 2022 14:49
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

Successfully merging this pull request may close these issues.

No longer possible to disable autolinking for specific platforms

2 participants