mirror of https://github.com/status-im/metro.git
Use Delta Bundler for symbolication of errors endpoint
Reviewed By: jeanlauliac Differential Revision: D5913798 fbshipit-source-id: 5a8aaa6b39aa864424eabb94748cbff24b463b81
This commit is contained in:
parent
8302fcb92b
commit
ccbe4bc78c
|
@ -17,6 +17,7 @@ const DeltaPatcher = require('./DeltaPatcher');
|
||||||
const {fromRawMappings} = require('../Bundler/source-map');
|
const {fromRawMappings} = require('../Bundler/source-map');
|
||||||
|
|
||||||
import type {BundleOptions} from '../Server';
|
import type {BundleOptions} from '../Server';
|
||||||
|
import type {MappingsMap} from '../lib/SourceMap';
|
||||||
import type DeltaBundler, {Options as BuildOptions} from './';
|
import type DeltaBundler, {Options as BuildOptions} from './';
|
||||||
import type {DeltaTransformResponse} from './DeltaTransformer';
|
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
|
* Returns the full JS bundle, which can be directly parsed by a JS interpreter
|
||||||
*/
|
*/
|
||||||
|
@ -113,4 +130,5 @@ module.exports = {
|
||||||
deltaBundle,
|
deltaBundle,
|
||||||
fullBundle,
|
fullBundle,
|
||||||
fullSourceMap,
|
fullSourceMap,
|
||||||
|
fullSourceMapObject,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1142,8 +1142,16 @@ class Server {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_sourceMapForURL(reqUrl: string): Promise<SourceMap> {
|
async _sourceMapForURL(reqUrl: string): Promise<SourceMap> {
|
||||||
const options = this._getOptionsFromUrl(reqUrl);
|
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
|
// We're not properly reporting progress here. Reporting should be done
|
||||||
// from within that function.
|
// from within that function.
|
||||||
const building = this.useCachedOrUpdateOrCreateBundle(
|
const building = this.useCachedOrUpdateOrCreateBundle(
|
||||||
|
|
Loading…
Reference in New Issue