Use Delta Bundler for symbolication of errors endpoint

Reviewed By: jeanlauliac

Differential Revision: D5913798

fbshipit-source-id: 5a8aaa6b39aa864424eabb94748cbff24b463b81
This commit is contained in:
Rafael Oleza 2017-09-28 09:11:08 -07:00 committed by Facebook Github Bot
parent 8302fcb92b
commit ccbe4bc78c
2 changed files with 28 additions and 2 deletions

View File

@ -17,6 +17,7 @@ const DeltaPatcher = require('./DeltaPatcher');
const {fromRawMappings} = require('../Bundler/source-map');
import type {BundleOptions} from '../Server';
import type {MappingsMap} from '../lib/SourceMap';
import type DeltaBundler, {Options as BuildOptions} from './';
import type {DeltaTransformResponse} from './DeltaTransformer';
@ -73,6 +74,22 @@ async function fullSourceMap(
});
}
async function fullSourceMapObject(
deltaBundler: DeltaBundler,
options: Options,
): Promise<MappingsMap> {
const {id, delta} = await _build(deltaBundler, {
...options,
wrapModules: true,
});
const deltaPatcher = DeltaPatcher.get(id).applyDelta(delta);
return fromRawMappings(deltaPatcher.getAllModules()).toMap(undefined, {
excludeSource: options.excludeSource,
});
}
/**
* Returns the full JS bundle, which can be directly parsed by a JS interpreter
*/
@ -113,4 +130,5 @@ module.exports = {
deltaBundle,
fullBundle,
fullSourceMap,
fullSourceMapObject,
};

View File

@ -1142,8 +1142,16 @@ class Server {
);
}
_sourceMapForURL(reqUrl: string): Promise<SourceMap> {
const options = this._getOptionsFromUrl(reqUrl);
async _sourceMapForURL(reqUrl: string): Promise<SourceMap> {
const options: DeltaBundlerOptions = this._getOptionsFromUrl(reqUrl);
if (this._opts.useDeltaBundler) {
return await Serializers.fullSourceMapObject(this._deltaBundler, {
...options,
deltaBundleId: this.optionsHash(options),
});
}
// We're not properly reporting progress here. Reporting should be done
// from within that function.
const building = this.useCachedOrUpdateOrCreateBundle(