Skip to content

Commit

Permalink
Fixed images required from node_modules
Browse files Browse the repository at this point in the history
Summary:This fixes #6638 by resolving AssetRegistry relatively.
Closes #6822

Reviewed By: davidaurelio

Differential Revision: D3144463

Pulled By: bestander

fb-gh-sync-id: d3eeb24ae9e08a32f742c50ae5f0314fd33d1b6b
fbshipit-source-id: d3eeb24ae9e08a32f742c50ae5f0314fd33d1b6b
  • Loading branch information
bestander authored and Facebook Github Bot 5 committed Apr 6, 2016
1 parent 1bdb6ca commit d0566d8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
"mkdirp": "^0.5.1",
"module-deps": "^3.9.1",
"node-fetch": "^1.3.3",
"node-haste": "~2.9.4",
"node-haste": "~2.9.6",
"opn": "^3.0.2",
"optimist": "^0.6.1",
"progress": "^1.1.8",
Expand Down
7 changes: 4 additions & 3 deletions packager/react-packager/src/Bundler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packager/react-packager/src/Resolver/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d0566d8

Please sign in to comment.