react-native-svg-asset-plugin icon indicating copy to clipboard operation
react-native-svg-asset-plugin copied to clipboard

Metro idles after bundling

Open maxammann opened this issue 3 years ago • 3 comments

The command yarn react-native bundle --platform android --entry-file index.ts --bundle-output out idles for at least a few minutes after it finished.

I found out that the following lines are responsible for this: https://github.com/aeirola/react-native-svg-asset-plugin/blob/master/src/cache.js#L63-L67

This was introduced here: https://github.com/aeirola/react-native-svg-asset-plugin/pull/49/files

When building in release mode there should be no cleanup task scheduled.

maxammann avatar Nov 02 '21 11:11 maxammann

The workaround is to revert to 0.4.0

maxammann avatar Nov 02 '21 11:11 maxammann

@aeirola This is such a great plugin. What do you think the right approach is to fix this? I don't have a good feel for what that would look like, so I've just patched my local copy to skip the cleanup-- but I'd love to see this properly fixed. Thanks!

jeremy303 avatar Apr 03 '24 17:04 jeremy303

Hi, sorry for not reacting to this earlier. Not really using react native anymore, so maintenance of the plugin is unfortunately on hold at the moment.

I know that the cache functionality is a bit fragile, and apparently doesn't work properly in all metro bundling scenarios. Would definitely be good to improve on that.

While I don't have time to fix it myself, I'll be happy to accept PRs that improve the situation. Some possible approaches for solving the issue come to mind:

  • Identifying when metro is in bundle mode and just skip the cleanup step. Not sure how to identify this though
  • See if we can move the cache outside of the working dir. This was not possible when developing the plugin, since react-native refused to import files from outside of the project root. This might have changed in newer versions of react-native and metro.
  • Just revert the cache cleanup logic, and live with the fact that there will be old files lying around. Maybe provide a separate cleanup command to mitigate this?

If anyone is familiar with the latest developments in react-native and metro, please share your thoughts on what kind of a solution would be suitable here. I unfortunately won't have time to familiarise myself with the current state of the react-native toolchain

aeirola avatar Apr 03 '24 17:04 aeirola