electrode-native icon indicating copy to clipboard operation
electrode-native copied to clipboard

New v0.41.x update breaks watchFolders support for the MiniApp's metro.config.js

Open LcTwisk opened this issue 4 years ago • 2 comments

Hey!

I'm facing some problems after upgrading to v0.41.1 and would like you guys opinion on how to solve them. In this PR https://github.com/electrode-io/electrode-native/pull/1554 the generated metro.config.js used in the composite was changed significantly and apparently it overrides values from the metro.config.js defined in the MiniApps folder.

The problem originates from the fact that I'm using lerna in my monorepo, and because the metro bundler doesn't support symlinks this forces me to use some wacky workaround to resolve the symlinks created by lerna.

After the changes made in https://github.com/electrode-io/electrode-native/pull/1554 (more specifically these lines, this workaround is not working anymore, the watchFolders are overridden (I discovered this by running a simple ern run-ios from a single MiniApp folder).

Would it be possible to somehow merge the MiniApp's metro.config.js and the generated composite's metro.config.js? Or do you guys have any other suggestions on how to deal with this problem, would be happy to contribute to make this possible 👍

Thanks!

LcTwisk avatar May 08 '20 14:05 LcTwisk

Hi @LcTwisk

Will need a bit more details on this one. What's exactly impacted in your workflow ? Is the problem only for the run-ios / run-android commands or other things ? Are you using a base/custom composite project or not ?

belemaire avatar May 08 '20 18:05 belemaire

Hi @belemaire

Here's a simplified version of my current setup: I've got a mono repo with three NPM packages:

  • foo-miniapp
  • foo-api
  • design-system

The foo-miniapp has both the other two NPM packages as dependencies. Furthermore, I'm using Lerna for easier version management + a more efficient local workflow using symlinks. This makes it easier to, for example, change something in design-system and directly use it in foo-minapp without publishing the design-system package.

The tricky part of this setup is that the react-native metro bundler doesn't respect the symlinks created by Lerna. To overcome this problem, I've modified the metro.config.js to also watch the folders of the 2 dependencies (using the watchFolders config).

After the latest release it seems that the watchFolders is ignored, or most likely overridden by the watchFolders section in the composite's metro.config.js.

To answer your last two questions:

  • I haven't tested other commands than run-ios or run-android, will try to generate a container sometime later
  • I'm indeed using a custom base composite (only containing a index.js and package.json, so no metro.config.js).

Let me know if you've got any more questions!

LcTwisk avatar May 08 '20 21:05 LcTwisk