diff --git a/CHANGELOG.md b/CHANGELOG.md index 5006a80da1ce..b24833bf4697 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [unreleased] +- [#1710](https://github.com/teambit/bit/issues/1710) improve performance of importing an entire collection + ## [14.2.2-dev.2] - 2019-07-24 - add option to pass context to trigger hook diff --git a/src/scope/component-ops/scope-components-importer.js b/src/scope/component-ops/scope-components-importer.js index 2471ec4cc888..332ef1aae777 100644 --- a/src/scope/component-ops/scope-components-importer.js +++ b/src/scope/component-ops/scope-components-importer.js @@ -95,19 +95,18 @@ export default class ScopeComponentsImporter { const idsWithoutNils = removeNils(ids); if (R.isEmpty(idsWithoutNils)) return Promise.resolve([]); const versionDependenciesArr: VersionDependencies[] = await this.importMany(idsWithoutNils, cache); - const importAllVersions = (versionDependencies) => { + + const allIdsWithAllVersions = new BitIds(); + versionDependenciesArr.forEach((versionDependencies) => { const versions = versionDependencies.component.component.listVersions(); const idsWithAllVersions = versions.map((version) => { if (version === versionDependencies.component.version) return null; // imported already const versionId = versionDependencies.component.id; return versionId.changeVersion(version); }); - // $FlowFixMe - const bitIdsWithAllVersions = BitIds.fromArray(idsWithAllVersions.filter(x => x)); - return this.importManyWithoutDependencies(bitIdsWithAllVersions); - }; - - await pMapSeries(versionDependenciesArr, importAllVersions); + allIdsWithAllVersions.push(...removeNils(idsWithAllVersions)); + }); + await this.importManyWithoutDependencies(allIdsWithAllVersions); return versionDependenciesArr; }