mirror of https://github.com/status-im/metro.git
packager: Server: make buildBundle() async
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
This commit is contained in:
parent
bdacb9595b
commit
915ab18d53
|
@ -302,37 +302,28 @@ class Server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buildBundle(options: {
|
async buildBundle(options: {entryFile: string, platform?: string}): Promise<Bundle> {
|
||||||
entryFile: string,
|
if (!options.platform) {
|
||||||
platform?: string,
|
options.platform = getPlatformExtension(options.entryFile);
|
||||||
}): Promise<Bundle> {
|
}
|
||||||
return this._bundler.getResolver().then(() => {
|
const opts = bundleOpts(options);
|
||||||
if (!options.platform) {
|
const bundle = await this._bundler.bundle(opts);
|
||||||
options.platform = getPlatformExtension(options.entryFile);
|
const modules = bundle.getModules();
|
||||||
}
|
const nonVirtual = modules.filter(m => !m.virtual);
|
||||||
|
bundleDeps.set(bundle, {
|
||||||
const opts = bundleOpts(options);
|
files: new Map(nonVirtual.map(({sourcePath, meta}) =>
|
||||||
return this._bundler.bundle(opts);
|
[sourcePath, meta != null ? meta.dependencies : []],
|
||||||
}).then(bundle => {
|
)),
|
||||||
const modules = bundle.getModules();
|
idToIndex: new Map(modules.map(({id}, i) => [id, i])),
|
||||||
const nonVirtual = modules.filter(m => !m.virtual);
|
dependencyPairs: new Map(
|
||||||
bundleDeps.set(bundle, {
|
nonVirtual
|
||||||
files: new Map(
|
.filter(({meta}) => meta && meta.dependencyPairs)
|
||||||
nonVirtual
|
/* $FlowFixMe: the filter above ensures `dependencyPairs` is not null. */
|
||||||
.map(({sourcePath, meta}) =>
|
.map(m => [m.sourcePath, m.meta.dependencyPairs])
|
||||||
[sourcePath, meta != null ? meta.dependencies : []])
|
),
|
||||||
),
|
outdated: new Set(),
|
||||||
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;
|
|
||||||
});
|
});
|
||||||
|
return bundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
buildBundleFromUrl(reqUrl: string): Promise<mixed> {
|
buildBundleFromUrl(reqUrl: string): Promise<mixed> {
|
||||||
|
|
Loading…
Reference in New Issue