Summary:
ref: https://github.com/facebook/react-native/pull/28266
Currently, SVG is not recognized as an image in the CLI bundle command, as defined in [assetPathUtils.js](https://github.com/facebook/react-native/blob/main/packages/community-cli-plugin/src/commands/bundle/assetPathUtils.js#L43-L50) . This is the correct behavior, as it ensures that SVG files are copied to the raw folder for Android resources.
However, there is an inconsistency with Image.resolveAssetSource, which does not follow the same classification. Instead, it resolves SVG assets to the drawable folder, leading to blank svg rendering errors in some scenario (codepush).
## Changelog
[Android][Fixed] - getAndroidResourceFolderName() should return raw folder for svg file
Pull Request resolved: https://github.com/facebook/react-native/pull/49452
Test Plan:
1. Use svg file this way `<LocalSvg asset={require('./react-logo.svg')} />`
2. Use `react-native bundle` command to make a bundle and sideload that bundle from sdcard. The svg file should render correctly.
Reviewed By: cortinico
Differential Revision: D69750779
Pulled By: Abbondanzo
fbshipit-source-id: 3af8d4a5da07213cdbb968b070d2507ed897d194
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48458
NOTE: This change is made once and is not guaranteed.
**Motivation**: Requiring Flow parsing for `react-native` and its dependencies in user space can involve friction. For the case of `react-native/assets-registry` → `react-native-web`, I believe we should do the pragmatic thing to relax this requirement.
- This is a convenience stopgap until https://github.com/facebook/react-native/pull/39542 can be stabilised.
- This package is tiny and infrequently modified — I believe it's pragmatic/safe to do a one-time conversion, with the above notice and no changelog (i.e. "experimental" for now).
Resolves https://github.com/facebook/react-native/issues/48349.
Changelog: [Internal]
Reviewed By: cortinico
Differential Revision: D67764460
fbshipit-source-id: 7687fd79c6dea73c234a46e475c1cc745225830b
Summary:
X-link: https://github.com/facebook/metro/pull/1348
Pull Request resolved: https://github.com/facebook/react-native/pull/46371
## Internal
Vector drawable image support was added in D59530172 but importing vector drawable asset types was not supported out of the box. It required custom source transformers like the one added in D60021474. This is because Android cannot load vector drawable XML over the network. Vector drawables are compiled by AAPT as part of the build process. Even though Metro can serve XML, it would never load.
## Summary
This adds some minor checks in the `AssetSourceResolver` to only attempt loading XML asset types from disk on the Android platform. XML assets like vector drawables are precompiled and cannot be served over the network by Metro.
## Changelog
[Android] [Added] - Adds support for importing XML assets as images
Reviewed By: javache
Differential Revision: D62302929
fbshipit-source-id: 01e49ac5b0429d291318984128dfca2dc058149d