Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dep-resolver), always use .bitmap version if exist #7021

Merged
merged 2 commits into from
Feb 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -721,12 +721,11 @@ either, use the ignore file syntax or change the require statement to have a mod
if (this.overridesDependencies.shouldIgnoreComponent(componentId, fileType)) {
return;
}
const getExistingIdFromBitMapOrModel = (): BitId | undefined => {
const getExistingIdFromBitmap = (): BitId | undefined => {
const existingIds = this.consumer.bitmapIdsFromCurrentLane.filterWithoutVersion(componentId);
if (existingIds.length === 1) {
depDebug.versionResolvedFrom = 'BitMap';
return existingIds[0];
}
return existingIds.length === 1 ? existingIds[0] : undefined;
};
const getExistingIdFromModel = (): BitId | undefined => {
if (this.componentFromModel) {
const modelDep = this.componentFromModel.getAllDependenciesIds().searchWithoutVersion(componentId);
if (modelDep) {
Expand All @@ -737,9 +736,13 @@ either, use the ignore file syntax or change the require statement to have a mod
return undefined;
};
const getExistingId = (): BitId | undefined => {
// Happens when the dep is not in the node_modules or it's there without a version
// (it's there without a version when it's in the workspace and it's linked)
if (!version) return getExistingIdFromBitMapOrModel();
const fromBitmap = getExistingIdFromBitmap();
if (fromBitmap) {
depDebug.versionResolvedFrom = 'BitMap';
return fromBitmap;
}
// Happens when the dep is not in the node_modules
if (!version) return getExistingIdFromModel();

// In case it's resolved from the node_modules, and it's also in the ws policy or variants,
// use the resolved version from the node_modules / package folder
Expand All @@ -748,8 +751,8 @@ either, use the ignore file syntax or change the require statement to have a mod
}

// If there is a version in the node_modules/package folder, but it's not in the ws policy,
// prefer the version from the bitmap/model over the version from the node_modules
return getExistingIdFromBitMapOrModel() ?? componentId;
// prefer the version from the model over the version from the node_modules
return getExistingIdFromModel() ?? componentId;
};
const existingId = getExistingId();
if (existingId) {
Expand Down