Skip to content

Commit

Permalink
packager: Server: make buildBundle() async
Browse files Browse the repository at this point in the history
Summary: Also remove the unnecessary await of the resolver, because `_bundler.bundle()` already does that.

Reviewed By: davidaurelio

Differential Revision: D4689448

fbshipit-source-id: 3b4fd73b1368f8b00c6eb7483e751387d9856ce9
  • Loading branch information
Jean Lauliac authored and facebook-github-bot committed Mar 13, 2017
1 parent 41f3d0c commit ac452c0
Showing 1 changed file with 21 additions and 30 deletions.
51 changes: 21 additions & 30 deletions packager/src/Server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,37 +302,28 @@ class Server {
}
}

buildBundle(options: {
entryFile: string,
platform?: string,
}): Promise<Bundle> {
return this._bundler.getResolver().then(() => {
if (!options.platform) {
options.platform = getPlatformExtension(options.entryFile);
}

const opts = bundleOpts(options);
return this._bundler.bundle(opts);
}).then(bundle => {
const modules = bundle.getModules();
const nonVirtual = modules.filter(m => !m.virtual);
bundleDeps.set(bundle, {
files: new Map(
nonVirtual
.map(({sourcePath, meta}) =>
[sourcePath, meta != null ? meta.dependencies : []])
),
idToIndex: new Map(modules.map(({id}, i) => [id, i])),
dependencyPairs: new Map(
nonVirtual
.filter(({meta}) => meta && meta.dependencyPairs)
/* $FlowFixMe: the filter above ensures `dependencyPairs` is not null. */
.map(m => [m.sourcePath, m.meta.dependencyPairs])
),
outdated: new Set(),
});
return bundle;
async buildBundle(options: {entryFile: string, platform?: string}): Promise<Bundle> {
if (!options.platform) {
options.platform = getPlatformExtension(options.entryFile);
}
const opts = bundleOpts(options);
const bundle = await this._bundler.bundle(opts);
const modules = bundle.getModules();
const nonVirtual = modules.filter(m => !m.virtual);
bundleDeps.set(bundle, {
files: new Map(nonVirtual.map(({sourcePath, meta}) =>
[sourcePath, meta != null ? meta.dependencies : []],
)),
idToIndex: new Map(modules.map(({id}, i) => [id, i])),
dependencyPairs: new Map(
nonVirtual
.filter(({meta}) => meta && meta.dependencyPairs)
/* $FlowFixMe: the filter above ensures `dependencyPairs` is not null. */
.map(m => [m.sourcePath, m.meta.dependencyPairs])
),
outdated: new Set(),
});
return bundle;
}

buildBundleFromUrl(reqUrl: string): Promise<mixed> {
Expand Down

0 comments on commit ac452c0

Please sign in to comment.