metro sourcemap add x_metro_module_paths

Reviewed By: davidaurelio

Differential Revision: D6593737

fbshipit-source-id: 3a642d77146308a9df19e16cddfcd0f91cb9d203
This commit is contained in:
Charles Dick 2017-12-20 08:11:07 -08:00 committed by Facebook Github Bot
parent 5eeb88f5a9
commit a66e1f71f6
3 changed files with 17 additions and 2 deletions

View File

@ -23,7 +23,10 @@ export type IndexMapSection = {
export type RawMappings = Array<RawMapping>;
type FBExtensions = {x_facebook_offsets: Array<number>};
type FBExtensions = {
x_facebook_offsets: Array<number>,
x_metro_module_paths: Array<string>,
};
export type {MappingsMap};
export type IndexMap = {

View File

@ -41,11 +41,22 @@ module.exports = ({
sourcePath: '',
};
// Add map of module id -> source to sourcemap
const module_paths = [];
startupModules.forEach(m => {
module_paths[m.id] = m.sourcePath;
});
lazyModules.forEach(m => {
module_paths[m.id] = m.sourcePath;
});
const map = combineSourceMapsAddingOffsets(
[startupModule].concat(lazyModules),
module_paths,
moduleGroups,
options,
);
delete map.x_facebook_offsets[Number.MIN_SAFE_INTEGER];
return map;
};

View File

@ -66,6 +66,7 @@ function combineSourceMaps(
function combineSourceMapsAddingOffsets(
modules: $ReadOnlyArray<ModuleTransportLike | RamModule>,
x_metro_module_paths: Array<string>,
moduleGroups?: ?ModuleGroups,
options?: ?CombineOptions,
): FBIndexMap {
@ -76,7 +77,7 @@ function combineSourceMapsAddingOffsets(
moduleGroups,
options,
);
return {sections, version: 3, x_facebook_offsets};
return {sections, version: 3, x_facebook_offsets, x_metro_module_paths};
}
function combineMaps(