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:
Konstantin Raev 2016-04-06 07:58:36 -07:00 committed by Facebook Github Bot 5
parent 30bdfdd370
commit 6f9aad3641
2 changed files with 5 additions and 4 deletions

View File

@ -612,10 +612,11 @@ class Bundler {
}; };
const json = JSON.stringify(asset); const json = JSON.stringify(asset);
const assetRegistryPath = 'react-native/Libraries/Image/AssetRegistry';
const code = const code =
`module.exports = require('AssetRegistry').registerAsset(${json});`; `module.exports = require(${JSON.stringify(assetRegistryPath)}).registerAsset(${json});`;
const dependencies = ['AssetRegistry']; const dependencies = [assetRegistryPath];
const dependencyOffsets = [code.indexOf('AssetRegistry') - 1]; const dependencyOffsets = [code.indexOf(assetRegistryPath) - 1];
return { return {
asset, asset,

View File

@ -107,7 +107,7 @@ class Resolver {
cache: opts.cache, cache: opts.cache,
shouldThrowOnUnresolvedErrors: (_, platform) => platform === 'ios', shouldThrowOnUnresolvedErrors: (_, platform) => platform === 'ios',
transformCode: opts.transformCode, transformCode: opts.transformCode,
assetDependencies: ['AssetRegistry'], assetDependencies: ['react-native/Libraries/Image/AssetRegistry'],
}); });
this._getModuleId = options.getModuleId; this._getModuleId = options.getModuleId;