mirror of https://github.com/status-im/metro.git
Add Source Map support to e2e deltas in chrome debugger
Reviewed By: jeanlauliac Differential Revision: D5917380 fbshipit-source-id: 31391bc03c420b8e7af5c840fbea2fb0dd5f7bbc
This commit is contained in:
parent
07d73a3af2
commit
09ee6d9cbe
|
@ -576,6 +576,35 @@ describe('processRequest', () => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Passes the full url as the sourcemap url', () => {
|
||||||
|
return server
|
||||||
|
.buildBundleFromUrl(
|
||||||
|
'http://localhost:8081/path/to/foo.bundle?dev=false&runModule=false&excludeSource=true',
|
||||||
|
)
|
||||||
|
.then(() =>
|
||||||
|
expect(Bundler.prototype.bundle).toBeCalledWith({
|
||||||
|
assetPlugins: [],
|
||||||
|
dev: false,
|
||||||
|
entryFile: 'path/to/foo.js',
|
||||||
|
entryModuleOnly: false,
|
||||||
|
excludeSource: true,
|
||||||
|
generateSourceMaps: false,
|
||||||
|
hot: true,
|
||||||
|
inlineSourceMap: false,
|
||||||
|
isolateModuleIDs: false,
|
||||||
|
minify: false,
|
||||||
|
onProgress: null,
|
||||||
|
platform: null,
|
||||||
|
resolutionResponse: null,
|
||||||
|
runBeforeMainModule: ['InitializeCore'],
|
||||||
|
runModule: false,
|
||||||
|
sourceMapUrl:
|
||||||
|
'http://localhost:8081/path/to/foo.map?dev=false&runModule=false&excludeSource=true',
|
||||||
|
unbundle: false,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('ignores the `hot` parameter (since it is not used anymore)', () => {
|
it('ignores the `hot` parameter (since it is not used anymore)', () => {
|
||||||
return server
|
return server
|
||||||
.buildBundleFromUrl(
|
.buildBundleFromUrl(
|
||||||
|
@ -662,17 +691,6 @@ describe('processRequest', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('_getOptionsFromUrl', () => {
|
|
||||||
it('ignores protocol, host and port of the passed in URL', () => {
|
|
||||||
const short =
|
|
||||||
'/path/to/entry-file.js??platform=ios&dev=true&minify=false';
|
|
||||||
const long = `http://localhost:8081${short}`;
|
|
||||||
expect(server._getOptionsFromUrl(long)).toEqual(
|
|
||||||
server._getOptionsFromUrl(short),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// ensures that vital properties exist on fake request objects
|
// ensures that vital properties exist on fake request objects
|
||||||
function scaffoldReq(req) {
|
function scaffoldReq(req) {
|
||||||
if (!req.headers) {
|
if (!req.headers) {
|
||||||
|
|
|
@ -891,7 +891,13 @@ class Server {
|
||||||
req: IncomingMessage,
|
req: IncomingMessage,
|
||||||
mres: MultipartResponse,
|
mres: MultipartResponse,
|
||||||
): {options: DeltaBundlerOptions, buildID: string} {
|
): {options: DeltaBundlerOptions, buildID: string} {
|
||||||
const options = this._getOptionsFromUrl(req.url);
|
const options = this._getOptionsFromUrl(
|
||||||
|
url.format({
|
||||||
|
...url.parse(req.url),
|
||||||
|
protocol: 'http',
|
||||||
|
host: req.headers.host,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
const buildID = this.getNewBuildID();
|
const buildID = this.getNewBuildID();
|
||||||
|
|
||||||
|
@ -1236,10 +1242,8 @@ class Server {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
sourceMapUrl: url.format({
|
sourceMapUrl: url.format({
|
||||||
hash: urlObj.hash,
|
...urlObj,
|
||||||
pathname: pathname.replace(/\.(bundle|delta)$/, '.map'),
|
pathname: pathname.replace(/\.(bundle|delta)$/, '.map'),
|
||||||
query: urlObj.query,
|
|
||||||
search: urlObj.search,
|
|
||||||
}),
|
}),
|
||||||
entryFile,
|
entryFile,
|
||||||
deltaBundleId,
|
deltaBundleId,
|
||||||
|
|
Loading…
Reference in New Issue