@teambit/dependency-resolver 0.0.964 → 0.0.965

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -242,9 +242,14 @@ class WorkspaceManifestFactory {
242
242
  exports.WorkspaceManifestFactory = WorkspaceManifestFactory;
243
243
  function filterComponents(dependencyList, componentsToFilterOut) {
244
244
  const filtered = dependencyList.filter(dep => {
245
- // Do not filter non components (like packages) dependencies
246
245
  if (!(dep instanceof _dependencies().ComponentDependency)) {
247
- return true;
246
+ var _dep$getPackageName;
247
+ const depPkgName = (_dep$getPackageName = dep.getPackageName) === null || _dep$getPackageName === void 0 ? void 0 : _dep$getPackageName.call(dep);
248
+ if (!depPkgName) return true;
249
+ // If the package is already in the workspace as a local component,
250
+ // then we don't want to install that package as a dependency to node_modules.
251
+ // Otherwise, it would rewrite the local component inside the root node_modules that is created by bit link.
252
+ return !componentsToFilterOut.some(component => depPkgName === (0, _componentIdToPackageName().default)(component.state._consumer));
248
253
  }
249
254
  // Remove dependencies which has no version (they are new in the workspace)
250
255
  if (!dep.componentId.hasVersion()) return false;
@@ -1 +1 @@
1
- {"version":3,"names":["DEFAULT_CREATE_OPTIONS","filterComponentsFromManifests","createManifestForComponentsWithoutDependencies","dedupe","WorkspaceManifestFactory","constructor","dependencyResolver","aspectLoader","createFromComponents","name","version","rootPolicy","rootDir","components","options","optsWithDefaults","Object","assign","hasRootComponents","componentDependenciesMap","buildComponentDependenciesMap","dependencyFilterFn","dedupedDependencies","getEmptyDedupedDependencies","filter","dep","dependencyId","rootDependencies","dedupeDependencies","mapValues","deps","excludeWorkspaceDependencies","toManifest","componentsManifestsMap","getComponentsManifests","envSelfPeers","getEnvsSelfPeersPolicy","workspaceManifest","WorkspaceManifest","foundEnvs","component","values","push","envPolicy","peersPolicies","map","policy","selfPolicy","mergedPolicies","VariantPolicy","mergePolices","buildResultsP","packageName","componentIdToPackageName","state","_consumer","depList","getDependencies","includeHidden","componentPolicy","getPolicy","additionalDeps","coreAspectIds","getCoreAspectIds","comp","toTypeArray","compIdWithoutVersion","id","split","isExtension","includes","some","c","isEqual","componentId","pkgName","getPackageName","filterComponents","filterResolvedFromEnv","updateDependenciesVersions","depManifest","toDependenciesManifest","dependencies","result","Map","length","results","Promise","all","forEach","currResult","set","dependencyList","updateDependencyVersion","componentsManifests","pMapSeries","has","blankDependencies","devDependencies","peerDependencies","get","getVersion","hasVersion","snapToSemver","getComponentEnvPolicy","manifest","ComponentManifest","SemVer","componentsToFilterOut","filtered","ComponentDependency","existingComponent","find","toString","ignoreVersion","_legacy","isEqualWithoutVersion","fromPolicy","value","resolveFromEnv","pickBy","versionSpec","startsWith"],"sources":["workspace-manifest-factory.ts"],"sourcesContent":["import { AspectLoaderMain } from '@teambit/aspect-loader';\nimport { Component } from '@teambit/component';\nimport componentIdToPackageName from '@teambit/legacy/dist/utils/bit/component-id-to-package-name';\nimport { pickBy, mapValues } from 'lodash';\nimport { SemVer } from 'semver';\nimport pMapSeries from 'p-map-series';\nimport { snapToSemver } from '@teambit/component-package-version';\nimport { ComponentDependency, DependencyList, PackageName } from '../dependencies';\nimport { VariantPolicy, WorkspacePolicy, EnvPolicy } from '../policy';\nimport { DependencyResolverMain } from '../dependency-resolver.main.runtime';\nimport { ComponentsManifestsMap } from '../types';\nimport { ComponentManifest } from './component-manifest';\nimport { dedupeDependencies, DedupedDependencies, getEmptyDedupedDependencies } from './deduping';\nimport { ManifestToJsonOptions, ManifestDependenciesObject, DepObjectValue } from './manifest';\nimport { updateDependencyVersion } from './update-dependency-version';\nimport { WorkspaceManifest } from './workspace-manifest';\n\nexport type DepsFilterFn = (dependencies: DependencyList) => DependencyList;\n\nexport type ComponentDependenciesMap = Map<PackageName, ManifestDependenciesObject>;\nexport interface WorkspaceManifestToJsonOptions extends ManifestToJsonOptions {\n includeDir?: boolean;\n}\n\nexport type CreateFromComponentsOptions = {\n filterComponentsFromManifests: boolean;\n createManifestForComponentsWithoutDependencies: boolean;\n dedupe?: boolean;\n dependencyFilterFn?: DepsFilterFn;\n};\n\nconst DEFAULT_CREATE_OPTIONS: CreateFromComponentsOptions = {\n filterComponentsFromManifests: true,\n createManifestForComponentsWithoutDependencies: true,\n dedupe: true,\n};\nexport class WorkspaceManifestFactory {\n constructor(private dependencyResolver: DependencyResolverMain, private aspectLoader: AspectLoaderMain) {}\n\n async createFromComponents(\n name: string,\n version: SemVer,\n rootPolicy: WorkspacePolicy,\n rootDir: string,\n components: Component[],\n options: CreateFromComponentsOptions = DEFAULT_CREATE_OPTIONS\n ): Promise<WorkspaceManifest> {\n // Make sure to take other default if passed options with only one option\n const optsWithDefaults = Object.assign({}, DEFAULT_CREATE_OPTIONS, options);\n const hasRootComponents = this.dependencyResolver.hasRootComponents();\n const componentDependenciesMap: ComponentDependenciesMap = await this.buildComponentDependenciesMap(\n components,\n optsWithDefaults.filterComponentsFromManifests,\n rootPolicy,\n optsWithDefaults.dependencyFilterFn,\n hasRootComponents\n );\n let dedupedDependencies = getEmptyDedupedDependencies();\n rootPolicy = rootPolicy.filter((dep) => dep.dependencyId !== '@teambit/legacy');\n if (hasRootComponents) {\n const { rootDependencies } = dedupeDependencies(rootPolicy, componentDependenciesMap);\n // We hoist dependencies in order for the IDE to work.\n // For runtime, the peer dependencies are installed inside:\n // <ws root>/node_module/<comp name>/node_module/<comp name>/node_modules\n dedupedDependencies.rootDependencies = mapValues(\n rootDependencies,\n (deps) => deps && excludeWorkspaceDependencies(deps)\n );\n dedupedDependencies.componentDependenciesMap = componentDependenciesMap;\n } else if (options.dedupe) {\n dedupedDependencies = dedupeDependencies(rootPolicy, componentDependenciesMap);\n } else {\n dedupedDependencies.rootDependencies = rootPolicy.toManifest();\n dedupedDependencies.componentDependenciesMap = componentDependenciesMap;\n }\n const componentsManifestsMap = await this.getComponentsManifests(\n dedupedDependencies,\n components,\n optsWithDefaults.createManifestForComponentsWithoutDependencies\n );\n const envSelfPeers = this.getEnvsSelfPeersPolicy(componentsManifestsMap);\n const workspaceManifest = new WorkspaceManifest(\n name,\n version,\n dedupedDependencies.rootDependencies,\n envSelfPeers,\n rootDir,\n componentsManifestsMap\n );\n return workspaceManifest;\n }\n\n private getEnvsSelfPeersPolicy(componentsManifestsMap: ComponentsManifestsMap) {\n const foundEnvs: EnvPolicy[] = [];\n for (const component of componentsManifestsMap.values()) {\n foundEnvs.push(component.envPolicy);\n }\n const peersPolicies = foundEnvs.map((policy) => policy.selfPolicy);\n // TODO: At the moment we are just merge everything, so in case of conflicts one will be taken\n // TODO: once we have root for each env, we should know to handle it differently\n const mergedPolicies = VariantPolicy.mergePolices(peersPolicies);\n return mergedPolicies;\n }\n\n /**\n * Get the components and build a map with the package name (from the component) as key and the dependencies as values\n *\n * @param {Component[]} components\n * @param {boolean} [filterComponentsFromManifests=true] - filter existing components from the dep graphs\n * @returns\n */\n private async buildComponentDependenciesMap(\n components: Component[],\n filterComponentsFromManifests = true,\n rootPolicy: WorkspacePolicy,\n dependencyFilterFn: DepsFilterFn | undefined,\n hasRootComponents?: boolean\n ): Promise<ComponentDependenciesMap> {\n const buildResultsP = components.map(async (component) => {\n const packageName = componentIdToPackageName(component.state._consumer);\n let depList = await this.dependencyResolver.getDependencies(component, { includeHidden: true });\n const componentPolicy = await this.dependencyResolver.getPolicy(component);\n const additionalDeps = {};\n if (hasRootComponents) {\n const coreAspectIds = this.aspectLoader.getCoreAspectIds();\n for (const comp of depList.toTypeArray('component') as ComponentDependency[]) {\n const [compIdWithoutVersion] = comp.id.split('@');\n if (\n !comp.isExtension &&\n !coreAspectIds.includes(compIdWithoutVersion) &&\n components.some((c) => c.id.isEqual(comp.componentId))\n ) {\n const pkgName = comp.getPackageName();\n if (pkgName !== '@teambit/harmony') {\n additionalDeps[pkgName] = `workspace:*`;\n }\n }\n }\n }\n if (filterComponentsFromManifests) {\n depList = filterComponents(depList, components);\n }\n depList = filterResolvedFromEnv(depList, componentPolicy);\n // Remove bit bin from dep list\n depList = depList.filter((dep) => dep.id !== '@teambit/legacy');\n if (dependencyFilterFn) {\n depList = dependencyFilterFn(depList);\n }\n await this.updateDependenciesVersions(component, rootPolicy, depList);\n const depManifest = depList.toDependenciesManifest();\n depManifest.dependencies = {\n ...additionalDeps,\n ...depManifest.dependencies,\n };\n\n return { packageName, depManifest };\n });\n const result: ComponentDependenciesMap = new Map();\n\n if (buildResultsP.length) {\n const results = await Promise.all(buildResultsP);\n results.forEach((currResult) => {\n result.set(currResult.packageName, currResult.depManifest);\n });\n }\n\n return result;\n }\n\n private async updateDependenciesVersions(\n component: Component,\n rootPolicy: WorkspacePolicy,\n dependencyList: DependencyList\n ): Promise<void> {\n const mergedPolicies = await this.dependencyResolver.getPolicy(component);\n dependencyList.forEach((dep) => {\n updateDependencyVersion(dep, rootPolicy, mergedPolicies);\n });\n }\n\n /**\n * Get the components manifests based on the calculated dedupedDependencies\n *\n * @param {DedupedDependencies} dedupedDependencies\n * @param {Component[]} components\n * @returns {ComponentsManifestsMap}\n */\n async getComponentsManifests(\n dedupedDependencies: DedupedDependencies,\n components: Component[],\n createManifestForComponentsWithoutDependencies = true\n ): Promise<ComponentsManifestsMap> {\n const componentsManifests: ComponentsManifestsMap = new Map();\n // don't use Promise.all, along the road this code might import an env from a remote, which can't be done in parallel.\n // otherwise, it may import the same component multiple times, and if fails, the ref (remote-lane) files may be corrupted.\n await pMapSeries(components, async (component) => {\n const packageName = componentIdToPackageName(component.state._consumer);\n if (\n dedupedDependencies.componentDependenciesMap.has(packageName) ||\n createManifestForComponentsWithoutDependencies\n ) {\n const blankDependencies: ManifestDependenciesObject = {\n dependencies: {},\n devDependencies: {},\n peerDependencies: {},\n };\n let dependencies = blankDependencies;\n if (dedupedDependencies.componentDependenciesMap.has(packageName)) {\n dependencies = dedupedDependencies.componentDependenciesMap.get(packageName) as ManifestDependenciesObject;\n }\n\n const getVersion = (): string => {\n if (!component.id.hasVersion()) return '0.0.1-new';\n return snapToSemver(component.id.version as string);\n };\n\n const version = getVersion();\n const envPolicy = await this.dependencyResolver.getComponentEnvPolicy(component);\n const manifest = new ComponentManifest(packageName, new SemVer(version), dependencies, component, envPolicy);\n componentsManifests.set(packageName, manifest);\n }\n });\n return componentsManifests;\n }\n}\n\nfunction filterComponents(dependencyList: DependencyList, componentsToFilterOut: Component[]): DependencyList {\n const filtered = dependencyList.filter((dep) => {\n // Do not filter non components (like packages) dependencies\n if (!(dep instanceof ComponentDependency)) {\n return true;\n }\n // Remove dependencies which has no version (they are new in the workspace)\n if (!dep.componentId.hasVersion()) return false;\n const existingComponent = componentsToFilterOut.find((component) => {\n // For new components, the component has no version but the dependency id has version 0.0.1\n if (!component.id.hasVersion()) {\n return component.id.toString() === dep.componentId.toString({ ignoreVersion: true });\n }\n // We are checking against both component.id._legacy and component.state._consumer.id\n // Because during tag operation, the component.id._legacy has the current version (before the tag)\n // while the component.state._consumer.id has the upcoming version (the version that will be after the tag)\n // The dependency in some cases is already updated to the upcoming version\n return (\n component.id._legacy.isEqualWithoutVersion(dep.componentId._legacy) ||\n component.state._consumer.id.isEqualWithoutVersion(dep.componentId._legacy)\n );\n });\n if (existingComponent) return false;\n return true;\n });\n return filtered;\n}\n\n/**\n * Filter deps which should be resolved from the env, we don't want to install them, they will be linked manually later\n * @param dependencyList\n * @param componentPolicy\n */\nfunction filterResolvedFromEnv(dependencyList: DependencyList, componentPolicy: VariantPolicy): DependencyList {\n const filtered = dependencyList.filter((dep) => {\n const fromPolicy = componentPolicy.find(dep.id);\n if (!fromPolicy) {\n return true;\n }\n if (fromPolicy.value.resolveFromEnv) {\n return false;\n }\n return true;\n });\n return filtered;\n}\n\nfunction excludeWorkspaceDependencies(deps: DepObjectValue): DepObjectValue {\n return pickBy(deps, (versionSpec) => !versionSpec.startsWith('workspace:'));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA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,cAAc,CAACpE,MAAM,CAAEC,GAAG,IAAK;IAC9C,MAAM4F,UAAU,GAAG1D,eAAe,CAACqD,IAAI,CAACvF,GAAG,CAAC0C,EAAE,CAAC;IAC/C,IAAI,CAACkD,UAAU,EAAE;MACf,OAAO,IAAI;IACb;IACA,IAAIA,UAAU,CAACC,KAAK,CAACC,cAAc,EAAE;MACnC,OAAO,KAAK;IACd;IACA,OAAO,IAAI;EACb,CAAC,CAAC;EACF,OAAOV,QAAQ;AACjB;AAEA,SAAS9E,4BAA4B,CAACD,IAAoB,EAAkB;EAC1E,OAAO,IAAA0F,gBAAM,EAAC1F,IAAI,EAAG2F,WAAW,IAAK,CAACA,WAAW,CAACC,UAAU,CAAC,YAAY,CAAC,CAAC;AAC7E"}
1
+ {"version":3,"names":["DEFAULT_CREATE_OPTIONS","filterComponentsFromManifests","createManifestForComponentsWithoutDependencies","dedupe","WorkspaceManifestFactory","constructor","dependencyResolver","aspectLoader","createFromComponents","name","version","rootPolicy","rootDir","components","options","optsWithDefaults","Object","assign","hasRootComponents","componentDependenciesMap","buildComponentDependenciesMap","dependencyFilterFn","dedupedDependencies","getEmptyDedupedDependencies","filter","dep","dependencyId","rootDependencies","dedupeDependencies","mapValues","deps","excludeWorkspaceDependencies","toManifest","componentsManifestsMap","getComponentsManifests","envSelfPeers","getEnvsSelfPeersPolicy","workspaceManifest","WorkspaceManifest","foundEnvs","component","values","push","envPolicy","peersPolicies","map","policy","selfPolicy","mergedPolicies","VariantPolicy","mergePolices","buildResultsP","packageName","componentIdToPackageName","state","_consumer","depList","getDependencies","includeHidden","componentPolicy","getPolicy","additionalDeps","coreAspectIds","getCoreAspectIds","comp","toTypeArray","compIdWithoutVersion","id","split","isExtension","includes","some","c","isEqual","componentId","pkgName","getPackageName","filterComponents","filterResolvedFromEnv","updateDependenciesVersions","depManifest","toDependenciesManifest","dependencies","result","Map","length","results","Promise","all","forEach","currResult","set","dependencyList","updateDependencyVersion","componentsManifests","pMapSeries","has","blankDependencies","devDependencies","peerDependencies","get","getVersion","hasVersion","snapToSemver","getComponentEnvPolicy","manifest","ComponentManifest","SemVer","componentsToFilterOut","filtered","ComponentDependency","depPkgName","existingComponent","find","toString","ignoreVersion","_legacy","isEqualWithoutVersion","fromPolicy","value","resolveFromEnv","pickBy","versionSpec","startsWith"],"sources":["workspace-manifest-factory.ts"],"sourcesContent":["import { AspectLoaderMain } from '@teambit/aspect-loader';\nimport { Component } from '@teambit/component';\nimport componentIdToPackageName from '@teambit/legacy/dist/utils/bit/component-id-to-package-name';\nimport { pickBy, mapValues } from 'lodash';\nimport { SemVer } from 'semver';\nimport pMapSeries from 'p-map-series';\nimport { snapToSemver } from '@teambit/component-package-version';\nimport { ComponentDependency, DependencyList, PackageName } from '../dependencies';\nimport { VariantPolicy, WorkspacePolicy, EnvPolicy } from '../policy';\nimport { DependencyResolverMain } from '../dependency-resolver.main.runtime';\nimport { ComponentsManifestsMap } from '../types';\nimport { ComponentManifest } from './component-manifest';\nimport { dedupeDependencies, DedupedDependencies, getEmptyDedupedDependencies } from './deduping';\nimport { ManifestToJsonOptions, ManifestDependenciesObject, DepObjectValue } from './manifest';\nimport { updateDependencyVersion } from './update-dependency-version';\nimport { WorkspaceManifest } from './workspace-manifest';\n\nexport type DepsFilterFn = (dependencies: DependencyList) => DependencyList;\n\nexport type ComponentDependenciesMap = Map<PackageName, ManifestDependenciesObject>;\nexport interface WorkspaceManifestToJsonOptions extends ManifestToJsonOptions {\n includeDir?: boolean;\n}\n\nexport type CreateFromComponentsOptions = {\n filterComponentsFromManifests: boolean;\n createManifestForComponentsWithoutDependencies: boolean;\n dedupe?: boolean;\n dependencyFilterFn?: DepsFilterFn;\n};\n\nconst DEFAULT_CREATE_OPTIONS: CreateFromComponentsOptions = {\n filterComponentsFromManifests: true,\n createManifestForComponentsWithoutDependencies: true,\n dedupe: true,\n};\nexport class WorkspaceManifestFactory {\n constructor(private dependencyResolver: DependencyResolverMain, private aspectLoader: AspectLoaderMain) {}\n\n async createFromComponents(\n name: string,\n version: SemVer,\n rootPolicy: WorkspacePolicy,\n rootDir: string,\n components: Component[],\n options: CreateFromComponentsOptions = DEFAULT_CREATE_OPTIONS\n ): Promise<WorkspaceManifest> {\n // Make sure to take other default if passed options with only one option\n const optsWithDefaults = Object.assign({}, DEFAULT_CREATE_OPTIONS, options);\n const hasRootComponents = this.dependencyResolver.hasRootComponents();\n const componentDependenciesMap: ComponentDependenciesMap = await this.buildComponentDependenciesMap(\n components,\n optsWithDefaults.filterComponentsFromManifests,\n rootPolicy,\n optsWithDefaults.dependencyFilterFn,\n hasRootComponents\n );\n let dedupedDependencies = getEmptyDedupedDependencies();\n rootPolicy = rootPolicy.filter((dep) => dep.dependencyId !== '@teambit/legacy');\n if (hasRootComponents) {\n const { rootDependencies } = dedupeDependencies(rootPolicy, componentDependenciesMap);\n // We hoist dependencies in order for the IDE to work.\n // For runtime, the peer dependencies are installed inside:\n // <ws root>/node_module/<comp name>/node_module/<comp name>/node_modules\n dedupedDependencies.rootDependencies = mapValues(\n rootDependencies,\n (deps) => deps && excludeWorkspaceDependencies(deps)\n );\n dedupedDependencies.componentDependenciesMap = componentDependenciesMap;\n } else if (options.dedupe) {\n dedupedDependencies = dedupeDependencies(rootPolicy, componentDependenciesMap);\n } else {\n dedupedDependencies.rootDependencies = rootPolicy.toManifest();\n dedupedDependencies.componentDependenciesMap = componentDependenciesMap;\n }\n const componentsManifestsMap = await this.getComponentsManifests(\n dedupedDependencies,\n components,\n optsWithDefaults.createManifestForComponentsWithoutDependencies\n );\n const envSelfPeers = this.getEnvsSelfPeersPolicy(componentsManifestsMap);\n const workspaceManifest = new WorkspaceManifest(\n name,\n version,\n dedupedDependencies.rootDependencies,\n envSelfPeers,\n rootDir,\n componentsManifestsMap\n );\n return workspaceManifest;\n }\n\n private getEnvsSelfPeersPolicy(componentsManifestsMap: ComponentsManifestsMap) {\n const foundEnvs: EnvPolicy[] = [];\n for (const component of componentsManifestsMap.values()) {\n foundEnvs.push(component.envPolicy);\n }\n const peersPolicies = foundEnvs.map((policy) => policy.selfPolicy);\n // TODO: At the moment we are just merge everything, so in case of conflicts one will be taken\n // TODO: once we have root for each env, we should know to handle it differently\n const mergedPolicies = VariantPolicy.mergePolices(peersPolicies);\n return mergedPolicies;\n }\n\n /**\n * Get the components and build a map with the package name (from the component) as key and the dependencies as values\n *\n * @param {Component[]} components\n * @param {boolean} [filterComponentsFromManifests=true] - filter existing components from the dep graphs\n * @returns\n */\n private async buildComponentDependenciesMap(\n components: Component[],\n filterComponentsFromManifests = true,\n rootPolicy: WorkspacePolicy,\n dependencyFilterFn: DepsFilterFn | undefined,\n hasRootComponents?: boolean\n ): Promise<ComponentDependenciesMap> {\n const buildResultsP = components.map(async (component) => {\n const packageName = componentIdToPackageName(component.state._consumer);\n let depList = await this.dependencyResolver.getDependencies(component, { includeHidden: true });\n const componentPolicy = await this.dependencyResolver.getPolicy(component);\n const additionalDeps = {};\n if (hasRootComponents) {\n const coreAspectIds = this.aspectLoader.getCoreAspectIds();\n for (const comp of depList.toTypeArray('component') as ComponentDependency[]) {\n const [compIdWithoutVersion] = comp.id.split('@');\n if (\n !comp.isExtension &&\n !coreAspectIds.includes(compIdWithoutVersion) &&\n components.some((c) => c.id.isEqual(comp.componentId))\n ) {\n const pkgName = comp.getPackageName();\n if (pkgName !== '@teambit/harmony') {\n additionalDeps[pkgName] = `workspace:*`;\n }\n }\n }\n }\n if (filterComponentsFromManifests) {\n depList = filterComponents(depList, components);\n }\n depList = filterResolvedFromEnv(depList, componentPolicy);\n // Remove bit bin from dep list\n depList = depList.filter((dep) => dep.id !== '@teambit/legacy');\n if (dependencyFilterFn) {\n depList = dependencyFilterFn(depList);\n }\n await this.updateDependenciesVersions(component, rootPolicy, depList);\n const depManifest = depList.toDependenciesManifest();\n depManifest.dependencies = {\n ...additionalDeps,\n ...depManifest.dependencies,\n };\n\n return { packageName, depManifest };\n });\n const result: ComponentDependenciesMap = new Map();\n\n if (buildResultsP.length) {\n const results = await Promise.all(buildResultsP);\n results.forEach((currResult) => {\n result.set(currResult.packageName, currResult.depManifest);\n });\n }\n\n return result;\n }\n\n private async updateDependenciesVersions(\n component: Component,\n rootPolicy: WorkspacePolicy,\n dependencyList: DependencyList\n ): Promise<void> {\n const mergedPolicies = await this.dependencyResolver.getPolicy(component);\n dependencyList.forEach((dep) => {\n updateDependencyVersion(dep, rootPolicy, mergedPolicies);\n });\n }\n\n /**\n * Get the components manifests based on the calculated dedupedDependencies\n *\n * @param {DedupedDependencies} dedupedDependencies\n * @param {Component[]} components\n * @returns {ComponentsManifestsMap}\n */\n async getComponentsManifests(\n dedupedDependencies: DedupedDependencies,\n components: Component[],\n createManifestForComponentsWithoutDependencies = true\n ): Promise<ComponentsManifestsMap> {\n const componentsManifests: ComponentsManifestsMap = new Map();\n // don't use Promise.all, along the road this code might import an env from a remote, which can't be done in parallel.\n // otherwise, it may import the same component multiple times, and if fails, the ref (remote-lane) files may be corrupted.\n await pMapSeries(components, async (component) => {\n const packageName = componentIdToPackageName(component.state._consumer);\n if (\n dedupedDependencies.componentDependenciesMap.has(packageName) ||\n createManifestForComponentsWithoutDependencies\n ) {\n const blankDependencies: ManifestDependenciesObject = {\n dependencies: {},\n devDependencies: {},\n peerDependencies: {},\n };\n let dependencies = blankDependencies;\n if (dedupedDependencies.componentDependenciesMap.has(packageName)) {\n dependencies = dedupedDependencies.componentDependenciesMap.get(packageName) as ManifestDependenciesObject;\n }\n\n const getVersion = (): string => {\n if (!component.id.hasVersion()) return '0.0.1-new';\n return snapToSemver(component.id.version as string);\n };\n\n const version = getVersion();\n const envPolicy = await this.dependencyResolver.getComponentEnvPolicy(component);\n const manifest = new ComponentManifest(packageName, new SemVer(version), dependencies, component, envPolicy);\n componentsManifests.set(packageName, manifest);\n }\n });\n return componentsManifests;\n }\n}\n\nfunction filterComponents(dependencyList: DependencyList, componentsToFilterOut: Component[]): DependencyList {\n const filtered = dependencyList.filter((dep) => {\n if (!(dep instanceof ComponentDependency)) {\n const depPkgName = dep.getPackageName?.();\n if (!depPkgName) return true;\n // If the package is already in the workspace as a local component,\n // then we don't want to install that package as a dependency to node_modules.\n // Otherwise, it would rewrite the local component inside the root node_modules that is created by bit link.\n return !componentsToFilterOut.some((component) =>\n depPkgName === componentIdToPackageName(component.state._consumer)\n );\n }\n // Remove dependencies which has no version (they are new in the workspace)\n if (!dep.componentId.hasVersion()) return false;\n const existingComponent = componentsToFilterOut.find((component) => {\n // For new components, the component has no version but the dependency id has version 0.0.1\n if (!component.id.hasVersion()) {\n return component.id.toString() === dep.componentId.toString({ ignoreVersion: true });\n }\n // We are checking against both component.id._legacy and component.state._consumer.id\n // Because during tag operation, the component.id._legacy has the current version (before the tag)\n // while the component.state._consumer.id has the upcoming version (the version that will be after the tag)\n // The dependency in some cases is already updated to the upcoming version\n return (\n component.id._legacy.isEqualWithoutVersion(dep.componentId._legacy) ||\n component.state._consumer.id.isEqualWithoutVersion(dep.componentId._legacy)\n );\n });\n if (existingComponent) return false;\n return true;\n });\n return filtered;\n}\n\n/**\n * Filter deps which should be resolved from the env, we don't want to install them, they will be linked manually later\n * @param dependencyList\n * @param componentPolicy\n */\nfunction filterResolvedFromEnv(dependencyList: DependencyList, componentPolicy: VariantPolicy): DependencyList {\n const filtered = dependencyList.filter((dep) => {\n const fromPolicy = componentPolicy.find(dep.id);\n if (!fromPolicy) {\n return true;\n }\n if (fromPolicy.value.resolveFromEnv) {\n return false;\n }\n return true;\n });\n return filtered;\n}\n\nfunction excludeWorkspaceDependencies(deps: DepObjectValue): DepObjectValue {\n return pickBy(deps, (versionSpec) => !versionSpec.startsWith('workspace:'));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;A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iBAAiB,EAAE,OAAO,KAAK;IACnC,OAAO,IAAI;EACb,CAAC,CAAC;EACF,OAAOH,QAAQ;AACjB;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAS/B,qBAAqB,CAACc,cAA8B,EAAEjC,eAA8B,EAAkB;EAC7G,MAAMkD,QAAQ,GAAGjB,cAAc,CAACpE,MAAM,CAAEC,GAAG,IAAK;IAC9C,MAAM6F,UAAU,GAAG3D,eAAe,CAACsD,IAAI,CAACxF,GAAG,CAAC0C,EAAE,CAAC;IAC/C,IAAI,CAACmD,UAAU,EAAE;MACf,OAAO,IAAI;IACb;IACA,IAAIA,UAAU,CAACC,KAAK,CAACC,cAAc,EAAE;MACnC,OAAO,KAAK;IACd;IACA,OAAO,IAAI;EACb,CAAC,CAAC;EACF,OAAOX,QAAQ;AACjB;AAEA,SAAS9E,4BAA4B,CAACD,IAAoB,EAAkB;EAC1E,OAAO,IAAA2F,gBAAM,EAAC3F,IAAI,EAAG4F,WAAW,IAAK,CAACA,WAAW,CAACC,UAAU,CAAC,YAAY,CAAC,CAAC;AAC7E"}
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.dependencies_dependency-resolver@0.0.964/dist/dependency-resolver.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.dependencies_dependency-resolver@0.0.964/dist/dependency-resolver.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.dependencies_dependency-resolver@0.0.965/dist/dependency-resolver.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.dependencies_dependency-resolver@0.0.965/dist/dependency-resolver.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
@@ -226,9 +226,15 @@ export class WorkspaceManifestFactory {
226
226
 
227
227
  function filterComponents(dependencyList: DependencyList, componentsToFilterOut: Component[]): DependencyList {
228
228
  const filtered = dependencyList.filter((dep) => {
229
- // Do not filter non components (like packages) dependencies
230
229
  if (!(dep instanceof ComponentDependency)) {
231
- return true;
230
+ const depPkgName = dep.getPackageName?.();
231
+ if (!depPkgName) return true;
232
+ // If the package is already in the workspace as a local component,
233
+ // then we don't want to install that package as a dependency to node_modules.
234
+ // Otherwise, it would rewrite the local component inside the root node_modules that is created by bit link.
235
+ return !componentsToFilterOut.some((component) =>
236
+ depPkgName === componentIdToPackageName(component.state._consumer)
237
+ );
232
238
  }
233
239
  // Remove dependencies which has no version (they are new in the workspace)
234
240
  if (!dep.componentId.hasVersion()) return false;
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/dependency-resolver",
3
- "version": "0.0.964",
3
+ "version": "0.0.965",
4
4
  "homepage": "https://bit.dev/teambit/dependencies/dependency-resolver",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.dependencies",
8
8
  "name": "dependency-resolver",
9
- "version": "0.0.964"
9
+ "version": "0.0.965"
10
10
  },
11
11
  "dependencies": {
12
12
  "cli-highlight": "2.1.9",
@@ -31,20 +31,20 @@
31
31
  "@teambit/harmony": "0.4.6",
32
32
  "@pnpm/network.ca-file": "1.0.2",
33
33
  "@teambit/component-version": "0.0.406",
34
- "@teambit/envs": "0.0.964",
35
- "@teambit/aspect-loader": "0.0.964",
36
- "@teambit/component": "0.0.964",
37
- "@teambit/logger": "0.0.740",
34
+ "@teambit/envs": "0.0.965",
35
+ "@teambit/aspect-loader": "0.0.965",
36
+ "@teambit/component": "0.0.965",
37
+ "@teambit/logger": "0.0.741",
38
38
  "@teambit/bit-error": "0.0.402",
39
- "@teambit/graphql": "0.0.964",
40
- "@teambit/bit": "0.0.966",
41
- "@teambit/cli": "0.0.647",
42
- "@teambit/config": "0.0.660",
43
- "@teambit/global-config": "0.0.649",
39
+ "@teambit/graphql": "0.0.965",
40
+ "@teambit/bit": "0.0.967",
41
+ "@teambit/cli": "0.0.648",
42
+ "@teambit/config": "0.0.661",
43
+ "@teambit/global-config": "0.0.650",
44
44
  "@teambit/harmony.modules.requireable-component": "0.0.491",
45
45
  "@teambit/legacy-bit-id": "0.0.421",
46
- "@teambit/snapping": "0.0.279",
47
- "@teambit/isolator": "0.0.964",
46
+ "@teambit/snapping": "0.0.280",
47
+ "@teambit/isolator": "0.0.965",
48
48
  "@teambit/component-issues": "0.0.85",
49
49
  "@teambit/component-package-version": "0.0.421",
50
50
  "@teambit/component-id": "0.0.425"
@@ -64,7 +64,7 @@
64
64
  "@teambit/dependencies.aspect-docs.dependency-resolver": "0.0.157"
65
65
  },
66
66
  "peerDependencies": {
67
- "@teambit/legacy": "1.0.427",
67
+ "@teambit/legacy": "1.0.429",
68
68
  "react": "^16.8.0 || ^17.0.0",
69
69
  "react-dom": "^16.8.0 || ^17.0.0"
70
70
  },