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

Exclude ios-xcframework folder when resolving modules in Metro #5819

Merged
merged 1 commit into from
May 31, 2023

Conversation

fluiddot
Copy link
Contributor

@fluiddot fluiddot commented May 31, 2023

Fixes the issue mentioned in wordpress-mobile/release-toolkit-gutenberg-mobile#116 (comment).

We need to exclude the ios-xcframework folder in Metro configuration to avoid conflicts when resolving modules. Specifically due to the potential presence of package.json files in Pods.

To test:
The issue this PR aims to fix can only be reproduced when installing the Pods of ios-xcframework.

  1. Run the command: cd ios-xcframework && bundle install && bundle exec pod install && cd ...
  2. Wait until all Pods are installed.
  3. Run the command: npm run bundle:android.
  4. Observe that the bundle is generated properly.

NOTE: The issue could be also reproduced by connecting the Metro server to the app.

PR submission checklist:

  • I have considered adding unit tests where possible.
  • I have considered if this change warrants user-facing release notes more info and have added them to RELEASE-NOTES.txt if necessary.

@fluiddot fluiddot added the [Type] Bug Something isn't working label May 31, 2023
@fluiddot fluiddot added this to the 1.97.0 (22.6) milestone May 31, 2023
@fluiddot fluiddot requested a review from mokagio May 31, 2023 14:44
@fluiddot fluiddot self-assigned this May 31, 2023
@@ -21,6 +21,9 @@ const nodeModulePaths = [
const possibleModulePaths = ( name ) =>
nodeModulePaths.map( ( dir ) => path.join( process.cwd(), dir, name ) );

// Exclude `ios-xcframework` folder to avoid conflicts with packages contained in Pods.
gutenbergMetroConfigCopy.resolver.blockList = [ /ios-xcframework\/.*/ ];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The folder is excluded using the blockList configuration parameter of Metro.

Copy link
Contributor

@geriux geriux left a comment

Choose a reason for hiding this comment

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

LGTM! From what I understand from the referenced PR and these new changes looks like this is the best approach. 🚀

@fluiddot fluiddot enabled auto-merge May 31, 2023 15:05
@fluiddot fluiddot merged commit 97e2915 into trunk May 31, 2023
@fluiddot fluiddot deleted the metro-exclude-ios-xcframework branch May 31, 2023 15:19
@mokagio
Copy link
Contributor

mokagio commented Jun 1, 2023

Great work @fluiddot ! Thank you so much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants