packager: fix buildBundle() options

Summary: The problem with `bundleOpts` is that it discards Flow typing, so it prevents reinforcing the integration of `Bundler` into `Server`. This changeset removes the `bundleOpts` to solve that issues. Instead, it makes the options explicit so that there is less uncertaintly. I love making options explicit, because they force callsites to take a consicious decision about what is really needed, making them more robust. They also expose oddities that probably needs refatoring, for example having a `resolutionRequest` in the bundle options does not seem correct, it should be an implementation details. Likewise, `onProgress` should probably be exposed differently, as it does not affect the content of the bundle itself.

Reviewed By: davidaurelio

Differential Revision: D4697729

fbshipit-source-id: d543870ba024e7588c10b101fa51429c77cc5ddc
This commit is contained in:
Jean Lauliac
2017-03-14 11:01:21 -07:00
committed by Facebook Github Bot
parent 8ac35c8a0e
commit 4203c9c837
7 changed files with 154 additions and 164 deletions

View File

@@ -8,18 +8,21 @@
*
* @flow
*/
'use strict';
const Server = require('../../../packager/src/Server');
const meta = require('./meta');
const relativizeSourceMap = require('../../../packager/src//lib/relativizeSourceMap');
const writeFile = require('./writeFile');
import type Bundle from '../../../packager/src//Bundler/Bundle';
import type Server from '../../../packager/src//Server';
import type {OutputOptions, RequestOptions} from '../types.flow';
function buildBundle(packagerClient: Server, requestOptions: RequestOptions) {
return packagerClient.buildBundle({
...Server.DEFAULT_BUNDLE_OPTIONS,
...requestOptions,
isolateModuleIDs: true,
});

View File

@@ -8,17 +8,20 @@
*
* @flow
*/
'use strict';
const Server = require('../../../../packager/src/Server');
const asAssets = require('./as-assets');
const asIndexedFile = require('./as-indexed-file');
import type Bundle from '../../../../packager/src//Bundler/Bundle';
import type Server from '../../../../packager/src//Server';
import type {OutputOptions, RequestOptions} from '../../types.flow';
function buildBundle(packagerClient: Server, requestOptions: RequestOptions) {
return packagerClient.buildBundle({
...Server.DEFAULT_BUNDLE_OPTIONS,
...requestOptions,
unbundle: true,
isolateModuleIDs: true,