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: don't run install again if a dependency changes its type #7338

Merged
merged 1 commit into from
Apr 30, 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
15 changes: 12 additions & 3 deletions scopes/workspace/install/install.main.runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { CompilerMain, CompilerAspect, CompilationInitiator } from '@teambit/com
import { CLIMain, CommandList, CLIAspect, MainRuntime } from '@teambit/cli';
import chalk from 'chalk';
import { WorkspaceAspect, Workspace, ComponentConfigFile } from '@teambit/workspace';
import { compact, omit, pick } from 'lodash';
import { compact, mapValues, omit, pick } from 'lodash';
import { ProjectManifest } from '@pnpm/types';
import { BitError } from '@teambit/bit-error';
import componentIdToPackageName from '@teambit/legacy/dist/utils/bit/component-id-to-package-name';
Expand Down Expand Up @@ -270,13 +270,13 @@ export class InstallMain {
this.logger.consoleSuccess(compileOutputMessage, compileStartTime);
}
await this.link(linkOpts);
prevManifests.add(hash(current.manifests));
prevManifests.add(manifestsHash(current.manifests));
// We need to clear cache before creating the new component manifests.
this.workspace.consumer.componentLoader.clearComponentsCache();
this.workspace.clearCache();
current = await this._getComponentsManifests(installer, mergedRootPolicy, pmInstallOptions);
installCycle += 1;
} while ((!prevManifests.has(hash(current.manifests)) || hasMissingLocalComponents) && installCycle < 5);
} while ((!prevManifests.has(manifestsHash(current.manifests)) || hasMissingLocalComponents) && installCycle < 5);
await this.workspace.consumer.componentFsCache.deleteAllDependenciesDataCache();
/* eslint-enable no-await-in-loop */
return current.componentDirectoryMap;
Expand Down Expand Up @@ -756,3 +756,12 @@ function hasComponentsFromWorkspaceInMissingDeps({
InstallAspect.addRuntime(InstallMain);

export default InstallMain;

function manifestsHash(manifests: Record<string, ProjectManifest>): string {
// We don't care if the type of the dependency changes as it doesn't change the node_modules structure
const depsByProjectPaths = mapValues(manifests, (manifest) => ({
...manifest.devDependencies,
...manifest.dependencies,
}));
return hash(depsByProjectPaths);
}