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:
Rafael Oleza 2017-09-29 05:38:15 -07:00 committed by Facebook Github Bot
parent 07d73a3af2
commit 09ee6d9cbe
2 changed files with 37 additions and 15 deletions

View File

@ -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)', () => {
return server
.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
function scaffoldReq(req) {
if (!req.headers) {

View File

@ -891,7 +891,13 @@ class Server {
req: IncomingMessage,
mres: MultipartResponse,
): {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();
@ -1236,10 +1242,8 @@ class Server {
return {
sourceMapUrl: url.format({
hash: urlObj.hash,
...urlObj,
pathname: pathname.replace(/\.(bundle|delta)$/, '.map'),
query: urlObj.query,
search: urlObj.search,
}),
entryFile,
deltaBundleId,