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

feat(expo-config-plugin): create config plugin for react-native-performance #145

Closed
wants to merge 6 commits into from

Conversation

friyiajr
Copy link
Contributor

@friyiajr friyiajr commented May 3, 2023

Motivation

Expo is becoming an increasingly popular way of building React-Native projects. It is important that we support their ecosystem in order to keep this library relevant in the RN Community.

NOTE: Reverted the import change found here because it seemed to be breaking builds in Vanilla RN and Expo Projects. Please double check this fix works on your end @ElviraBurchik.

Description

Fixes N/A

This Pull request adds a plugin folder to the library that has the code for the Expo Config-Plugin. No other code was touched. The purpose of the Config plugin is just to update the code on the library consumer's end

Test plan

  1. Checkout this branch
  2. At the root of the project run yarn to install all dependancies
  3. Run yarn build to build the config plugin locally
  4. cd into the ExpoFixture and run yarn again to install it's dependancies
  5. Run npx expo prebuild to do all native code setup
  6. After this run the app on both platforms making sure that you can see the logs in Flipper

For iOS:

npx expo run:ios

For Android:

npx expo run:android

Checklist

  • I have added a decision record entry, PR includes changes to monorepo setup that may require explanation

@friyiajr friyiajr force-pushed the dfriyia-expo-config-plugin branch from e334543 to f6fb98c Compare May 3, 2023 19:31
@friyiajr friyiajr changed the title [DF] feat(expo-config-plugin): create config plugin for react-native-performance feat(expo-config-plugin): create config plugin for react-native-performance May 3, 2023
@friyiajr friyiajr force-pushed the dfriyia-expo-config-plugin branch from f722e88 to 4aaf951 Compare May 3, 2023 20:55
@friyiajr friyiajr marked this pull request as ready for review May 3, 2023 21:33
return withAppDelegate(expoConfig, iosConfig => {
if (!['objc', 'objcpp'].includes(iosConfig.modResults.language)) {
throw new Error(
"react-native-google-cast config plugin does not support AppDelegate' that aren't Objective-C(++) yet.",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"react-native-google-cast config plugin does not support AppDelegate' that aren't Objective-C(++) yet.",
"react-native-performance config plugin does not support AppDelegate' that aren't Objective-C(++) yet.",

copy pasta error 🍝

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out. I'll rename both errors 👍

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your work on this, I really appreciate it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem! I am currently working with the team in charge of this to try and take the next steps to get it merged.

const newLine = ' ReactNativePerformance.onAppStarted();\n';
return withMainApplication(expoConfig, async androidConfig => {
if (androidConfig.modResults.language !== 'java') {
throw new Error('react-native-google-cast config plugin does not support kotlin MainActivity yet.');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw new Error('react-native-google-cast config plugin does not support kotlin MainActivity yet.');
throw new Error('react-native-performance config plugin does not support kotlin MainActivity yet.');

@friyiajr friyiajr requested review from fortmarek and removed request for ElviraBurchik May 8, 2023 13:33
@friyiajr friyiajr force-pushed the dfriyia-expo-config-plugin branch from 01f0051 to be04ca9 Compare May 8, 2023 13:35
@friyiajr friyiajr force-pushed the dfriyia-expo-config-plugin branch from be04ca9 to 54ae7f1 Compare May 8, 2023 13:39
@yefim
Copy link

yefim commented Jun 22, 2023

Can we get an update on this? I'd like to use this library in my Expo app

@OwenMelbz
Copy link

Is this suggesting the package is compatible with expo?

@gstcarv
Copy link

gstcarv commented Sep 21, 2023

any plans to merge it?

@ansh
Copy link

ansh commented Oct 25, 2023

@friyiajr Is this ready to be merged?

@markrickert
Copy link

@friyiajr I was able to get this config plugin working with expo sdk 50 (which uses kotlin files now in their prebuild)

const withRequiredAndroidMainApplicationSetup: ConfigPlugin = (expoConfig) => {
  const importStatement =
    'com.shopify.reactnativeperformance.ReactNativePerformance';
  return withMainApplication(expoConfig, async (androidConfig) => {
    const isJava = androidConfig.modResults.language === 'java';
    const newLine = `    ReactNativePerformance.onAppStarted()${
      isJava ? ';' : ''
    }\n`;

    const srcWithNewImport = addImports(
      androidConfig.modResults.contents,
      [importStatement],
      isJava
    );

    androidConfig.modResults.contents = mergeContents({
      tag: 'react-native-performance-onCreate-android',
      src: srcWithNewImport,
      newSrc: newLine,
      anchor: MATCH_ON_CREATE,
      offset: 0,
      comment: '//',
    }).contents;

    return androidConfig;
  });
};

@friyiajr friyiajr closed this by deleting the head repository Aug 28, 2024
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.

7 participants