Skip to content

Commit ab999bf

Browse files
authored
fix: ensure assets are registered correctly (#608)
react-native uses a asset registry package to register assets. seems the library and the example app are using different copies of this package, presumably because Expo CLI embeds `@react-native/assets-registry` verbatim in the code during transform. this causes the library not to use the same copy of the package as `react-native`. this results in broken assets in the app. with this change we're ensuring that we always load a single version of the package to ensure assets work. closes #607
1 parent 163b168 commit ab999bf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/react-native-builder-bob/metro-config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ const exclusionList = require('metro-config/src/defaults/exclusionList');
1717
* @returns {import('metro-config').MetroConfig} Metro configuration
1818
*/
1919
const getConfig = (defaultConfig, { root, pkg, project }) => {
20-
const modules = Object.keys({ ...pkg.peerDependencies });
20+
const modules = [
21+
// AssetsRegistry is used internally by React Native to handle asset imports
22+
// This needs to be a singleton so all assets are registered to a single registry
23+
'@react-native/assets-registry',
24+
...Object.keys({ ...pkg.peerDependencies }),
25+
];
2126

2227
/**
2328
* Metro configuration

0 commit comments

Comments
 (0)