Use Delta Bundler to get all bundle assets

Reviewed By: mjesun

Differential Revision: D6255563

fbshipit-source-id: fe08021ef6be8528ddcbb553be62e8a8cf2bcf0a
This commit is contained in:
Rafael Oleza 2017-11-07 08:05:52 -08:00 committed by Facebook Github Bot
parent d4dcd4c6fa
commit 8fe2d588bc
1 changed files with 49 additions and 2 deletions

View File

@ -599,7 +599,7 @@ class Server {
return data;
}
_processAssetsRequest(req: IncomingMessage, res: ServerResponse) {
_processSingleAssetRequest(req: IncomingMessage, res: ServerResponse) {
const urlObj = url.parse(decodeURI(req.url), true);
/* $FlowFixMe: could be empty if the url is invalid */
const assetPath: string = urlObj.pathname.match(/^\/assets\/(.+)$/);
@ -835,7 +835,7 @@ class Server {
this._processOnChangeRequest(req, res);
return;
} else if (pathname.match(/^\/assets\//)) {
this._processAssetsRequest(req, res);
this._processSingleAssetRequest(req, res);
return;
} else if (pathname === '/symbolicate') {
this._symbolicate(req, res);
@ -856,6 +856,9 @@ class Server {
} else if (requestType === 'map') {
await this._processSourceMapUsingDeltaBundler(req, res);
return;
} else if (requestType === 'assets') {
await this._processAssetsRequest(req, res);
return;
}
}
@ -1149,6 +1152,50 @@ class Server {
);
}
async _processAssetsRequest(req: IncomingMessage, res: ServerResponse) {
const mres = MultipartResponse.wrap(req, res);
const {options, buildID} = this._prepareDeltaBundler(req, mres);
const requestingAssetsLogEntry = log(
createActionStartEntry({
action_name: 'Requesting assets',
bundle_url: req.url,
entry_point: options.entryFile,
bundler: 'delta',
}),
);
let assets;
try {
assets = await this.getAssets(options);
} catch (error) {
this._handleError(mres, this.optionsHash(options), error);
this._reporter.update({
buildID,
type: 'bundle_build_failed',
});
return;
}
mres.setHeader('Content-Type', 'application/json');
mres.end(JSON.stringify(assets));
this._reporter.update({
buildID,
type: 'bundle_build_done',
});
log(
createActionEndEntry({
...requestingAssetsLogEntry,
bundler: 'delta',
}),
);
}
_symbolicate(req: IncomingMessage, res: ServerResponse) {
const symbolicatingLogEntry = log(createActionStartEntry('Symbolicating'));