mirror of
https://github.com/status-im/metro.git
synced 2025-01-11 11:34:24 +00:00
Use the new Graph object for symbolicating errors
Reviewed By: jeanlauliac Differential Revision: D7275603 fbshipit-source-id: 94a127647f22f7deaaffe649bba6a7ec9353fc03
This commit is contained in:
parent
b9b541542b
commit
1b3d2e126d
@ -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,
|
||||
};
|
||||
|
@ -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;
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user