@teambit/dependency-resolver 0.0.1066 → 0.0.1067

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.
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- require("core-js/modules/es.array.flat.js");
5
4
  require("core-js/modules/es.array.iterator.js");
6
- require("core-js/modules/es.array.unscopables.flat.js");
7
5
  require("core-js/modules/es.promise.js");
8
6
  require("core-js/modules/es.regexp.exec.js");
9
7
  Object.defineProperty(exports, "__esModule", {
@@ -31,6 +29,13 @@ function _componentIdToPackageName() {
31
29
  };
32
30
  return data;
33
31
  }
32
+ function _dependencyResolver() {
33
+ const data = require("@teambit/legacy/dist/consumer/component/dependencies/dependency-resolver");
34
+ _dependencyResolver = function () {
35
+ return data;
36
+ };
37
+ return data;
38
+ }
34
39
  function _lodash() {
35
40
  const data = require("lodash");
36
41
  _lodash = function () {
@@ -178,7 +183,6 @@ class WorkspaceManifestFactory {
178
183
  let depList = await this.dependencyResolver.getDependencies(component, {
179
184
  includeHidden: true
180
185
  });
181
- const componentPolicy = await this.dependencyResolver.getPolicy(component);
182
186
  const additionalDeps = {};
183
187
  if (referenceLocalPackages) {
184
188
  const coreAspectIds = this.aspectLoader.getCoreAspectIds();
@@ -192,10 +196,10 @@ class WorkspaceManifestFactory {
192
196
  }
193
197
  }
194
198
  }
199
+ const depManifestBeforeFiltering = depList.toDependenciesManifest();
195
200
  if (filterComponentsFromManifests !== null && filterComponentsFromManifests !== void 0 ? filterComponentsFromManifests : true) {
196
201
  depList = filterComponents(depList, components);
197
202
  }
198
- depList = filterResolvedFromEnv(depList, componentPolicy);
199
203
  // Remove bit bin from dep list
200
204
  depList = depList.filter(dep => dep.id !== '@teambit/legacy');
201
205
  if (dependencyFilterFn) {
@@ -203,8 +207,25 @@ class WorkspaceManifestFactory {
203
207
  }
204
208
  await this.updateDependenciesVersions(component, rootPolicy, depList);
205
209
  const depManifest = depList.toDependenciesManifest();
206
- const missingRootDeps = rootDependencies ? (0, _lodash().pick)(rootDependencies, getMissingPackages(component)) : {};
207
- depManifest.dependencies = _objectSpread(_objectSpread(_objectSpread({}, missingRootDeps), additionalDeps), depManifest.dependencies);
210
+ const {
211
+ devMissings,
212
+ runtimeMissings
213
+ } = await getMissingPackages(component);
214
+ // Only add missing root deps that are not already in the component manifest
215
+ // We are using depManifestBeforeFiltering to support (rare) cases when a dependency is both:
216
+ // a component in the workspace (bitmap) and a dependency in the workspace.jsonc / package.json
217
+ // this happens for the bit repo itself for the @teambit/component-version component
218
+ // in this case we don't want to add that to the manifest when it's missing, because it will be linked from the
219
+ // workspace
220
+ const unresolvedRuntimeMissingRootDeps = (0, _lodash().pickBy)(rootDependencies, (_version, rootPackageName) => {
221
+ return runtimeMissings.includes(rootPackageName) && !depManifestBeforeFiltering.dependencies[rootPackageName] && !depManifestBeforeFiltering.devDependencies[rootPackageName] && !depManifestBeforeFiltering.peerDependencies[rootPackageName];
222
+ });
223
+ // Only add missing root deps that are not already in the component manifest
224
+ const unresolvedDevMissingRootDeps = (0, _lodash().pickBy)(rootDependencies, (_version, rootPackageName) => {
225
+ return devMissings.includes(rootPackageName) && !depManifestBeforeFiltering.dependencies[rootPackageName] && !depManifestBeforeFiltering.devDependencies[rootPackageName] && !depManifestBeforeFiltering.peerDependencies[rootPackageName];
226
+ });
227
+ depManifest.dependencies = _objectSpread(_objectSpread(_objectSpread({}, unresolvedRuntimeMissingRootDeps), additionalDeps), depManifest.dependencies);
228
+ depManifest.devDependencies = _objectSpread(_objectSpread({}, unresolvedDevMissingRootDeps), depManifest.devDependencies);
208
229
  return {
209
230
  packageName,
210
231
  depManifest
@@ -296,30 +317,34 @@ function filterComponents(dependencyList, componentsToFilterOut) {
296
317
  });
297
318
  return filtered;
298
319
  }
299
-
300
- /**
301
- * Filter deps which should be resolved from the env, we don't want to install them, they will be linked manually later
302
- * @param dependencyList
303
- * @param componentPolicy
304
- */
305
- function filterResolvedFromEnv(dependencyList, componentPolicy) {
306
- const filtered = dependencyList.filter(dep => {
307
- const fromPolicy = componentPolicy.find(dep.id);
308
- if (!fromPolicy) {
309
- return true;
310
- }
311
- if (fromPolicy.value.resolveFromEnv) {
312
- return false;
313
- }
314
- return true;
315
- });
316
- return filtered;
317
- }
318
320
  function excludeWorkspaceDependencies(deps) {
319
321
  return (0, _lodash().pickBy)(deps, versionSpec => !versionSpec.startsWith('file:') && !versionSpec.startsWith('workspace:'));
320
322
  }
321
- function getMissingPackages(component) {
322
- return (0, _lodash().uniq)(Object.values(component.state.issues.getOrCreate(_componentIssues().IssuesClasses.MissingPackagesDependenciesOnFs).data).flat());
323
+ async function getMissingPackages(component) {
324
+ var _component$state$issu;
325
+ const missingPackagesData = (_component$state$issu = component.state.issues.getIssue(_componentIssues().IssuesClasses.MissingPackagesDependenciesOnFs)) === null || _component$state$issu === void 0 ? void 0 : _component$state$issu.data;
326
+ if (!missingPackagesData) return {
327
+ devMissings: [],
328
+ runtimeMissings: []
329
+ };
330
+ // TODO: this is a hack to get it from the legacy, we should take it from the dev files aspect
331
+ // TODO: the reason we don't is that it will make circular dependency between the dep resolver and the dev files aspect
332
+ const devFiles = await _dependencyResolver().DependencyResolver.getDevFiles(component.state._consumer);
333
+ let devMissings = [];
334
+ let runtimeMissings = [];
335
+ Object.entries(missingPackagesData).forEach(([fileName, packages]) => {
336
+ if (devFiles.includes(fileName)) {
337
+ devMissings = (0, _lodash().uniq)([...devMissings, ...packages]);
338
+ } else {
339
+ runtimeMissings = (0, _lodash().uniq)([...runtimeMissings, ...packages]);
340
+ }
341
+ });
342
+ // Remove dev missing which are also runtime missing
343
+ devMissings = (0, _lodash().difference)(devMissings, runtimeMissings);
344
+ return {
345
+ devMissings,
346
+ runtimeMissings
347
+ };
323
348
  }
324
349
 
325
350
  //# sourceMappingURL=workspace-manifest-factory.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["DEFAULT_CREATE_OPTIONS","filterComponentsFromManifests","createManifestForComponentsWithoutDependencies","dedupe","resolveVersionsFromDependenciesOnly","WorkspaceManifestFactory","constructor","dependencyResolver","aspectLoader","createFromComponents","name","version","rootPolicy","rootDir","components","options","optsWithDefaults","Object","assign","hasRootComponents","componentDependenciesMap","buildComponentDependenciesMap","undefined","dependencyFilterFn","referenceLocalPackages","rootDependencies","toManifest","dependencies","dedupedDependencies","getEmptyDedupedDependencies","filter","dep","dependencyId","dedupeDependencies","mapValues","deps","excludeWorkspaceDependencies","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","missingRootDeps","pick","getMissingPackages","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","uniq","issues","getOrCreate","IssuesClasses","MissingPackagesDependenciesOnFs","data","flat"],"sources":["workspace-manifest-factory.ts"],"sourcesContent":["import { AspectLoaderMain } from '@teambit/aspect-loader';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { Component } from '@teambit/component';\nimport componentIdToPackageName from '@teambit/legacy/dist/utils/bit/component-id-to-package-name';\nimport { pickBy, pick, mapValues, uniq } 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 resolveVersionsFromDependenciesOnly?: boolean;\n referenceLocalPackages?: boolean;\n};\n\nconst DEFAULT_CREATE_OPTIONS: CreateFromComponentsOptions = {\n filterComponentsFromManifests: true,\n createManifestForComponentsWithoutDependencies: true,\n dedupe: true,\n resolveVersionsFromDependenciesOnly: false,\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(components, {\n filterComponentsFromManifests: optsWithDefaults.filterComponentsFromManifests,\n rootPolicy: optsWithDefaults.resolveVersionsFromDependenciesOnly ? undefined : rootPolicy,\n dependencyFilterFn: optsWithDefaults.dependencyFilterFn,\n referenceLocalPackages: optsWithDefaults.referenceLocalPackages && hasRootComponents,\n rootDependencies: hasRootComponents ? rootPolicy.toManifest().dependencies : undefined,\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 {\n dependencyFilterFn,\n filterComponentsFromManifests,\n referenceLocalPackages,\n rootDependencies,\n rootPolicy,\n }: {\n dependencyFilterFn?: DepsFilterFn;\n filterComponentsFromManifests?: boolean;\n referenceLocalPackages?: boolean;\n rootDependencies?: Record<string, string>;\n rootPolicy?: WorkspacePolicy;\n }\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 (referenceLocalPackages) {\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 ?? true) {\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 const missingRootDeps = rootDependencies ? pick(rootDependencies, getMissingPackages(component)) : {};\n depManifest.dependencies = {\n ...missingRootDeps,\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 | undefined,\n dependencyList: DependencyList\n ): Promise<void> {\n // If root policy is not passed, it means that installation happens in a capsule\n // and we only resolve versions from the dependencies, not any policies.\n const mergedPolicies = rootPolicy && (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(\n (component) => 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('file:') && !versionSpec.startsWith('workspace:'));\n}\n\nfunction getMissingPackages(component: Component): string[] {\n return uniq(\n Object.values(component.state.issues.getOrCreate(IssuesClasses.MissingPackagesD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AAc,EAAE;MACnC,OAAO,KAAK;IACd;IACA,OAAO,IAAI;EACb,CAAC,CAAC;EACF,OAAOX,QAAQ;AACjB;AAEA,SAAS/E,4BAA4B,CAACD,IAAoB,EAAkB;EAC1E,OAAO,IAAA4F,gBAAM,EAAC5F,IAAI,EAAG6F,WAAW,IAAK,CAACA,WAAW,CAACC,UAAU,CAAC,OAAO,CAAC,IAAI,CAACD,WAAW,CAACC,UAAU,CAAC,YAAY,CAAC,CAAC;AACjH;AAEA,SAASzC,kBAAkB,CAAC5C,SAAoB,EAAY;EAC1D,OAAO,IAAAsF,cAAI,EACTjH,MAAM,CAAC4B,MAAM,CAACD,SAAS,CAACc,KAAK,CAACyE,MAAM,CAACC,WAAW,CAACC,gCAAa,CAACC,+BAA+B,CAAC,CAACC,IAAI,CAAC,CAACC,IAAI,EAAE,CAC7G;AACH"}
1
+ {"version":3,"names":["DEFAULT_CREATE_OPTIONS","filterComponentsFromManifests","createManifestForComponentsWithoutDependencies","dedupe","resolveVersionsFromDependenciesOnly","WorkspaceManifestFactory","constructor","dependencyResolver","aspectLoader","createFromComponents","name","version","rootPolicy","rootDir","components","options","optsWithDefaults","Object","assign","hasRootComponents","componentDependenciesMap","buildComponentDependenciesMap","undefined","dependencyFilterFn","referenceLocalPackages","rootDependencies","toManifest","dependencies","dedupedDependencies","getEmptyDedupedDependencies","filter","dep","dependencyId","dedupeDependencies","mapValues","deps","excludeWorkspaceDependencies","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","additionalDeps","coreAspectIds","getCoreAspectIds","comp","toTypeArray","compIdWithoutVersion","id","split","isExtension","includes","some","c","isEqual","componentId","pkgName","getPackageName","depManifestBeforeFiltering","toDependenciesManifest","filterComponents","updateDependenciesVersions","depManifest","devMissings","runtimeMissings","getMissingPackages","unresolvedRuntimeMissingRootDeps","pickBy","_version","rootPackageName","devDependencies","peerDependencies","unresolvedDevMissingRootDeps","result","Map","length","results","Promise","all","forEach","currResult","set","dependencyList","getPolicy","updateDependencyVersion","componentsManifests","pMapSeries","has","blankDependencies","get","getVersion","hasVersion","snapToSemver","getComponentEnvPolicy","manifest","ComponentManifest","SemVer","componentsToFilterOut","filtered","ComponentDependency","depPkgName","existingComponent","find","toString","ignoreVersion","_legacy","isEqualWithoutVersion","versionSpec","startsWith","missingPackagesData","issues","getIssue","IssuesClasses","MissingPackagesDependenciesOnFs","data","devFiles","DependencyResolver","getDevFiles","entries","fileName","packages","uniq","difference"],"sources":["workspace-manifest-factory.ts"],"sourcesContent":["import { AspectLoaderMain } from '@teambit/aspect-loader';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { Component } from '@teambit/component';\nimport componentIdToPackageName from '@teambit/legacy/dist/utils/bit/component-id-to-package-name';\nimport { DependencyResolver } from '@teambit/legacy/dist/consumer/component/dependencies/dependency-resolver';\nimport { pickBy, mapValues, uniq, difference } 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 resolveVersionsFromDependenciesOnly?: boolean;\n referenceLocalPackages?: boolean;\n};\n\nconst DEFAULT_CREATE_OPTIONS: CreateFromComponentsOptions = {\n filterComponentsFromManifests: true,\n createManifestForComponentsWithoutDependencies: true,\n dedupe: true,\n resolveVersionsFromDependenciesOnly: false,\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(components, {\n filterComponentsFromManifests: optsWithDefaults.filterComponentsFromManifests,\n rootPolicy: optsWithDefaults.resolveVersionsFromDependenciesOnly ? undefined : rootPolicy,\n dependencyFilterFn: optsWithDefaults.dependencyFilterFn,\n referenceLocalPackages: optsWithDefaults.referenceLocalPackages && hasRootComponents,\n rootDependencies: hasRootComponents ? rootPolicy.toManifest().dependencies : undefined,\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 {\n dependencyFilterFn,\n filterComponentsFromManifests,\n referenceLocalPackages,\n rootDependencies,\n rootPolicy,\n }: {\n dependencyFilterFn?: DepsFilterFn;\n filterComponentsFromManifests?: boolean;\n referenceLocalPackages?: boolean;\n rootDependencies?: Record<string, string>;\n rootPolicy?: WorkspacePolicy;\n }\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 additionalDeps = {};\n if (referenceLocalPackages) {\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 const depManifestBeforeFiltering = depList.toDependenciesManifest();\n\n if (filterComponentsFromManifests ?? true) {\n depList = filterComponents(depList, components);\n }\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 const { devMissings, runtimeMissings } = await getMissingPackages(component);\n // Only add missing root deps that are not already in the component manifest\n // We are using depManifestBeforeFiltering to support (rare) cases when a dependency is both:\n // a component in the workspace (bitmap) and a dependency in the workspace.jsonc / package.json\n // this happens for the bit repo itself for the @teambit/component-version component\n // in this case we don't want to add that to the manifest when it's missing, because it will be linked from the\n // workspace\n const unresolvedRuntimeMissingRootDeps = pickBy(rootDependencies, (_version, rootPackageName) => {\n return (\n runtimeMissings.includes(rootPackageName) &&\n !depManifestBeforeFiltering.dependencies[rootPackageName] &&\n !depManifestBeforeFiltering.devDependencies[rootPackageName] &&\n !depManifestBeforeFiltering.peerDependencies[rootPackageName]\n );\n });\n // Only add missing root deps that are not already in the component manifest\n const unresolvedDevMissingRootDeps = pickBy(rootDependencies, (_version, rootPackageName) => {\n return (\n devMissings.includes(rootPackageName) &&\n !depManifestBeforeFiltering.dependencies[rootPackageName] &&\n !depManifestBeforeFiltering.devDependencies[rootPackageName] &&\n !depManifestBeforeFiltering.peerDependencies[rootPackageName]\n );\n });\n depManifest.dependencies = {\n ...unresolvedRuntimeMissingRootDeps,\n ...additionalDeps,\n ...depManifest.dependencies,\n };\n\n depManifest.devDependencies = {\n ...unresolvedDevMissingRootDeps,\n ...depManifest.devDependencies,\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 | undefined,\n dependencyList: DependencyList\n ): Promise<void> {\n // If root policy is not passed, it means that installation happens in a capsule\n // and we only resolve versions from the dependencies, not any policies.\n const mergedPolicies = rootPolicy && (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(\n (component) => 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\nfunction excludeWorkspaceDependencies(deps: DepObjectValue): DepObjectValue {\n return pickBy(deps, (versionSpec) => !versionSpec.startsWith('file:') && !versionSpec.startsWith('workspace:'));\n}\n\nasync function getMissingPackages(component: Component): Promise<{ devMissings: string[]; runtimeMissings: string[] }> {\n const missingPackagesData = component.state.issues.getIssue(IssuesClasses.MissingPackagesDependenciesOnFs)?.data;\n if (!missingPackagesData) return { devMissings: [], runtimeMissings: [] };\n // TODO: this is a hack to get it from the legacy, we should take it from the dev files aspect\n // TODO: the reason we don't is that it will make circular dependency between the dep resolver and the dev files aspect\n const devFiles = await DependencyResolver.getDevFiles(component.state._consumer);\n let devMissings: string[] = [];\n let runtimeMissings: string[] = [];\n Object.entries(missingPackagesData).forEach(([fileName, packages]) => {\n if (devFiles.includes(fileName)) {\n devMissings = uniq([...devMissings, ...packages]);\n } else {\n runtimeMissings = uniq([...runtimeMissings, ...packages]);\n }\n });\n // Remove dev missing which are also runtime missing\n devMissings = difference(devMissings, runtimeMissings);\n return {\n devMissings,\n runtimeMissings,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;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;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAyD;AAAA;AAkBzD,MAAMA,sBAAmD,GAAG;EAC1DC,6BAA6B,EAAE,IAAI;EACnCC,8CAA8C,EAAE,IAAI;EACpDC,MAAM,EAAE,IAAI;EACZC,mCAAmC,EAAE;AACvC,CAAC;AACM,MAAMC,wBAAwB,CAAC;EACpCC,WAAW,CAASC,kBAA0C,EAAUC,YAA8B,EAAE;IAAA,KAApFD,kBAA0C,GAA1CA,kBAA0C;IAAA,KAAUC,YAA8B,GAA9BA,YAA8B;EAAG;EAEzG,MAAMC,oBAAoB,CACxBC,IAAY,EACZC,OAAe,EACfC,UAA2B,EAC3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G,EAAE;EAC9B,IAAIC,eAAyB,GAAG,EAAE;EAClCpE,MAAM,CAAC0H,OAAO,CAACT,mBAAmB,CAAC,CAAC9B,OAAO,CAAC,CAAC,CAACwC,QAAQ,EAAEC,QAAQ,CAAC,KAAK;IACpE,IAAIL,QAAQ,CAAChE,QAAQ,CAACoE,QAAQ,CAAC,EAAE;MAC/BxD,WAAW,GAAG,IAAA0D,cAAI,EAAC,CAAC,GAAG1D,WAAW,EAAE,GAAGyD,QAAQ,CAAC,CAAC;IACnD,CAAC,MAAM;MACLxD,eAAe,GAAG,IAAAyD,cAAI,EAAC,CAAC,GAAGzD,eAAe,EAAE,GAAGwD,QAAQ,CAAC,CAAC;IAC3D;EACF,CAAC,CAAC;EACF;EACAzD,WAAW,GAAG,IAAA2D,oBAAU,EAAC3D,WAAW,EAAEC,eAAe,CAAC;EACtD,OAAO;IACLD,WAAW;IACXC;EACF,CAAC;AACH"}
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.dependencies_dependency-resolver@0.0.1066/dist/dependency-resolver.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.dependencies_dependency-resolver@0.0.1066/dist/dependency-resolver.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.dependencies_dependency-resolver@0.0.1067/dist/dependency-resolver.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.dependencies_dependency-resolver@0.0.1067/dist/dependency-resolver.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
@@ -2,7 +2,8 @@ import { AspectLoaderMain } from '@teambit/aspect-loader';
2
2
  import { IssuesClasses } from '@teambit/component-issues';
3
3
  import { Component } from '@teambit/component';
4
4
  import componentIdToPackageName from '@teambit/legacy/dist/utils/bit/component-id-to-package-name';
5
- import { pickBy, pick, mapValues, uniq } from 'lodash';
5
+ import { DependencyResolver } from '@teambit/legacy/dist/consumer/component/dependencies/dependency-resolver';
6
+ import { pickBy, mapValues, uniq, difference } from 'lodash';
6
7
  import { SemVer } from 'semver';
7
8
  import pMapSeries from 'p-map-series';
8
9
  import { snapToSemver } from '@teambit/component-package-version';
@@ -132,7 +133,6 @@ export class WorkspaceManifestFactory {
132
133
  const buildResultsP = components.map(async (component) => {
133
134
  const packageName = componentIdToPackageName(component.state._consumer);
134
135
  let depList = await this.dependencyResolver.getDependencies(component, { includeHidden: true });
135
- const componentPolicy = await this.dependencyResolver.getPolicy(component);
136
136
  const additionalDeps = {};
137
137
  if (referenceLocalPackages) {
138
138
  const coreAspectIds = this.aspectLoader.getCoreAspectIds();
@@ -150,10 +150,11 @@ export class WorkspaceManifestFactory {
150
150
  }
151
151
  }
152
152
  }
153
+ const depManifestBeforeFiltering = depList.toDependenciesManifest();
154
+
153
155
  if (filterComponentsFromManifests ?? true) {
154
156
  depList = filterComponents(depList, components);
155
157
  }
156
- depList = filterResolvedFromEnv(depList, componentPolicy);
157
158
  // Remove bit bin from dep list
158
159
  depList = depList.filter((dep) => dep.id !== '@teambit/legacy');
159
160
  if (dependencyFilterFn) {
@@ -161,13 +162,41 @@ export class WorkspaceManifestFactory {
161
162
  }
162
163
  await this.updateDependenciesVersions(component, rootPolicy, depList);
163
164
  const depManifest = depList.toDependenciesManifest();
164
- const missingRootDeps = rootDependencies ? pick(rootDependencies, getMissingPackages(component)) : {};
165
+ const { devMissings, runtimeMissings } = await getMissingPackages(component);
166
+ // Only add missing root deps that are not already in the component manifest
167
+ // We are using depManifestBeforeFiltering to support (rare) cases when a dependency is both:
168
+ // a component in the workspace (bitmap) and a dependency in the workspace.jsonc / package.json
169
+ // this happens for the bit repo itself for the @teambit/component-version component
170
+ // in this case we don't want to add that to the manifest when it's missing, because it will be linked from the
171
+ // workspace
172
+ const unresolvedRuntimeMissingRootDeps = pickBy(rootDependencies, (_version, rootPackageName) => {
173
+ return (
174
+ runtimeMissings.includes(rootPackageName) &&
175
+ !depManifestBeforeFiltering.dependencies[rootPackageName] &&
176
+ !depManifestBeforeFiltering.devDependencies[rootPackageName] &&
177
+ !depManifestBeforeFiltering.peerDependencies[rootPackageName]
178
+ );
179
+ });
180
+ // Only add missing root deps that are not already in the component manifest
181
+ const unresolvedDevMissingRootDeps = pickBy(rootDependencies, (_version, rootPackageName) => {
182
+ return (
183
+ devMissings.includes(rootPackageName) &&
184
+ !depManifestBeforeFiltering.dependencies[rootPackageName] &&
185
+ !depManifestBeforeFiltering.devDependencies[rootPackageName] &&
186
+ !depManifestBeforeFiltering.peerDependencies[rootPackageName]
187
+ );
188
+ });
165
189
  depManifest.dependencies = {
166
- ...missingRootDeps,
190
+ ...unresolvedRuntimeMissingRootDeps,
167
191
  ...additionalDeps,
168
192
  ...depManifest.dependencies,
169
193
  };
170
194
 
195
+ depManifest.devDependencies = {
196
+ ...unresolvedDevMissingRootDeps,
197
+ ...depManifest.devDependencies,
198
+ };
199
+
171
200
  return { packageName, depManifest };
172
201
  });
173
202
  const result: ComponentDependenciesMap = new Map();
@@ -275,31 +304,29 @@ function filterComponents(dependencyList: DependencyList, componentsToFilterOut:
275
304
  return filtered;
276
305
  }
277
306
 
278
- /**
279
- * Filter deps which should be resolved from the env, we don't want to install them, they will be linked manually later
280
- * @param dependencyList
281
- * @param componentPolicy
282
- */
283
- function filterResolvedFromEnv(dependencyList: DependencyList, componentPolicy: VariantPolicy): DependencyList {
284
- const filtered = dependencyList.filter((dep) => {
285
- const fromPolicy = componentPolicy.find(dep.id);
286
- if (!fromPolicy) {
287
- return true;
288
- }
289
- if (fromPolicy.value.resolveFromEnv) {
290
- return false;
291
- }
292
- return true;
293
- });
294
- return filtered;
295
- }
296
-
297
307
  function excludeWorkspaceDependencies(deps: DepObjectValue): DepObjectValue {
298
308
  return pickBy(deps, (versionSpec) => !versionSpec.startsWith('file:') && !versionSpec.startsWith('workspace:'));
299
309
  }
300
310
 
301
- function getMissingPackages(component: Component): string[] {
302
- return uniq(
303
- Object.values(component.state.issues.getOrCreate(IssuesClasses.MissingPackagesDependenciesOnFs).data).flat()
304
- );
311
+ async function getMissingPackages(component: Component): Promise<{ devMissings: string[]; runtimeMissings: string[] }> {
312
+ const missingPackagesData = component.state.issues.getIssue(IssuesClasses.MissingPackagesDependenciesOnFs)?.data;
313
+ if (!missingPackagesData) return { devMissings: [], runtimeMissings: [] };
314
+ // TODO: this is a hack to get it from the legacy, we should take it from the dev files aspect
315
+ // TODO: the reason we don't is that it will make circular dependency between the dep resolver and the dev files aspect
316
+ const devFiles = await DependencyResolver.getDevFiles(component.state._consumer);
317
+ let devMissings: string[] = [];
318
+ let runtimeMissings: string[] = [];
319
+ Object.entries(missingPackagesData).forEach(([fileName, packages]) => {
320
+ if (devFiles.includes(fileName)) {
321
+ devMissings = uniq([...devMissings, ...packages]);
322
+ } else {
323
+ runtimeMissings = uniq([...runtimeMissings, ...packages]);
324
+ }
325
+ });
326
+ // Remove dev missing which are also runtime missing
327
+ devMissings = difference(devMissings, runtimeMissings);
328
+ return {
329
+ devMissings,
330
+ runtimeMissings,
331
+ };
305
332
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/dependency-resolver",
3
- "version": "0.0.1066",
3
+ "version": "0.0.1067",
4
4
  "homepage": "https://bit.cloud/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.1066"
9
+ "version": "0.0.1067"
10
10
  },
11
11
  "dependencies": {
12
12
  "cli-highlight": "2.1.9",
@@ -18,7 +18,6 @@
18
18
  "is-builtin-module": "3.1.0",
19
19
  "resolve-from": "5.0.0",
20
20
  "graphql-tag": "2.12.1",
21
- "comment-json": "3.0.3",
22
21
  "semver": "7.3.4",
23
22
  "p-limit": "3.1.0",
24
23
  "execa": "2.1.0",
@@ -32,22 +31,22 @@
32
31
  "@pnpm/network.ca-file": "1.0.2",
33
32
  "@teambit/legacy-bit-id": "0.0.423",
34
33
  "@teambit/component-id": "0.0.427",
35
- "@teambit/envs": "0.0.1066",
36
- "@teambit/aspect-loader": "0.0.1066",
37
- "@teambit/component": "0.0.1066",
38
- "@teambit/logger": "0.0.812",
34
+ "@teambit/envs": "0.0.1067",
35
+ "@teambit/aspect-loader": "0.0.1067",
36
+ "@teambit/component": "0.0.1067",
37
+ "@teambit/logger": "0.0.813",
39
38
  "@teambit/bit-error": "0.0.402",
40
- "@teambit/graphql": "0.0.1066",
41
- "@teambit/bit-roots": "0.0.56",
42
- "@teambit/bit": "0.1.53",
43
- "@teambit/cli": "0.0.719",
44
- "@teambit/config": "0.0.732",
45
- "@teambit/global-config": "0.0.721",
39
+ "@teambit/graphql": "0.0.1067",
40
+ "@teambit/bit-roots": "0.0.57",
41
+ "@teambit/bit": "0.1.54",
42
+ "@teambit/cli": "0.0.720",
43
+ "@teambit/config": "0.0.733",
44
+ "@teambit/global-config": "0.0.722",
46
45
  "@teambit/harmony.modules.requireable-component": "0.0.491",
47
- "@teambit/snapping": "0.0.381",
48
- "@teambit/isolator": "0.0.1066",
46
+ "@teambit/snapping": "0.0.382",
47
+ "@teambit/isolator": "0.0.1067",
49
48
  "@teambit/component-package-version": "0.0.422",
50
- "@teambit/component-issues": "0.0.91",
49
+ "@teambit/component-issues": "0.0.92",
51
50
  "@teambit/component-version": "0.0.408"
52
51
  },
53
52
  "devDependencies": {
@@ -65,7 +64,7 @@
65
64
  "@teambit/dependencies.aspect-docs.dependency-resolver": "0.0.161"
66
65
  },
67
66
  "peerDependencies": {
68
- "@teambit/legacy": "1.0.499",
67
+ "@teambit/legacy": "1.0.500",
69
68
  "react": "^16.8.0 || ^17.0.0",
70
69
  "react-dom": "^16.8.0 || ^17.0.0"
71
70
  },