mirror of https://github.com/status-im/metro.git
Fixed images required from node_modules
Summary:This fixes https://github.com/facebook/react-native/issues/6638 by resolving AssetRegistry relatively. Closes https://github.com/facebook/react-native/pull/6822 Reviewed By: davidaurelio Differential Revision: D3144463 Pulled By: bestander fb-gh-sync-id: d3eeb24ae9e08a32f742c50ae5f0314fd33d1b6b fbshipit-source-id: d3eeb24ae9e08a32f742c50ae5f0314fd33d1b6b
This commit is contained in:
parent
30bdfdd370
commit
6f9aad3641
|
@ -612,10 +612,11 @@ class Bundler {
|
|||
};
|
||||
|
||||
const json = JSON.stringify(asset);
|
||||
const assetRegistryPath = 'react-native/Libraries/Image/AssetRegistry';
|
||||
const code =
|
||||
`module.exports = require('AssetRegistry').registerAsset(${json});`;
|
||||
const dependencies = ['AssetRegistry'];
|
||||
const dependencyOffsets = [code.indexOf('AssetRegistry') - 1];
|
||||
`module.exports = require(${JSON.stringify(assetRegistryPath)}).registerAsset(${json});`;
|
||||
const dependencies = [assetRegistryPath];
|
||||
const dependencyOffsets = [code.indexOf(assetRegistryPath) - 1];
|
||||
|
||||
return {
|
||||
asset,
|
||||
|
|
|
@ -107,7 +107,7 @@ class Resolver {
|
|||
cache: opts.cache,
|
||||
shouldThrowOnUnresolvedErrors: (_, platform) => platform === 'ios',
|
||||
transformCode: opts.transformCode,
|
||||
assetDependencies: ['AssetRegistry'],
|
||||
assetDependencies: ['react-native/Libraries/Image/AssetRegistry'],
|
||||
});
|
||||
|
||||
this._getModuleId = options.getModuleId;
|
||||
|
|
Loading…
Reference in New Issue