@teambit/dependency-resolver 1.0.957 → 1.0.959
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.
- package/dist/dependency-resolver.main.runtime.d.ts +6 -4
- package/dist/dependency-resolver.main.runtime.js +51 -5
- package/dist/dependency-resolver.main.runtime.js.map +1 -1
- package/dist/get-all-policy-pkgs.d.ts +1 -1
- package/dist/get-all-policy-pkgs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/manifest/workspace-manifest-factory.d.ts +5 -0
- package/dist/manifest/workspace-manifest-factory.js +39 -1
- package/dist/manifest/workspace-manifest-factory.js.map +1 -1
- package/dist/policy/env-policy/index.d.ts +1 -1
- package/dist/policy/env-policy/index.js +12 -0
- package/dist/policy/env-policy/index.js.map +1 -1
- package/dist/policy/index.d.ts +2 -2
- package/dist/policy/index.js +12 -0
- package/dist/policy/index.js.map +1 -1
- package/dist/policy/variant-policy/index.d.ts +1 -1
- package/dist/policy/variant-policy/index.js +6 -0
- package/dist/policy/variant-policy/index.js.map +1 -1
- package/dist/{preview-1776705141733.js → preview-1776776950183.js} +2 -2
- package/manifest/workspace-manifest-factory.ts +41 -2
- package/package.json +7 -7
- package/policy/env-policy/index.ts +1 -1
- package/policy/index.ts +2 -1
- package/policy/variant-policy/index.ts +1 -0
|
@@ -10,8 +10,9 @@ import { snapToSemver } from '@teambit/component-package-version';
|
|
|
10
10
|
import type { Logger } from '@teambit/logger';
|
|
11
11
|
import type { DependencyList, PackageName } from '../dependencies';
|
|
12
12
|
import { ComponentDependency } from '../dependencies';
|
|
13
|
-
import type { WorkspacePolicy, EnvPolicy } from '../policy';
|
|
13
|
+
import type { WorkspacePolicy, EnvPolicy, VariantPolicyConfigEntryValue, VariantPolicyEntryValue } from '../policy';
|
|
14
14
|
import { VariantPolicy } from '../policy';
|
|
15
|
+
import { DependencyResolverAspect } from '../dependency-resolver.aspect';
|
|
15
16
|
import type { VariantPolicyEntry } from '../policy/variant-policy';
|
|
16
17
|
import { createVariantPolicyEntry } from '../policy/variant-policy';
|
|
17
18
|
import type { DependencyResolverMain } from '../dependency-resolver.main.runtime';
|
|
@@ -464,6 +465,12 @@ export class WorkspaceManifestFactory {
|
|
|
464
465
|
if (!this.resolveEnvPeersFromRoot) {
|
|
465
466
|
// Legacy behavior: inject env peer deps into each component's manifest
|
|
466
467
|
const envPeerDependencies = await this._getEnvPeerDependencies(component, packageNames);
|
|
468
|
+
// Also include packages that are explicitly listed in the component's
|
|
469
|
+
// dep-resolver config (e.g. with version "+"). Without this, a fresh
|
|
470
|
+
// workspace after `bit new`/`bit fork` hits a chicken-and-egg problem:
|
|
471
|
+
// "+" can't resolve → package absent from manifest → filter excludes it
|
|
472
|
+
// → package never installed.
|
|
473
|
+
const componentExplicitPkgs = this.getComponentExplicitPackages(component);
|
|
467
474
|
if (includeAllEnvPeers ?? true) {
|
|
468
475
|
peerDepsForManifest = envPeerDependencies;
|
|
469
476
|
} else {
|
|
@@ -471,7 +478,8 @@ export class WorkspaceManifestFactory {
|
|
|
471
478
|
return (
|
|
472
479
|
depManifestBeforeFiltering.dependencies[pkgName] ||
|
|
473
480
|
depManifestBeforeFiltering.devDependencies[pkgName] ||
|
|
474
|
-
depManifestBeforeFiltering.peerDependencies[pkgName]
|
|
481
|
+
depManifestBeforeFiltering.peerDependencies[pkgName] ||
|
|
482
|
+
componentExplicitPkgs.has(pkgName)
|
|
475
483
|
);
|
|
476
484
|
});
|
|
477
485
|
|
|
@@ -517,6 +525,20 @@ export class WorkspaceManifestFactory {
|
|
|
517
525
|
return result;
|
|
518
526
|
}
|
|
519
527
|
|
|
528
|
+
/**
|
|
529
|
+
* Collect package names explicitly listed in the component's dep-resolver policy,
|
|
530
|
+
* excluding entries that represent removals ("-" or `{ version: "-" }`).
|
|
531
|
+
*/
|
|
532
|
+
private getComponentExplicitPackages(component: Component): Set<string> {
|
|
533
|
+
const depResolverEntry = component.get(DependencyResolverAspect.id);
|
|
534
|
+
const explicitPolicy = depResolverEntry?.config?.policy ?? {};
|
|
535
|
+
return new Set<string>([
|
|
536
|
+
...nonRemovedEntryNames(explicitPolicy.dependencies),
|
|
537
|
+
...nonRemovedEntryNames(explicitPolicy.devDependencies),
|
|
538
|
+
...nonRemovedEntryNames(explicitPolicy.peerDependencies),
|
|
539
|
+
]);
|
|
540
|
+
}
|
|
541
|
+
|
|
520
542
|
private async _getEnvPeerDependencies(
|
|
521
543
|
component: Component,
|
|
522
544
|
packageNamesFromWorkspace: string[]
|
|
@@ -675,3 +697,20 @@ async function getMissingPackages(component: Component): Promise<{ devMissings:
|
|
|
675
697
|
runtimeMissings,
|
|
676
698
|
};
|
|
677
699
|
}
|
|
700
|
+
|
|
701
|
+
function nonRemovedEntryNames(policySection?: Record<string, VariantPolicyConfigEntryValue>): string[] {
|
|
702
|
+
if (!policySection) return [];
|
|
703
|
+
const names: string[] = [];
|
|
704
|
+
for (const [name, versionSpec] of Object.entries(policySection)) {
|
|
705
|
+
// Skip explicit removals expressed as "-" or as removal objects.
|
|
706
|
+
if (versionSpec !== '-' && !isRemovalObject(versionSpec)) {
|
|
707
|
+
names.push(name);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
return names;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
function isRemovalObject(val: VariantPolicyConfigEntryValue): boolean {
|
|
714
|
+
if (!val || typeof val !== 'object') return false;
|
|
715
|
+
return (val as VariantPolicyEntryValue).version === '-';
|
|
716
|
+
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/dependency-resolver",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.959",
|
|
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": "1.0.
|
|
9
|
+
"version": "1.0.959"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "4.1.2",
|
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
"@teambit/legacy.consumer-config": "0.0.109",
|
|
56
56
|
"@teambit/toolbox.crypto.sha1": "0.0.15",
|
|
57
57
|
"@teambit/toolbox.object.sorter": "0.0.2",
|
|
58
|
-
"@teambit/component": "1.0.
|
|
59
|
-
"@teambit/envs": "1.0.
|
|
60
|
-
"@teambit/aspect-loader": "1.0.
|
|
61
|
-
"@teambit/objects": "0.0.
|
|
62
|
-
"@teambit/graphql": "1.0.
|
|
58
|
+
"@teambit/component": "1.0.959",
|
|
59
|
+
"@teambit/envs": "1.0.959",
|
|
60
|
+
"@teambit/aspect-loader": "1.0.959",
|
|
61
|
+
"@teambit/objects": "0.0.466",
|
|
62
|
+
"@teambit/graphql": "1.0.959"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@types/fs-extra": "9.0.7",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { EnvPolicy, EnvPolicyConfigObject } from './env-policy';
|
|
1
|
+
export { EnvPolicy, EnvPolicyConfigObject, EnvJsoncPolicyEntry, EnvPolicyEnvJsoncConfigObject } from './env-policy';
|
package/policy/index.ts
CHANGED
|
@@ -9,10 +9,11 @@ export {
|
|
|
9
9
|
} from './workspace-policy';
|
|
10
10
|
export {
|
|
11
11
|
VariantPolicy,
|
|
12
|
+
VariantPolicyConfigEntryValue,
|
|
12
13
|
VariantPolicyEntryValue,
|
|
13
14
|
VariantPolicyConfigObject,
|
|
14
15
|
SerializedVariantPolicy,
|
|
15
16
|
VariantPolicyConfigArr,
|
|
16
17
|
} from './variant-policy';
|
|
17
18
|
|
|
18
|
-
export { EnvPolicy, EnvPolicyConfigObject } from './env-policy';
|
|
19
|
+
export { EnvPolicy, EnvPolicyConfigObject, EnvPolicyEnvJsoncConfigObject } from './env-policy';
|