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: {
|
||||
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> {
|
||||
|
|
Loading…
Reference in New Issue