From 46e1404a76f8368f176db0526efcbdd333913236 Mon Sep 17 00:00:00 2001 From: Amjad Masad Date: Fri, 15 May 2015 15:47:44 -0700 Subject: [PATCH] [react-native] Fix source map issue with virtual modules --- react-packager/src/Packager/Package.js | 2 +- .../src/Packager/__tests__/Packager-test.js | 12 +++++++++--- react-packager/src/Packager/index.js | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/react-packager/src/Packager/Package.js b/react-packager/src/Packager/Package.js index c621f747..eca709d5 100644 --- a/react-packager/src/Packager/Package.js +++ b/react-packager/src/Packager/Package.js @@ -285,6 +285,6 @@ function generateSourceMapForVirtualModule(module) { names: [], mappings: mappings, file: module.sourcePath, - sourcesContent: [ module.code ], + sourcesContent: [ module.sourceCode ], }; } diff --git a/react-packager/src/Packager/__tests__/Packager-test.js b/react-packager/src/Packager/__tests__/Packager-test.js index 9babda54..901c467b 100644 --- a/react-packager/src/Packager/__tests__/Packager-test.js +++ b/react-packager/src/Packager/__tests__/Packager-test.js @@ -150,7 +150,9 @@ describe('Packager', function() { sourceCode: 'module.exports = ' + JSON.stringify(imgModule_DEPRECATED) + ';', - sourcePath: '/root/img/img.png' + sourcePath: '/root/img/img.png', + virtual: true, + map: undefined, }); var imgModule = { @@ -172,13 +174,17 @@ describe('Packager', function() { sourceCode: 'module.exports = require("AssetRegistry").registerAsset(' + JSON.stringify(imgModule) + ');', - sourcePath: '/root/img/new_image.png' + sourcePath: '/root/img/new_image.png', + virtual: true, + map: undefined, }); expect(p.addModule.mock.calls[4][0]).toEqual({ code: 'lol module.exports = {"json":true}; lol', sourceCode: 'module.exports = {"json":true};', - sourcePath: '/root/file.json' + sourcePath: '/root/file.json', + map: undefined, + virtual: true, }); expect(p.finalize.mock.calls[0]).toEqual([ diff --git a/react-packager/src/Packager/index.js b/react-packager/src/Packager/index.js index e647f764..e5afefe7 100644 --- a/react-packager/src/Packager/index.js +++ b/react-packager/src/Packager/index.js @@ -165,6 +165,7 @@ Packager.prototype._transformModule = function(ppackage, module) { map: transformed.map, sourceCode: transformed.sourceCode, sourcePath: transformed.sourcePath, + virtual: transformed.virtual, }); }); };