[react-native] Fix source map issue with virtual modules

This commit is contained in:
Amjad Masad 2015-05-15 15:47:44 -07:00
parent cc9ab9ee79
commit 46e1404a76
3 changed files with 11 additions and 4 deletions

View File

@ -285,6 +285,6 @@ function generateSourceMapForVirtualModule(module) {
names: [],
mappings: mappings,
file: module.sourcePath,
sourcesContent: [ module.code ],
sourcesContent: [ module.sourceCode ],
};
}

View File

@ -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([

View File

@ -165,6 +165,7 @@ Packager.prototype._transformModule = function(ppackage, module) {
map: transformed.map,
sourceCode: transformed.sourceCode,
sourcePath: transformed.sourcePath,
virtual: transformed.virtual,
});
});
};