Use the new Graph object for symbolicating errors

Reviewed By: jeanlauliac

Differential Revision: D7275603

fbshipit-source-id: 94a127647f22f7deaaffe649bba6a7ec9353fc03
This commit is contained in:
Rafael Oleza 2018-03-20 06:53:22 -07:00 committed by Facebook Github Bot
parent b9b541542b
commit 1b3d2e126d
3 changed files with 44 additions and 14 deletions

View File

@ -25,7 +25,6 @@ import type DeltaTransformer, {
DeltaEntry,
DeltaTransformResponse,
} from '../DeltaTransformer';
import type {BabelSourceMap} from '@babel/core';
export type DeltaOptions = BundleOptions & {
deltaBundleId: ?string,
@ -71,17 +70,6 @@ async function deltaBundle(
};
}
async function fullSourceMapObject(
deltaBundler: DeltaBundler,
options: BundleOptions,
): Promise<BabelSourceMap> {
const {modules} = await _getAllModules(deltaBundler, options);
return fromRawMappings(modules).toMap(undefined, {
excludeSource: options.excludeSource,
});
}
async function _getAllModules(
deltaBundler: DeltaBundler,
options: BundleOptions,
@ -220,6 +208,5 @@ async function _build(
module.exports = {
deltaBundle,
fullSourceMapObject,
getRamBundleInfo,
};

View File

@ -0,0 +1,36 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @format
*/
'use strict';
const {fromRawMappings} = require('metro-source-map');
import type {Graph} from '../DeltaCalculator';
import type {DependencyEdge} from '../traverseDependencies';
import type {BabelSourceMap} from '@babel/core';
function fullSourceMapObject(
pre: $ReadOnlyArray<DependencyEdge>,
graph: Graph,
options: {|+excludeSource: boolean|},
): BabelSourceMap {
const modules = [...pre, ...graph.dependencies.values()].map(module => {
return {
...module.output,
path: module.path,
};
});
return fromRawMappings(modules).toMap(undefined, {
excludeSource: options.excludeSource,
});
}
module.exports = fullSourceMapObject;

View File

@ -19,6 +19,7 @@ const defaultCreateModuleIdFactory = require('../lib/createModuleIdFactory');
const getAllFiles = require('../DeltaBundler/Serializers/getAllFiles');
const getAssets = require('../DeltaBundler/Serializers/getAssets');
const plainJSBundle = require('../DeltaBundler/Serializers/plainJSBundle');
const sourceMapObject = require('../DeltaBundler/Serializers/sourceMapObject');
const sourceMapString = require('../DeltaBundler/Serializers/sourceMapString');
const debug = require('debug')('Metro:Server');
const defaults = require('../defaults');
@ -898,7 +899,13 @@ class Server {
async _sourceMapForURL(reqUrl: string): Promise<MetroSourceMap> {
const options: DeltaOptions = this._getOptionsFromUrl(reqUrl);
return await Serializers.fullSourceMapObject(this._deltaBundler, options);
const {graph, prepend} = await this._getGraphInfo(options, {
rebuild: false,
});
return sourceMapObject(prepend, graph, {
excludeSource: options.excludeSource,
});
}
_handleError(res: ServerResponse, bundleID: string, error: CustomError) {