import type { ComponentMap, ComponentID, ComponentMain } from '@teambit/component'; import type { Logger } from '@teambit/logger'; import type { PathAbsolute } from '@teambit/toolbox.path.path'; import type { EnvsMain } from '@teambit/envs'; import type { AspectLoaderMain } from '@teambit/aspect-loader'; import type { DependencyResolverMain } from './dependency-resolver.main.runtime'; /** * context of the linking process. */ export type DepLinkerContext = { inCapsule?: boolean; }; export type LinkingOptions = { rewire?: boolean; /** * Whether to create link to @teambit/bit in the root node modules */ linkTeambitBit?: boolean; /** * Whether to create links in the root dir node modules to all core aspects */ linkCoreAspects?: boolean; linkNestedDepsInNM?: boolean; /** * link to another project, so that project could use components from this workspace. * similar to npm/yarn link */ linkToDir?: string; /** * Link peer dependencies of the components to the target project. * Peer dependencies should be singletons, so the project should use the same * version of the peer dependency as the linked in components. */ includePeers?: boolean; /** * whether link should import objects before linking */ fetchObject?: boolean; /** * Link deps which should be linked to the env */ linkDepsResolvedFromEnv?: boolean; /** * non-core packages to link. provided by addPackagesToLink slot of the deps-resolver aspect */ additionalPackagesToLink?: string[]; }; export type LinkDetail = { packageName: string; from: string; to: string; }; export type CoreAspectLinkResult = { aspectId: string; linkDetail: LinkDetail; }; export type DepsLinkedToEnvResult = { componentId: string; linksDetail: LinkDetail[]; }; export type NestedNMDepsLinksResult = { componentId: string; linksDetail: LinkDetail[]; }; export type LinkToDirResult = { componentId: string; linksDetail: LinkDetail; }; export type LinkResults = { teambitBitLink?: CoreAspectLinkResult; coreAspectsLinks?: CoreAspectLinkResult[]; harmonyLink?: LinkDetail; teambitLegacyLink?: LinkDetail; resolvedFromEnvLinks?: DepsLinkedToEnvResult[]; nestedDepsInNmLinks?: NestedNMDepsLinksResult[]; linkToDirResults?: LinkToDirResult[]; /** * non-core packages to link. provided by addPackagesToLink slot of the deps-resolver aspect */ slotOriginatedLinks?: LinkDetail[]; }; export declare class DependencyLinker { private dependencyResolver; private aspectLoader; private componentAspect; private envs; private logger; private rootDir?; private linkingOptions?; private linkingContext; private _currentBitDir; constructor(dependencyResolver: DependencyResolverMain, aspectLoader: AspectLoaderMain, componentAspect: ComponentMain, envs: EnvsMain, logger: Logger, rootDir?: (string | PathAbsolute) | undefined, linkingOptions?: LinkingOptions | undefined, linkingContext?: DepLinkerContext); calculateLinkedDeps(rootDir: string | undefined, componentDirectoryMap: ComponentMap, options?: LinkingOptions): Promise<{ linkedRootDeps: Record; linkResults: LinkResults; }>; private linkDetailToLocalDepEntry; private _calculateLinks; _getLinksToPeers(componentDirectoryMap: ComponentMap, options: { finalRootDir: string; linkToDir: string; }): Promise; linkCoreAspectsAndLegacy(rootDir: string, componentIds?: ComponentID[], options?: Pick): Promise; private linkToDir; /** * Add symlinks from the node_modules in the component's root-dir to the workspace node_modules * of the component. e.g. * /node_modules/comp1/node_modules/ -> /components/comp1/node_modules/ * This is needed because the component is compiled into the dist folder at /node_modules/comp1/dist, * so the files in the dist folder need to find the right dependencies of comp1. */ private addSymlinkFromComponentDirNMToWorkspaceDirNM; private linkDepsResolvedFromEnv; private linkBitAspectIfNotExist; linkBit(dir: string): Promise; private linkNonExistingCoreAspects; private isBitRepoWorkspace; private linkCoreAspect; /** * returns true if it's safe to symlink it later. */ private removeSymlinkTarget; private _getPkgPathFromCurrentBitDir; private linkNonCorePackages; private linkNonAspectCorePackages; }