@teambit/dependency-resolver 1.0.1096 → 1.0.1098

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.
Files changed (32) hide show
  1. package/dist/dependency-installer.d.ts +67 -2
  2. package/dist/dependency-installer.js +155 -1
  3. package/dist/dependency-installer.js.map +1 -1
  4. package/dist/dependency-linker.d.ts +23 -0
  5. package/dist/dependency-linker.js +82 -4
  6. package/dist/dependency-linker.js.map +1 -1
  7. package/dist/dependency-resolver-workspace-config.d.ts +5 -1
  8. package/dist/dependency-resolver-workspace-config.js.map +1 -1
  9. package/dist/dependency-resolver.main.runtime.d.ts +34 -0
  10. package/dist/dependency-resolver.main.runtime.js +80 -1
  11. package/dist/dependency-resolver.main.runtime.js.map +1 -1
  12. package/dist/exceptions/index.d.ts +1 -0
  13. package/dist/exceptions/index.js +13 -0
  14. package/dist/exceptions/index.js.map +1 -1
  15. package/dist/exceptions/self-hosted-virtual-store-transition.d.ts +16 -0
  16. package/dist/exceptions/self-hosted-virtual-store-transition.js +36 -0
  17. package/dist/exceptions/self-hosted-virtual-store-transition.js.map +1 -0
  18. package/dist/hoisted-resolution-bridge.d.ts +78 -0
  19. package/dist/hoisted-resolution-bridge.js +348 -0
  20. package/dist/hoisted-resolution-bridge.js.map +1 -0
  21. package/dist/hoisted-resolution-bridge.spec.d.ts +1 -0
  22. package/dist/hoisted-resolution-bridge.spec.js +233 -0
  23. package/dist/hoisted-resolution-bridge.spec.js.map +1 -0
  24. package/dist/index.d.ts +2 -1
  25. package/dist/index.js +37 -0
  26. package/dist/index.js.map +1 -1
  27. package/dist/package-manager.d.ts +39 -0
  28. package/dist/package-manager.js.map +1 -1
  29. package/dist/{preview-1785958716068.js → preview-1786365057144.js} +2 -2
  30. package/exceptions/index.ts +1 -0
  31. package/exceptions/self-hosted-virtual-store-transition.ts +26 -0
  32. package/package.json +28 -27
@@ -1 +1 @@
1
- {"version":3,"names":["_isBuiltinModule","data","_interopRequireDefault","require","_path","_lodash","_fsExtra","_resolveFrom","_bvm","_pkgModules","_dependenciesFs","_bitError","_aspectLoader","_exceptions","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","DEFAULT_LINKING_OPTIONS","rewire","linkTeambitBit","linkCoreAspects","linkDepsResolvedFromEnv","linkNestedDepsInNM","DependencyLinker","constructor","dependencyResolver","aspectLoader","componentAspect","envs","logger","rootDir","linkingOptions","linkingContext","_currentBitDir","findCurrentBvmDir","calculateLinkedDeps","componentDirectoryMap","options","linkResults","_calculateLinks","localLinks","teambitBitLink","linkDetailToLocalDepEntry","linkDetail","coreAspectsLinks","link","harmonyLink","teambitLegacyLink","slotOriginatedLinks","map","l","resolvedFromEnvLinks","linksDetail","linkToDirResults","linkedRootDeps","fromEntries","key","packageName","from","outputMessage","inCapsule","setStatusLine","debug","omit","startTime","process","hrtime","result","finalRootDir","linkingOpts","assign","RootDirNotDefined","linkToDir","components","toArray","component","includePeers","_getLinksToPeers","nestedDepsInNmLinks","addSymlinkFromComponentDirNMToWorkspaceDirNM","componentIds","_dir","comp","id","undefined","linkCoreAspectsAndLegacy","registeredPackages","additionalPackagesToLink","pkgName","linkNonCorePackages","consoleSuccess","peers","Set","Promise","all","depList","getDependencies","peerList","byLifecycle","dependency","getPackageName","add","fromDir","path","join","toDir","Array","componentId","to","componentIdsWithoutVersions","toString","ignoreVersion","isBitRepoWorkspace","bitLink","linkBitAspectIfNotExist","mainAspectPath","mainAspect","MainAspectNotLinkable","hasLocalInstallation","linkNonExistingCoreAspects","targetModulesDir","linkNonAspectCorePackages","targetDir","results","componentPackageName","componentIdToPackageName","state","_consumer","rootNodeModules","getPackagesFoldersToLink","dir","parent","folders","fs","readdirSync","withFileTypes","dirent","name","startsWith","isDirectory","isSymbolicLink","dirPath","moduleName","moduleNameToResolve","isBuiltinModule","resolvedModuleFrom","resolveModuleFromDir","origPath","resolveModuleDirFromFile","flatten","linksOfAllComponents","compDirNM","existsSync","innerNMofComponentInNM","isPathSymlink","packagesFoldersToLink","ensureDirSync","oneComponentLinks","folderEntry","linkTarget","linkSrc","info","filteredLinks","compact","componentsNeedLinks","componentsNeedLinksP","policy","getPolicy","resolvedFromEnv","getResolvedFromEnv","env","getEnv","componentNeedLink","envsStringIds","obj","uniqEnvIds","uniq","host","getHost","resolvedEnvIds","resolveMultipleComponentIds","resolvedAspects","resolveAspects","resolvedAspectsIndex","reduce","acc","curr","getId","allLinksP","entry","oneComponentLinksP","entries","depEntry","dependencyId","envDir","aspectPath","resolvedModule","console","depsLinkedToEnvResult","mainAspectId","existing","find","linkBit","aspectId","target","shouldSymlink","removeSymlinkTarget","src","_getPkgPathFromCurrentBitDir","ensureDir","dirname","opts","coreAspectsIds","getCoreAspectIds","filtered","getCoreAspectName","linkCoreAspect","syncCoreAspectLinksForEnvs","idsInWorkspace","authoredCoreAspects","some","hoistedStoreDir","pathExistsSync","links","getCoreAspectPackageName","linkPath","hasCompiledMain","removeCoreAspectBootstrapLink","_getCoreAspectSourceDir","packagesToLink","createLinks","skipIfSymlinkValid","err","warn","message","pkgDir","main","readJsonSync","workspaceDir","isUsableSource","_realpathIsInside","fromBvmDir","fromRunningBit","getAspectDir","realpathSync","sep","lstatSync","remove","aspectDir","isAspectDirExist","module","resolve","CoreAspectLinkError","targetPath","targetStat","fromDirBvm","fromDirBitRepo","getDistDirForDevEnv","distDir","isDistDirExist","newDir","resolvedPath","NonAspectCorePackageLinkError","exports","moduleDirectory","includes","nmDir","__dirname","substring","indexOf","paths","BitError","moduleId","silent","resolveFrom","resolvedModulePath","NM","slice","lastIndexOf","start","end","split","basename","versionStr","head","folderPath","stat"],"sources":["dependency-linker.ts"],"sourcesContent":["import isBuiltinModule from 'is-builtin-module';\nimport path from 'path';\nimport { uniq, compact, flatten, head, omit } from 'lodash';\nimport type { Stats } from 'fs';\nimport fs from 'fs-extra';\nimport resolveFrom from 'resolve-from';\nimport { findCurrentBvmDir } from '@teambit/bvm.path';\nimport type { ComponentMap, Component, ComponentID, ComponentMain } from '@teambit/component';\nimport type { Logger } from '@teambit/logger';\nimport type { PathAbsolute } from '@teambit/toolbox.path.path';\nimport { componentIdToPackageName } from '@teambit/pkg.modules.component-package-name';\nimport { createLinks } from '@teambit/dependencies.fs.linked-dependencies';\nimport { BitError } from '@teambit/bit-error';\nimport type { EnvsMain } from '@teambit/envs';\nimport type { AspectLoaderMain } from '@teambit/aspect-loader';\nimport { getCoreAspectName, getCoreAspectPackageName, getAspectDir } from '@teambit/aspect-loader';\nimport {\n MainAspectNotLinkable,\n RootDirNotDefined,\n CoreAspectLinkError,\n NonAspectCorePackageLinkError,\n} from './exceptions';\nimport type { DependencyResolverMain } from './dependency-resolver.main.runtime';\n\n/**\n * context of the linking process.\n */\nexport type DepLinkerContext = {\n inCapsule?: boolean;\n};\n\nexport type LinkingOptions = {\n rewire?: boolean;\n /**\n * Whether to create link to @teambit/bit in the root node modules\n */\n linkTeambitBit?: boolean;\n /**\n * Whether to create links in the root dir node modules to all core aspects\n */\n linkCoreAspects?: boolean;\n\n linkNestedDepsInNM?: boolean;\n\n /**\n * link to another project, so that project could use components from this workspace.\n * similar to npm/yarn link\n */\n linkToDir?: string;\n\n /**\n * Link peer dependencies of the components to the target project.\n * Peer dependencies should be singletons, so the project should use the same\n * version of the peer dependency as the linked in components.\n */\n includePeers?: boolean;\n\n /**\n * whether link should import objects before linking\n */\n fetchObject?: boolean;\n\n /**\n * Link deps which should be linked to the env\n */\n linkDepsResolvedFromEnv?: boolean;\n\n /**\n * non-core packages to link. provided by addPackagesToLink slot of the deps-resolver aspect\n */\n additionalPackagesToLink?: string[];\n};\n\nconst DEFAULT_LINKING_OPTIONS: LinkingOptions = {\n rewire: false,\n linkTeambitBit: true,\n linkCoreAspects: true,\n linkDepsResolvedFromEnv: true,\n linkNestedDepsInNM: true,\n};\n\nexport type LinkDetail = { packageName: string; from: string; to: string };\n\nexport type CoreAspectLinkResult = {\n aspectId: string;\n linkDetail: LinkDetail;\n};\n\nexport type DepsLinkedToEnvResult = {\n componentId: string;\n linksDetail: LinkDetail[];\n};\n\nexport type NestedNMDepsLinksResult = {\n componentId: string;\n linksDetail: LinkDetail[];\n};\n\nexport type LinkToDirResult = {\n componentId: string;\n linksDetail: LinkDetail;\n};\n\nexport type LinkResults = {\n teambitBitLink?: CoreAspectLinkResult;\n coreAspectsLinks?: CoreAspectLinkResult[];\n harmonyLink?: LinkDetail;\n teambitLegacyLink?: LinkDetail;\n resolvedFromEnvLinks?: DepsLinkedToEnvResult[];\n nestedDepsInNmLinks?: NestedNMDepsLinksResult[];\n linkToDirResults?: LinkToDirResult[];\n /**\n * non-core packages to link. provided by addPackagesToLink slot of the deps-resolver aspect\n */\n slotOriginatedLinks?: LinkDetail[];\n};\n\ntype NestedModuleFolderEntry = {\n moduleName: string;\n path: string;\n origPath?: string;\n};\n\nexport class DependencyLinker {\n private _currentBitDir: string | null;\n\n constructor(\n private dependencyResolver: DependencyResolverMain,\n\n private aspectLoader: AspectLoaderMain,\n\n private componentAspect: ComponentMain,\n\n private envs: EnvsMain,\n\n private logger: Logger,\n\n private rootDir?: string | PathAbsolute,\n\n private linkingOptions?: LinkingOptions,\n\n private linkingContext: DepLinkerContext = {}\n ) {\n this._currentBitDir = findCurrentBvmDir();\n }\n\n async calculateLinkedDeps(\n rootDir: string | undefined,\n componentDirectoryMap: ComponentMap<string>,\n options: LinkingOptions = {}\n ): Promise<{ linkedRootDeps: Record<string, string>; linkResults: LinkResults }> {\n const linkResults = await this._calculateLinks(rootDir, componentDirectoryMap, options);\n const localLinks: Array<[string, string]> = [];\n if (linkResults.teambitBitLink) {\n localLinks.push(this.linkDetailToLocalDepEntry(linkResults.teambitBitLink.linkDetail));\n }\n if (linkResults.coreAspectsLinks) {\n linkResults.coreAspectsLinks.forEach((link) => {\n localLinks.push(this.linkDetailToLocalDepEntry(link.linkDetail));\n });\n }\n if (linkResults.harmonyLink) {\n localLinks.push(this.linkDetailToLocalDepEntry(linkResults.harmonyLink));\n }\n if (linkResults.teambitLegacyLink) {\n localLinks.push(this.linkDetailToLocalDepEntry(linkResults.teambitLegacyLink));\n }\n if (linkResults.slotOriginatedLinks) {\n localLinks.push(...linkResults.slotOriginatedLinks.map((l) => this.linkDetailToLocalDepEntry(l)));\n }\n if (linkResults.resolvedFromEnvLinks) {\n linkResults.resolvedFromEnvLinks.forEach((link) => {\n link.linksDetail.forEach((linkDetail) => {\n localLinks.push(this.linkDetailToLocalDepEntry(linkDetail));\n });\n });\n }\n if (linkResults.linkToDirResults) {\n linkResults.linkToDirResults.forEach((link) => {\n localLinks.push(this.linkDetailToLocalDepEntry(link.linksDetail));\n });\n }\n return {\n linkedRootDeps: Object.fromEntries(localLinks.map(([key, value]) => [key, `link:${value}`])),\n linkResults,\n };\n }\n\n private linkDetailToLocalDepEntry(linkDetail: LinkDetail): [string, string] {\n return [linkDetail.packageName, linkDetail.from];\n }\n\n private async _calculateLinks(\n rootDir: string | undefined,\n componentDirectoryMap: ComponentMap<string>,\n options: LinkingOptions = {}\n ): Promise<LinkResults> {\n const outputMessage = this.linkingContext?.inCapsule\n ? `(capsule) linking components in root dir: ${rootDir || this.rootDir}`\n : 'linking components';\n if (!this.linkingContext?.inCapsule) {\n this.logger.setStatusLine(outputMessage);\n }\n this.logger.debug('linking components with options', omit(options, ['consumer']));\n const startTime = process.hrtime();\n\n let result: LinkResults = {};\n const finalRootDir = rootDir || this.rootDir;\n const linkingOpts = Object.assign({}, DEFAULT_LINKING_OPTIONS, this.linkingOptions || {}, options || {});\n if (!finalRootDir) {\n throw new RootDirNotDefined();\n }\n if (options.linkToDir) {\n const components = componentDirectoryMap.toArray().map(([component]) => component);\n const linkToDirResults = await this.linkToDir(finalRootDir, options.linkToDir, components);\n result.linkToDirResults = linkToDirResults;\n if (options.includePeers) {\n result.linkToDirResults.push(\n ...(await this._getLinksToPeers(componentDirectoryMap, { finalRootDir, linkToDir: options.linkToDir }))\n );\n }\n return result;\n }\n\n // Link deps which should be linked to the env\n if (linkingOpts.linkDepsResolvedFromEnv) {\n result.resolvedFromEnvLinks = await this.linkDepsResolvedFromEnv(componentDirectoryMap);\n }\n if (linkingOpts.linkNestedDepsInNM) {\n result.nestedDepsInNmLinks = this.addSymlinkFromComponentDirNMToWorkspaceDirNM(\n finalRootDir,\n componentDirectoryMap\n );\n }\n\n // We remove the version since it used in order to check if it's core aspects, and the core aspects arrived from aspect loader without versions\n const componentIds: ComponentID[] = [];\n componentDirectoryMap.map((_dir, comp) => {\n componentIds.push(comp.id);\n return undefined;\n });\n result = {\n ...result,\n ...(await this.linkCoreAspectsAndLegacy(finalRootDir, componentIds, linkingOpts)),\n };\n const registeredPackages = this.linkingOptions?.additionalPackagesToLink || [];\n result.slotOriginatedLinks = registeredPackages.map((pkgName) => this.linkNonCorePackages(finalRootDir, pkgName));\n\n if (!this.linkingContext?.inCapsule) {\n this.logger.consoleSuccess(outputMessage, startTime);\n }\n return result;\n }\n\n async _getLinksToPeers(\n componentDirectoryMap: ComponentMap<string>,\n options: {\n finalRootDir: string;\n linkToDir: string;\n }\n ): Promise<LinkToDirResult[]> {\n const peers = new Set<string>();\n await Promise.all(\n componentDirectoryMap.toArray().map(async ([component]) => {\n const depList = this.dependencyResolver.getDependencies(component);\n const peerList = depList.byLifecycle('peer');\n peerList.forEach((dependency) => {\n if (dependency.getPackageName) {\n peers.add(dependency.getPackageName());\n }\n });\n })\n );\n const fromDir = path.join(options.finalRootDir, 'node_modules');\n const toDir = path.join(options.linkToDir, 'node_modules');\n return Array.from(peers).map((packageName) => ({\n componentId: packageName,\n linksDetail: {\n packageName,\n from: path.join(fromDir, packageName),\n to: path.join(toDir, packageName),\n },\n }));\n }\n\n async linkCoreAspectsAndLegacy(\n rootDir: string,\n componentIds: ComponentID[] = [],\n options: Pick<LinkingOptions, 'linkTeambitBit' | 'linkCoreAspects'> = {}\n ) {\n const result: LinkResults = {};\n const componentIdsWithoutVersions: string[] = [];\n componentIds.map((id) => {\n componentIdsWithoutVersions.push(id.toString({ ignoreVersion: true }));\n return undefined;\n });\n const linkingOpts = Object.assign({}, DEFAULT_LINKING_OPTIONS, this.linkingOptions || {}, options || {});\n if (linkingOpts.linkTeambitBit && !this.isBitRepoWorkspace(rootDir)) {\n const bitLink = await this.linkBitAspectIfNotExist(\n path.join(rootDir, 'node_modules'),\n componentIdsWithoutVersions\n );\n result.teambitBitLink = bitLink;\n }\n\n let mainAspectPath = result.teambitBitLink?.linkDetail.from;\n if (!mainAspectPath && this.aspectLoader.mainAspect) {\n if (!this.aspectLoader.mainAspect.packageName) {\n throw new MainAspectNotLinkable();\n }\n mainAspectPath = path.join(rootDir, 'node_modules', this.aspectLoader.mainAspect.packageName);\n }\n if (linkingOpts.linkCoreAspects && !this.isBitRepoWorkspace(rootDir)) {\n const hasLocalInstallation = !linkingOpts.linkTeambitBit;\n if (mainAspectPath) {\n result.coreAspectsLinks = await this.linkNonExistingCoreAspects(componentIdsWithoutVersions, {\n targetModulesDir: path.join(rootDir, 'node_modules'),\n mainAspectPath,\n hasLocalInstallation,\n });\n } else {\n result.coreAspectsLinks = [];\n }\n }\n\n if (mainAspectPath) {\n // the following line links @teambit/legacy to the workspace node_modules. at this point, we removed all\n // @teambit/legacy occurrences from the repo but others/external repos still have it.\n result.teambitLegacyLink = this.linkNonAspectCorePackages(rootDir, 'legacy', mainAspectPath);\n result.harmonyLink = this.linkNonAspectCorePackages(rootDir, 'harmony', mainAspectPath);\n }\n return result;\n }\n\n private async linkToDir(rootDir: string, targetDir: string, components: Component[]): Promise<LinkToDirResult[]> {\n const results: LinkToDirResult[] = components.map((component) => {\n const componentPackageName = componentIdToPackageName(component.state._consumer);\n return {\n componentId: component.id.toString(),\n linksDetail: {\n packageName: componentPackageName,\n from: path.join(rootDir, 'node_modules', componentPackageName),\n to: path.join(targetDir, 'node_modules', componentPackageName),\n },\n };\n });\n return results;\n }\n\n /**\n * Add symlinks from the node_modules in the component's root-dir to the workspace node_modules\n * of the component. e.g.\n * <ws-root>/node_modules/comp1/node_modules/<dep> -> <ws-root>/components/comp1/node_modules/<dep>\n * This is needed because the component is compiled into the dist folder at <ws-root>/node_modules/comp1/dist,\n * so the files in the dist folder need to find the right dependencies of comp1.\n */\n private addSymlinkFromComponentDirNMToWorkspaceDirNM(\n rootDir: string,\n componentDirectoryMap: ComponentMap<string>\n ): NestedNMDepsLinksResult[] {\n const rootNodeModules = path.join(rootDir, 'node_modules');\n const getPackagesFoldersToLink = (dir: string, parent?: string): NestedModuleFolderEntry[] => {\n const folders = fs\n .readdirSync(dir, { withFileTypes: true })\n .filter((dirent) => {\n if (dirent.name.startsWith('.')) {\n return false;\n }\n return dirent.isDirectory() || dirent.isSymbolicLink();\n })\n .map((dirent) => {\n const dirPath = path.join(dir, dirent.name);\n const moduleName = parent ? `${parent}/${dirent.name}` : dirent.name;\n // If we have a folder with a name of built in module (like events)\n // the resolve from will resolve it from the core, so it will return something like 'events'\n // instead of the path.\n // adding a '/' at the end solve this\n const moduleNameToResolve = isBuiltinModule(moduleName) ? `${moduleName}/` : moduleName;\n // This is a scoped package, need to go inside\n if (dirent.name.startsWith('@')) {\n return getPackagesFoldersToLink(dirPath, dirent.name);\n }\n\n if (dirent.isSymbolicLink()) {\n const resolvedModuleFrom = resolveModuleFromDir(dir, moduleNameToResolve);\n if (!resolvedModuleFrom) {\n return {\n moduleName,\n path: dirPath,\n };\n }\n return {\n origPath: dirPath,\n moduleName,\n path: resolveModuleDirFromFile(resolvedModuleFrom, moduleName),\n };\n }\n return {\n moduleName,\n path: dirPath,\n };\n });\n return flatten(folders);\n };\n const linksOfAllComponents = componentDirectoryMap.toArray().map(([component, dir]) => {\n const compDirNM = path.join(dir, 'node_modules');\n if (!fs.existsSync(compDirNM)) return undefined;\n // TODO: support modules with scoped packages (start with @) - we need to make this logic 2 levels\n\n const componentPackageName = componentIdToPackageName(component.state._consumer);\n const innerNMofComponentInNM = path.join(rootNodeModules, componentPackageName);\n // If the folder itself is a symlink, do not try to symlink inside it\n if (isPathSymlink(innerNMofComponentInNM)) {\n return undefined;\n }\n const packagesFoldersToLink: NestedModuleFolderEntry[] = getPackagesFoldersToLink(compDirNM);\n fs.ensureDirSync(innerNMofComponentInNM);\n\n const oneComponentLinks: LinkDetail[] = packagesFoldersToLink.map((folderEntry: NestedModuleFolderEntry) => {\n const linkTarget = path.join(innerNMofComponentInNM, 'node_modules', folderEntry?.moduleName);\n const linkSrc = folderEntry.path;\n // This works as well, consider using it instead\n // const linkSrc = folderEntry.origPath || folderEntry.path;\n const origPath = folderEntry.origPath ? `(${folderEntry.origPath})` : '';\n const linkDetail: LinkDetail = {\n packageName: folderEntry.moduleName,\n from: `${linkSrc} ${origPath}`,\n to: linkTarget,\n };\n this.logger.info(\n `linking nested dependency ${folderEntry.moduleName} for component ${component}. link src: ${linkSrc} link target: ${linkTarget}`\n );\n return linkDetail;\n });\n\n const filteredLinks = compact(oneComponentLinks);\n return {\n componentId: component.id.toString(),\n linksDetail: filteredLinks,\n };\n });\n const filteredLinks = compact(linksOfAllComponents);\n return filteredLinks;\n }\n\n private async linkDepsResolvedFromEnv(\n componentDirectoryMap: ComponentMap<string>\n ): Promise<Array<DepsLinkedToEnvResult>> {\n const componentsNeedLinks: {\n component: Component;\n dir: string;\n env;\n resolvedFromEnv;\n envId?: string;\n envDir?: string;\n }[] = [];\n\n const componentsNeedLinksP = componentDirectoryMap.toArray().map(async ([component, dir]) => {\n const policy = await this.dependencyResolver.getPolicy(component);\n const resolvedFromEnv = policy.getResolvedFromEnv();\n // Nothing should be resolved from env, do nothing\n if (!resolvedFromEnv.length) {\n return;\n }\n const env = this.envs.getEnv(component);\n const componentNeedLink = {\n component,\n dir,\n env,\n resolvedFromEnv,\n };\n componentsNeedLinks.push(componentNeedLink);\n });\n\n await Promise.all(componentsNeedLinksP);\n // Stop if there are not components needs to be linked\n if (!componentsNeedLinks || !componentsNeedLinks.length) return [];\n const envsStringIds = componentsNeedLinks.map((obj) => obj.env.id);\n const uniqEnvIds = uniq(envsStringIds);\n const host = this.componentAspect.getHost();\n const resolvedEnvIds = await host.resolveMultipleComponentIds(uniqEnvIds);\n const resolvedAspects = await host.resolveAspects(undefined, resolvedEnvIds);\n const resolvedAspectsIndex = resolvedAspects.reduce((acc, curr) => {\n if (curr.getId) {\n acc[curr.getId] = curr;\n }\n return acc;\n }, {});\n const allLinksP = componentsNeedLinks.map(async (entry) => {\n const oneComponentLinksP: Array<LinkDetail | undefined> = entry.resolvedFromEnv.entries.map(async (depEntry) => {\n const linkTarget = path.join(entry.dir, 'node_modules', depEntry.dependencyId);\n const envDir = resolvedAspectsIndex[entry.env.id].aspectPath;\n const resolvedModule = resolveModuleFromDir(envDir, depEntry.dependencyId);\n if (!resolvedModule) {\n this.logger.console(`could not resolve ${depEntry.dependencyId} from env directory ${envDir}`);\n return undefined;\n }\n const linkSrc = resolveModuleDirFromFile(resolvedModule, depEntry.dependencyId);\n const linkDetail: LinkDetail = {\n packageName: depEntry.dependencyId,\n from: linkSrc,\n to: linkTarget,\n };\n this.logger.info(\n `linking dependency ${depEntry.dependencyId} from env directory ${envDir}. link src: ${linkSrc} link target: ${linkTarget}`\n );\n\n return linkDetail;\n });\n const oneComponentLinks = await Promise.all(oneComponentLinksP);\n const filteredLinks = compact(oneComponentLinks);\n const depsLinkedToEnvResult: DepsLinkedToEnvResult = {\n componentId: entry.component.id.toString(),\n linksDetail: filteredLinks,\n };\n return depsLinkedToEnvResult;\n });\n return Promise.all(allLinksP);\n }\n\n private async linkBitAspectIfNotExist(\n dir: string,\n componentIds: string[]\n ): Promise<CoreAspectLinkResult | undefined> {\n if (!this.aspectLoader.mainAspect) return undefined;\n const mainAspectId = this.aspectLoader.mainAspect.id;\n const existing = componentIds.find((id) => {\n return id === mainAspectId;\n });\n\n if (existing) {\n return undefined;\n }\n const linkDetail = await this.linkBit(dir);\n if (!linkDetail) return undefined;\n return {\n aspectId: mainAspectId,\n linkDetail,\n };\n }\n\n async linkBit(dir: string): Promise<LinkDetail | undefined> {\n if (!this.aspectLoader.mainAspect.packageName) {\n throw new MainAspectNotLinkable();\n }\n const target = path.join(dir, this.aspectLoader.mainAspect.packageName);\n const shouldSymlink = this.removeSymlinkTarget(target);\n if (!shouldSymlink) return undefined;\n const src =\n this._getPkgPathFromCurrentBitDir(this.aspectLoader.mainAspect.packageName) ?? this.aspectLoader.mainAspect.path;\n await fs.ensureDir(path.dirname(target));\n return { packageName: this.aspectLoader.mainAspect.packageName, from: src, to: target };\n }\n\n private async linkNonExistingCoreAspects(\n componentIds: string[],\n opts: {\n targetModulesDir: string;\n mainAspectPath: string;\n hasLocalInstallation?: boolean;\n }\n ): Promise<CoreAspectLinkResult[]> {\n const coreAspectsIds = this.aspectLoader.getCoreAspectIds();\n const filtered = coreAspectsIds.filter((aspectId) => {\n // Remove bit aspect\n if (aspectId === this.aspectLoader.mainAspect?.id) {\n return false;\n }\n // TODO: use the aspect id once default scope is resolved and the component dir map has the id with scope\n const name = getCoreAspectName(aspectId);\n const existing = componentIds.find((componentId) => {\n return componentId === name || componentId === aspectId;\n });\n if (existing) {\n return false;\n }\n return true;\n });\n\n this.logger.debug(`linkNonExistingCoreAspects: linking the following core aspects ${filtered.join()}`);\n\n const results = filtered.map((id) => this.linkCoreAspect(id, opts));\n return compact(results);\n }\n\n /**\n * The core aspects are phantom dependencies of the published envs - an env requires\n * `@teambit/builder` (and `@teambit/ui`, `@teambit/pkg`...) without declaring it, and relies on the\n * running bit installation to provide it. `linkCoreAspectsAndLegacy` is what normally satisfies\n * that, by linking bit's own copies into the workspace's root node_modules.\n *\n * A workspace that authors the core aspects has them as source components instead, so they're\n * excluded from that linking - such a workspace must build and load its own. That leaves the envs'\n * phantom require resolving to a source component, which has no `main` until it's been compiled,\n * so an env resolved from the root (see `resolveEnvsFromRoots`) fails to load during install -\n * before the compile step that would have made it resolvable.\n *\n * Bridge that gap by linking bit's own (always compiled) copies into pnpm's hoisted store. That\n * directory is on the module resolution path of packages inside the virtual store - the published\n * envs - and not on the resolution path of the workspace's own components, so the envs bootstrap\n * against the running bit while the workspace still builds and loads its own core aspects.\n *\n * This is a reconciler - each core aspect converges to \"link present iff its source is still\n * uncompiled\", so the same call both creates the links during bootstrap and removes them once the\n * source components have been compiled.\n *\n * Only reached from a workspace with `linkCoreAspects` off, i.e. one that authors them.\n */\n async syncCoreAspectLinksForEnvs(rootDir: string, componentIds: ComponentID[]): Promise<void> {\n const idsInWorkspace = componentIds.map((id) => id.toString({ ignoreVersion: true }));\n const authoredCoreAspects = this.aspectLoader.getCoreAspectIds().filter((aspectId) => {\n if (aspectId === this.aspectLoader.mainAspect?.id) return false;\n // the same naive comparison done by linkNonExistingCoreAspects, whose filter this inverts\n const name = getCoreAspectName(aspectId);\n return idsInWorkspace.some((id) => id === name || id === aspectId);\n });\n if (!authoredCoreAspects.length) return;\n\n const hoistedStoreDir = path.join(rootDir, 'node_modules', '.pnpm');\n // the hoisted store only exists in a pnpm-managed workspace. anywhere else this directory is on\n // no resolution path, so there is nothing to bridge - and it must not be fabricated here.\n if (!fs.pathExistsSync(hoistedStoreDir)) return;\n\n const links: Record<string, string> = {};\n for (const aspectId of authoredCoreAspects) {\n const packageName = getCoreAspectPackageName(aspectId);\n const linkPath = path.join(hoistedStoreDir, 'node_modules', packageName);\n if (this.hasCompiledMain(path.join(rootDir, 'node_modules', packageName))) {\n await this.removeCoreAspectBootstrapLink(linkPath, rootDir);\n continue;\n }\n const fromDir = this._getCoreAspectSourceDir(aspectId, packageName, rootDir);\n if (fromDir) links[packageName] = `link:${fromDir}`;\n }\n const packagesToLink = Object.keys(links);\n if (!packagesToLink.length) return;\n this.logger.debug(`syncCoreAspectLinksForEnvs: linking ${packagesToLink.join(', ')}`);\n try {\n await createLinks(hoistedStoreDir, links, { skipIfSymlinkValid: true });\n } catch (err: any) {\n // the bridge is best-effort. without it the envs may fail to load during install, which the\n // install flow already tolerates - a broken bridge must not turn that into a fatal error.\n this.logger.warn(\n `syncCoreAspectLinksForEnvs: failed linking core aspects into the hoisted store. ${err.message}`\n );\n }\n }\n\n private hasCompiledMain(pkgDir: string): boolean {\n try {\n const { main } = fs.readJsonSync(path.join(pkgDir, 'package.json'));\n return fs.pathExistsSync(path.join(pkgDir, main || 'index.js'));\n } catch {\n return false;\n }\n }\n\n /**\n * the directory to bridge a core aspect from: the running bit installation's copy. bvm is where a\n * released bit runs from; when bit runs from elsewhere (e.g. installed through a package manager),\n * fall back to the module-resolution strategy aspect-loader uses to locate core aspects.\n *\n * a copy is only usable as a bridge source if its own compiled main exists AND it lives outside\n * the workspace. the second condition is what lets removeCoreAspectBootstrapLink identify this\n * method's links: a workspace-internal source (e.g. a published bit installed as a workspace\n * dependency) would produce a link the cleanup can never tell apart from pnpm's own hoisted\n * entries, shadowing the workspace's compiled sources forever.\n */\n private _getCoreAspectSourceDir(aspectId: string, packageName: string, workspaceDir: string): string | undefined {\n const isUsableSource = (dir: string) => this.hasCompiledMain(dir) && !this._realpathIsInside(dir, workspaceDir);\n const fromBvmDir = this._getPkgPathFromCurrentBitDir(packageName);\n if (fromBvmDir && isUsableSource(fromBvmDir)) return fromBvmDir;\n try {\n const fromRunningBit = getAspectDir(aspectId);\n if (isUsableSource(fromRunningBit)) return fromRunningBit;\n } catch {\n // not resolvable from the running installation either\n }\n return undefined;\n }\n\n /** both paths must exist. compares real paths, as either side may be reached through a symlink. */\n private _realpathIsInside(target: string, dir: string): boolean {\n return fs.realpathSync(target).startsWith(fs.realpathSync(dir) + path.sep);\n }\n\n /**\n * only removes links created by syncCoreAspectLinksForEnvs, identified by resolving OUTSIDE the\n * workspace - an invariant _getCoreAspectSourceDir enforces on every link source, and one nothing\n * else at this location+name violates: pnpm's own hoisted entries always point back into the\n * virtual store. matching the exact bit installation instead would be too strict: a link leaked\n * by an interrupted install may point at a bit version that was since upgraded or removed\n * (dangling), and it must still be cleaned up or it would shadow the workspace's copy forever.\n */\n private async removeCoreAspectBootstrapLink(linkPath: string, workspaceDir: string): Promise<void> {\n try {\n if (!fs.lstatSync(linkPath).isSymbolicLink()) return;\n } catch {\n return; // nothing at this path\n }\n try {\n if (this._realpathIsInside(linkPath, workspaceDir)) return;\n } catch {\n // dangling link - fall through and remove it\n }\n await fs.remove(linkPath);\n }\n\n private isBitRepoWorkspace(dir: string) {\n // A special condition to not link core aspects in bit workspace itself\n if (this.aspectLoader.mainAspect?.path.startsWith(dir)) {\n return true;\n }\n return false;\n }\n\n private linkCoreAspect(\n id: string,\n {\n targetModulesDir,\n mainAspectPath,\n hasLocalInstallation,\n }: {\n targetModulesDir: string;\n mainAspectPath: string;\n hasLocalInstallation?: boolean;\n }\n ): CoreAspectLinkResult | undefined {\n const name = getCoreAspectName(id);\n const packageName = getCoreAspectPackageName(id);\n let aspectDir = path.join(mainAspectPath, 'dist', name);\n const target = path.join(targetModulesDir, packageName);\n const fromDir = this._getPkgPathFromCurrentBitDir(packageName);\n if (fromDir) {\n return { aspectId: id, linkDetail: { packageName, from: fromDir, to: target } };\n }\n const shouldSymlink = this.removeSymlinkTarget(target, hasLocalInstallation);\n if (!shouldSymlink) return undefined;\n const isAspectDirExist = fs.pathExistsSync(aspectDir);\n if (!isAspectDirExist) {\n this.logger.debug(`linkCoreAspect: aspectDir ${aspectDir} does not exist, linking it to ${target}`);\n aspectDir = getAspectDir(id);\n return { aspectId: id, linkDetail: { packageName, from: aspectDir, to: target } };\n }\n\n try {\n // eslint-disable-next-line global-require, import/no-dynamic-require\n const module = require(aspectDir);\n const aspectPath = path.resolve(path.join(module.path, '..', '..'));\n this.logger.debug(`linkCoreAspect: linking aspectPath ${aspectPath} to ${target}`);\n return { aspectId: id, linkDetail: { packageName, from: aspectPath, to: target } };\n } catch (err: any) {\n throw new CoreAspectLinkError(id, err);\n }\n }\n\n /**\n * returns true if it's safe to symlink it later.\n */\n private removeSymlinkTarget(targetPath: string, hasLocalInstallation = false): boolean {\n // TODO: change to fs.lstatSync(dest, {throwIfNoEntry: false});\n // TODO: this requires to upgrade node to v15.3.0 to have the throwIfNoEntry property (maybe upgrade fs-extra will work as well)\n // TODO: we don't use fs.pathExistsSync since it will return false in case the dest is a symlink which will result error on write\n let targetStat: Stats | undefined;\n try {\n targetStat = fs.lstatSync(targetPath);\n // eslint-disable-next-line no-empty\n } catch {}\n if (targetStat && !hasLocalInstallation) {\n // Do not override links created by other means\n if (!targetStat.isSymbolicLink()) {\n this.logger.debug(`removing link target, target ${targetPath} already exist. skipping it`);\n return false;\n }\n return true;\n }\n return true;\n }\n\n private _getPkgPathFromCurrentBitDir(packageName: string): string | undefined {\n if (!this._currentBitDir) return undefined;\n return path.join(this._currentBitDir, 'node_modules', packageName);\n }\n\n private linkNonCorePackages(rootDir: string, packageName: string): LinkDetail {\n const target = path.join(rootDir, 'node_modules', packageName);\n const fromDirBvm = this._getPkgPathFromCurrentBitDir(packageName);\n if (fromDirBvm) {\n return { packageName, from: fromDirBvm, to: target };\n }\n const fromDirBitRepo = getDistDirForDevEnv(packageName);\n return { packageName, from: fromDirBitRepo, to: target };\n }\n\n private linkNonAspectCorePackages(rootDir: string, name: string, mainAspectPath: string): LinkDetail | undefined {\n const distDir = path.join(mainAspectPath, 'dist', name);\n\n const packageName = `@teambit/${name}`;\n const target = path.join(rootDir, 'node_modules', packageName);\n const fromDir = this._getPkgPathFromCurrentBitDir(packageName);\n if (fromDir) {\n return { packageName, from: fromDir, to: target };\n }\n const isDistDirExist = fs.pathExistsSync(distDir);\n if (!isDistDirExist) {\n const newDir = getDistDirForDevEnv(packageName);\n return { packageName, from: newDir, to: target };\n }\n\n try {\n // eslint-disable-next-line global-require, import/no-dynamic-require\n const module = require(distDir);\n const resolvedPath = path.resolve(path.join(module.path, '..', '..'));\n return { packageName, from: resolvedPath, to: target };\n } catch (err: any) {\n throw new NonAspectCorePackageLinkError(err, packageName);\n }\n }\n}\n\n/**\n * When running dev env (bd) we need to get the harmony/legacy folder from the node_modules of the clone\n */\nfunction getDistDirForDevEnv(packageName: string): string {\n let moduleDirectory = require.resolve(packageName);\n let dirPath;\n if (moduleDirectory.includes(packageName)) {\n dirPath = path.join(moduleDirectory, '../..'); // to remove the \"index.js\" at the end\n } else {\n // This is usually required for the @teambit/legacy, as we re inside the nm so we can't find it in the other way\n const nmDir = __dirname.substring(0, __dirname.indexOf('@teambit'));\n dirPath = path.join(nmDir, packageName);\n moduleDirectory = require.resolve(packageName, { paths: [nmDir] });\n }\n if (!fs.existsSync(dirPath)) {\n throw new BitError(`unable to find ${packageName} in ${dirPath}`);\n }\n\n return dirPath;\n}\n\n// TODO: extract to new component\nfunction resolveModuleFromDir(fromDir: string, moduleId: string, silent = true): string | undefined {\n if (silent) {\n return resolveFrom.silent(fromDir, moduleId);\n }\n return resolveFrom(fromDir, moduleId);\n}\n\n// TODO: extract to new component\nfunction resolveModuleDirFromFile(resolvedModulePath: string, moduleId: string): string {\n const NM = 'node_modules';\n if (resolvedModulePath.includes(NM)) {\n return path.join(resolvedModulePath.slice(0, resolvedModulePath.lastIndexOf(NM) + NM.length), moduleId);\n }\n\n const [start, end] = resolvedModulePath.split('@');\n if (!end) return path.basename(resolvedModulePath);\n const versionStr = head(end.split('/'));\n return `${start}@${versionStr}`;\n}\n\nfunction isPathSymlink(folderPath: string): boolean | undefined {\n // TODO: change to fs.lstatSync(dest, {throwIfNoEntry: false}); once upgrade fs-extra\n try {\n const stat = fs.lstatSync(folderPath);\n return stat.isSymbolicLink();\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,iBAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,gBAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,MAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,KAAA,YAAAA,CAAA;IAAA,OAAAH,I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AC9D;EACA,IAAI;IACF,MAAMC,IAAI,GAAGzJ,kBAAE,CAACiH,SAAS,CAACuC,UAAU,CAAC;IACrC,OAAOC,IAAI,CAAClJ,cAAc,CAAC,CAAC;EAC9B,CAAC,CAAC,MAAM;IACN,OAAOxD,SAAS;EAClB;AACF","ignoreList":[]}
1
+ {"version":3,"names":["_isBuiltinModule","data","_interopRequireDefault","require","_path","_lodash","_fsExtra","_resolveFrom","_bvm","_pkgModules","_dependenciesFs","_bitError","_aspectLoader","_exceptions","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","DEFAULT_LINKING_OPTIONS","rewire","linkTeambitBit","linkCoreAspects","linkDepsResolvedFromEnv","linkNestedDepsInNM","DependencyLinker","constructor","dependencyResolver","aspectLoader","componentAspect","envs","logger","rootDir","linkingOptions","linkingContext","_currentBitDir","findCurrentBvmDir","calculateLinkedDeps","componentDirectoryMap","options","linkResults","_calculateLinks","localLinks","teambitBitLink","linkDetailToLocalDepEntry","linkDetail","coreAspectsLinks","link","harmonyLink","teambitLegacyLink","slotOriginatedLinks","map","l","resolvedFromEnvLinks","linksDetail","linkToDirResults","linkCoreAspectsToHoistedStore","linkedRootDeps","fromEntries","key","inCapsule","finalRootDir","getGlobalVirtualStoreDir","links","addLink","packageName","from","hoistedStoreDir","path","join","toString","fs","pathExistsSync","createLinks","skipIfSymlinkValid","err","BitError","message","outputMessage","setStatusLine","debug","omit","startTime","process","hrtime","result","linkingOpts","assign","RootDirNotDefined","linkToDir","components","toArray","component","includePeers","_getLinksToPeers","nestedDepsInNmLinks","addSymlinkFromComponentDirNMToWorkspaceDirNM","componentIds","_dir","comp","id","undefined","linkCoreAspectsAndLegacy","registeredPackages","additionalPackagesToLink","pkgName","linkNonCorePackages","consoleSuccess","peers","Set","Promise","all","depList","getDependencies","peerList","byLifecycle","dependency","getPackageName","add","fromDir","toDir","Array","componentId","to","componentIdsWithoutVersions","ignoreVersion","isBitRepoWorkspace","bitLink","linkBitAspectIfNotExist","mainAspectPath","mainAspect","MainAspectNotLinkable","hasLocalInstallation","linkNonExistingCoreAspects","targetModulesDir","linkNonAspectCorePackages","targetDir","results","componentPackageName","componentIdToPackageName","state","_consumer","rootNodeModules","getPackagesFoldersToLink","dir","parent","folders","readdirSync","withFileTypes","dirent","name","startsWith","isDirectory","isSymbolicLink","dirPath","moduleName","moduleNameToResolve","isBuiltinModule","resolvedModuleFrom","resolveModuleFromDir","origPath","resolveModuleDirFromFile","flatten","linksOfAllComponents","compDirNM","existsSync","innerNMofComponentInNM","isPathSymlink","packagesFoldersToLink","ensureDirSync","oneComponentLinks","folderEntry","linkTarget","linkSrc","info","filteredLinks","compact","componentsNeedLinks","componentsNeedLinksP","policy","getPolicy","resolvedFromEnv","getResolvedFromEnv","env","getEnv","componentNeedLink","envsStringIds","obj","uniqEnvIds","uniq","host","getHost","resolvedEnvIds","resolveMultipleComponentIds","resolvedAspects","resolveAspects","resolvedAspectsIndex","reduce","acc","curr","getId","allLinksP","entry","oneComponentLinksP","entries","depEntry","dependencyId","envDir","aspectPath","resolvedModule","console","depsLinkedToEnvResult","mainAspectId","existing","find","linkBit","aspectId","target","shouldSymlink","removeSymlinkTarget","src","_getPkgPathFromCurrentBitDir","ensureDir","dirname","opts","coreAspectsIds","getCoreAspectIds","filtered","getCoreAspectName","linkCoreAspect","syncCoreAspectLinksForEnvs","idsInWorkspace","authoredCoreAspects","some","underGlobalVirtualStore","Boolean","getCoreAspectPackageName","linkPath","workspacePkgDir","hasCompiledMain","removeCoreAspectBootstrapLink","_getCoreAspectSourceDir","packagesToLink","warn","pkgDir","main","readJsonSync","workspaceDir","isUsableSource","_realpathIsInside","fromBvmDir","fromRunningBit","getAspectDir","realpathSync","sep","lstatSync","remove","aspectDir","isAspectDirExist","module","resolve","CoreAspectLinkError","targetPath","targetStat","fromDirBvm","fromDirBitRepo","getDistDirForDevEnv","distDir","isDistDirExist","newDir","resolvedPath","NonAspectCorePackageLinkError","exports","moduleDirectory","includes","nmDir","__dirname","substring","indexOf","paths","moduleId","silent","resolveFrom","resolvedModulePath","NM","slice","lastIndexOf","start","end","split","basename","versionStr","head","folderPath","stat"],"sources":["dependency-linker.ts"],"sourcesContent":["import isBuiltinModule from 'is-builtin-module';\nimport path from 'path';\nimport { uniq, compact, flatten, head, omit } from 'lodash';\nimport type { Stats } from 'fs';\nimport fs from 'fs-extra';\nimport resolveFrom from 'resolve-from';\nimport { findCurrentBvmDir } from '@teambit/bvm.path';\nimport type { ComponentMap, Component, ComponentID, ComponentMain } from '@teambit/component';\nimport type { Logger } from '@teambit/logger';\nimport type { PathAbsolute } from '@teambit/toolbox.path.path';\nimport { componentIdToPackageName } from '@teambit/pkg.modules.component-package-name';\nimport { createLinks } from '@teambit/dependencies.fs.linked-dependencies';\nimport { BitError } from '@teambit/bit-error';\nimport type { EnvsMain } from '@teambit/envs';\nimport type { AspectLoaderMain } from '@teambit/aspect-loader';\nimport { getCoreAspectName, getCoreAspectPackageName, getAspectDir } from '@teambit/aspect-loader';\nimport {\n MainAspectNotLinkable,\n RootDirNotDefined,\n CoreAspectLinkError,\n NonAspectCorePackageLinkError,\n} from './exceptions';\nimport type { DependencyResolverMain } from './dependency-resolver.main.runtime';\n\n/**\n * context of the linking process.\n */\nexport type DepLinkerContext = {\n inCapsule?: boolean;\n};\n\nexport type LinkingOptions = {\n rewire?: boolean;\n /**\n * Whether to create link to @teambit/bit in the root node modules\n */\n linkTeambitBit?: boolean;\n /**\n * Whether to create links in the root dir node modules to all core aspects\n */\n linkCoreAspects?: boolean;\n\n linkNestedDepsInNM?: boolean;\n\n /**\n * link to another project, so that project could use components from this workspace.\n * similar to npm/yarn link\n */\n linkToDir?: string;\n\n /**\n * Link peer dependencies of the components to the target project.\n * Peer dependencies should be singletons, so the project should use the same\n * version of the peer dependency as the linked in components.\n */\n includePeers?: boolean;\n\n /**\n * whether link should import objects before linking\n */\n fetchObject?: boolean;\n\n /**\n * Link deps which should be linked to the env\n */\n linkDepsResolvedFromEnv?: boolean;\n\n /**\n * non-core packages to link. provided by addPackagesToLink slot of the deps-resolver aspect\n */\n additionalPackagesToLink?: string[];\n};\n\nconst DEFAULT_LINKING_OPTIONS: LinkingOptions = {\n rewire: false,\n linkTeambitBit: true,\n linkCoreAspects: true,\n linkDepsResolvedFromEnv: true,\n linkNestedDepsInNM: true,\n};\n\nexport type LinkDetail = { packageName: string; from: string; to: string };\n\nexport type CoreAspectLinkResult = {\n aspectId: string;\n linkDetail: LinkDetail;\n};\n\nexport type DepsLinkedToEnvResult = {\n componentId: string;\n linksDetail: LinkDetail[];\n};\n\nexport type NestedNMDepsLinksResult = {\n componentId: string;\n linksDetail: LinkDetail[];\n};\n\nexport type LinkToDirResult = {\n componentId: string;\n linksDetail: LinkDetail;\n};\n\nexport type LinkResults = {\n teambitBitLink?: CoreAspectLinkResult;\n coreAspectsLinks?: CoreAspectLinkResult[];\n harmonyLink?: LinkDetail;\n teambitLegacyLink?: LinkDetail;\n resolvedFromEnvLinks?: DepsLinkedToEnvResult[];\n nestedDepsInNmLinks?: NestedNMDepsLinksResult[];\n linkToDirResults?: LinkToDirResult[];\n /**\n * non-core packages to link. provided by addPackagesToLink slot of the deps-resolver aspect\n */\n slotOriginatedLinks?: LinkDetail[];\n};\n\ntype NestedModuleFolderEntry = {\n moduleName: string;\n path: string;\n origPath?: string;\n};\n\nexport class DependencyLinker {\n private _currentBitDir: string | null;\n\n constructor(\n private dependencyResolver: DependencyResolverMain,\n\n private aspectLoader: AspectLoaderMain,\n\n private componentAspect: ComponentMain,\n\n private envs: EnvsMain,\n\n private logger: Logger,\n\n private rootDir?: string | PathAbsolute,\n\n private linkingOptions?: LinkingOptions,\n\n private linkingContext: DepLinkerContext = {}\n ) {\n this._currentBitDir = findCurrentBvmDir();\n }\n\n async calculateLinkedDeps(\n rootDir: string | undefined,\n componentDirectoryMap: ComponentMap<string>,\n options: LinkingOptions = {}\n ): Promise<{ linkedRootDeps: Record<string, string>; linkResults: LinkResults }> {\n const linkResults = await this._calculateLinks(rootDir, componentDirectoryMap, options);\n const localLinks: Array<[string, string]> = [];\n if (linkResults.teambitBitLink) {\n localLinks.push(this.linkDetailToLocalDepEntry(linkResults.teambitBitLink.linkDetail));\n }\n if (linkResults.coreAspectsLinks) {\n linkResults.coreAspectsLinks.forEach((link) => {\n localLinks.push(this.linkDetailToLocalDepEntry(link.linkDetail));\n });\n }\n if (linkResults.harmonyLink) {\n localLinks.push(this.linkDetailToLocalDepEntry(linkResults.harmonyLink));\n }\n if (linkResults.teambitLegacyLink) {\n localLinks.push(this.linkDetailToLocalDepEntry(linkResults.teambitLegacyLink));\n }\n if (linkResults.slotOriginatedLinks) {\n localLinks.push(...linkResults.slotOriginatedLinks.map((l) => this.linkDetailToLocalDepEntry(l)));\n }\n if (linkResults.resolvedFromEnvLinks) {\n linkResults.resolvedFromEnvLinks.forEach((link) => {\n link.linksDetail.forEach((linkDetail) => {\n localLinks.push(this.linkDetailToLocalDepEntry(linkDetail));\n });\n });\n }\n if (linkResults.linkToDirResults) {\n linkResults.linkToDirResults.forEach((link) => {\n localLinks.push(this.linkDetailToLocalDepEntry(link.linksDetail));\n });\n }\n await this.linkCoreAspectsToHoistedStore(rootDir, linkResults);\n return {\n linkedRootDeps: Object.fromEntries(localLinks.map(([key, value]) => [key, `link:${value}`])),\n linkResults,\n };\n }\n\n /**\n * The core aspects are phantom dependencies of every published env and aspect - they are required\n * without being declared, and the running bit installation provides them. Under the project-local\n * virtual store that works because a package in `node_modules/.pnpm` resolves them by walking up\n * into the workspace's root `node_modules`, where they are linked as root dependencies.\n *\n * A package in the global virtual store has no workspace to walk up into: it lives under\n * `<storeDir>/links/<scope>/<name>/<version>/<hash>`, shared with every other project on the\n * machine. pnpm's answer for exactly this case is the privately hoisted directory: it stays\n * project-local at `<rootDir>/node_modules/.pnpm/node_modules` even under the global virtual\n * store, and is put on the module resolution path via `NODE_PATH` and an ESM loader (see\n * `ensureHoistedDependencyResolution` in the hoisted-resolution bridge, which does that for\n * bit's own process and the ones it spawns).\n *\n * So the core aspects are linked there rather than mirrored into the store. Nothing is written\n * inside the store itself, which is what lets bit use pnpm's shared `<storeDir>/links` instead of\n * a root private to one bit installation - slots are then shared across bit versions and with\n * every other pnpm project, and `pnpm store prune` can reason about them.\n *\n * Only the links that come from the bit installation go here - the workspace's own component\n * links stay in the workspace's root `node_modules`.\n */\n private async linkCoreAspectsToHoistedStore(rootDir: string | undefined, linkResults: LinkResults): Promise<void> {\n // capsules stay on the project-local virtual store (see the installer's capsule invariant),\n // where packages reach the core aspects by walking up to the capsule root - the hoisted-store\n // bridge is a global-virtual-store mechanism and must not write into capsule layouts\n if (this.linkingContext?.inCapsule) return;\n const finalRootDir = rootDir ?? this.rootDir;\n if (!finalRootDir) return;\n if (!(await this.dependencyResolver.getGlobalVirtualStoreDir(finalRootDir))) return;\n const links: Record<string, string> = {};\n const addLink = (linkDetail?: LinkDetail) => {\n if (!linkDetail) return;\n const [packageName, from] = this.linkDetailToLocalDepEntry(linkDetail);\n links[packageName] = `link:${from}`;\n };\n addLink(linkResults.teambitBitLink?.linkDetail);\n linkResults.coreAspectsLinks?.forEach((link) => addLink(link.linkDetail));\n addLink(linkResults.harmonyLink);\n addLink(linkResults.teambitLegacyLink);\n if (!Object.keys(links).length) return;\n const hoistedStoreDir = path.join(finalRootDir.toString(), 'node_modules', '.pnpm');\n // same rule as syncCoreAspectLinksForEnvs: bridge the virtual store pnpm materialized, never\n // fabricate one (a lockfile-only install leaves it missing on purpose)\n if (!fs.pathExistsSync(hoistedStoreDir)) return;\n try {\n await createLinks(hoistedStoreDir, links, { skipIfSymlinkValid: true });\n } catch (err: any) {\n // fail loudly: under the global virtual store these links are what lets every package in a\n // store slot resolve the undeclared core aspects. A workspace missing them is broken in\n // ways that only surface later as obscure \"Cannot find module '@teambit/...'\" failures far\n // from the cause - unlike syncCoreAspectLinksForEnvs' bootstrap bridge, which the install\n // flow genuinely tolerates losing.\n throw new BitError(\n `failed linking the core aspects into the hoisted store at ${hoistedStoreDir}, which packages ` +\n `in the global virtual store rely on to resolve them: ${err.message}`\n );\n }\n }\n\n private linkDetailToLocalDepEntry(linkDetail: LinkDetail): [string, string] {\n return [linkDetail.packageName, linkDetail.from];\n }\n\n private async _calculateLinks(\n rootDir: string | undefined,\n componentDirectoryMap: ComponentMap<string>,\n options: LinkingOptions = {}\n ): Promise<LinkResults> {\n const outputMessage = this.linkingContext?.inCapsule\n ? `(capsule) linking components in root dir: ${rootDir || this.rootDir}`\n : 'linking components';\n if (!this.linkingContext?.inCapsule) {\n this.logger.setStatusLine(outputMessage);\n }\n this.logger.debug('linking components with options', omit(options, ['consumer']));\n const startTime = process.hrtime();\n\n let result: LinkResults = {};\n const finalRootDir = rootDir || this.rootDir;\n const linkingOpts = Object.assign({}, DEFAULT_LINKING_OPTIONS, this.linkingOptions || {}, options || {});\n if (!finalRootDir) {\n throw new RootDirNotDefined();\n }\n if (options.linkToDir) {\n const components = componentDirectoryMap.toArray().map(([component]) => component);\n const linkToDirResults = await this.linkToDir(finalRootDir, options.linkToDir, components);\n result.linkToDirResults = linkToDirResults;\n if (options.includePeers) {\n result.linkToDirResults.push(\n ...(await this._getLinksToPeers(componentDirectoryMap, { finalRootDir, linkToDir: options.linkToDir }))\n );\n }\n return result;\n }\n\n // Link deps which should be linked to the env\n if (linkingOpts.linkDepsResolvedFromEnv) {\n result.resolvedFromEnvLinks = await this.linkDepsResolvedFromEnv(componentDirectoryMap);\n }\n if (linkingOpts.linkNestedDepsInNM) {\n result.nestedDepsInNmLinks = this.addSymlinkFromComponentDirNMToWorkspaceDirNM(\n finalRootDir,\n componentDirectoryMap\n );\n }\n\n // We remove the version since it used in order to check if it's core aspects, and the core aspects arrived from aspect loader without versions\n const componentIds: ComponentID[] = [];\n componentDirectoryMap.map((_dir, comp) => {\n componentIds.push(comp.id);\n return undefined;\n });\n result = {\n ...result,\n ...(await this.linkCoreAspectsAndLegacy(finalRootDir, componentIds, linkingOpts)),\n };\n const registeredPackages = this.linkingOptions?.additionalPackagesToLink || [];\n result.slotOriginatedLinks = registeredPackages.map((pkgName) => this.linkNonCorePackages(finalRootDir, pkgName));\n\n if (!this.linkingContext?.inCapsule) {\n this.logger.consoleSuccess(outputMessage, startTime);\n }\n return result;\n }\n\n async _getLinksToPeers(\n componentDirectoryMap: ComponentMap<string>,\n options: {\n finalRootDir: string;\n linkToDir: string;\n }\n ): Promise<LinkToDirResult[]> {\n const peers = new Set<string>();\n await Promise.all(\n componentDirectoryMap.toArray().map(async ([component]) => {\n const depList = this.dependencyResolver.getDependencies(component);\n const peerList = depList.byLifecycle('peer');\n peerList.forEach((dependency) => {\n if (dependency.getPackageName) {\n peers.add(dependency.getPackageName());\n }\n });\n })\n );\n const fromDir = path.join(options.finalRootDir, 'node_modules');\n const toDir = path.join(options.linkToDir, 'node_modules');\n return Array.from(peers).map((packageName) => ({\n componentId: packageName,\n linksDetail: {\n packageName,\n from: path.join(fromDir, packageName),\n to: path.join(toDir, packageName),\n },\n }));\n }\n\n async linkCoreAspectsAndLegacy(\n rootDir: string,\n componentIds: ComponentID[] = [],\n options: Pick<LinkingOptions, 'linkTeambitBit' | 'linkCoreAspects'> = {}\n ) {\n const result: LinkResults = {};\n const componentIdsWithoutVersions: string[] = [];\n componentIds.map((id) => {\n componentIdsWithoutVersions.push(id.toString({ ignoreVersion: true }));\n return undefined;\n });\n const linkingOpts = Object.assign({}, DEFAULT_LINKING_OPTIONS, this.linkingOptions || {}, options || {});\n if (linkingOpts.linkTeambitBit && !this.isBitRepoWorkspace(rootDir)) {\n const bitLink = await this.linkBitAspectIfNotExist(\n path.join(rootDir, 'node_modules'),\n componentIdsWithoutVersions\n );\n result.teambitBitLink = bitLink;\n }\n\n let mainAspectPath = result.teambitBitLink?.linkDetail.from;\n if (!mainAspectPath && this.aspectLoader.mainAspect) {\n if (!this.aspectLoader.mainAspect.packageName) {\n throw new MainAspectNotLinkable();\n }\n mainAspectPath = path.join(rootDir, 'node_modules', this.aspectLoader.mainAspect.packageName);\n }\n if (linkingOpts.linkCoreAspects && !this.isBitRepoWorkspace(rootDir)) {\n const hasLocalInstallation = !linkingOpts.linkTeambitBit;\n if (mainAspectPath) {\n result.coreAspectsLinks = await this.linkNonExistingCoreAspects(componentIdsWithoutVersions, {\n targetModulesDir: path.join(rootDir, 'node_modules'),\n mainAspectPath,\n hasLocalInstallation,\n });\n } else {\n result.coreAspectsLinks = [];\n }\n }\n\n if (mainAspectPath) {\n // the following line links @teambit/legacy to the workspace node_modules. at this point, we removed all\n // @teambit/legacy occurrences from the repo but others/external repos still have it.\n result.teambitLegacyLink = this.linkNonAspectCorePackages(rootDir, 'legacy', mainAspectPath);\n result.harmonyLink = this.linkNonAspectCorePackages(rootDir, 'harmony', mainAspectPath);\n }\n return result;\n }\n\n private async linkToDir(rootDir: string, targetDir: string, components: Component[]): Promise<LinkToDirResult[]> {\n const results: LinkToDirResult[] = components.map((component) => {\n const componentPackageName = componentIdToPackageName(component.state._consumer);\n return {\n componentId: component.id.toString(),\n linksDetail: {\n packageName: componentPackageName,\n from: path.join(rootDir, 'node_modules', componentPackageName),\n to: path.join(targetDir, 'node_modules', componentPackageName),\n },\n };\n });\n return results;\n }\n\n /**\n * Add symlinks from the node_modules in the component's root-dir to the workspace node_modules\n * of the component. e.g.\n * <ws-root>/node_modules/comp1/node_modules/<dep> -> <ws-root>/components/comp1/node_modules/<dep>\n * This is needed because the component is compiled into the dist folder at <ws-root>/node_modules/comp1/dist,\n * so the files in the dist folder need to find the right dependencies of comp1.\n */\n private addSymlinkFromComponentDirNMToWorkspaceDirNM(\n rootDir: string,\n componentDirectoryMap: ComponentMap<string>\n ): NestedNMDepsLinksResult[] {\n const rootNodeModules = path.join(rootDir, 'node_modules');\n const getPackagesFoldersToLink = (dir: string, parent?: string): NestedModuleFolderEntry[] => {\n const folders = fs\n .readdirSync(dir, { withFileTypes: true })\n .filter((dirent) => {\n if (dirent.name.startsWith('.')) {\n return false;\n }\n return dirent.isDirectory() || dirent.isSymbolicLink();\n })\n .map((dirent) => {\n const dirPath = path.join(dir, dirent.name);\n const moduleName = parent ? `${parent}/${dirent.name}` : dirent.name;\n // If we have a folder with a name of built in module (like events)\n // the resolve from will resolve it from the core, so it will return something like 'events'\n // instead of the path.\n // adding a '/' at the end solve this\n const moduleNameToResolve = isBuiltinModule(moduleName) ? `${moduleName}/` : moduleName;\n // This is a scoped package, need to go inside\n if (dirent.name.startsWith('@')) {\n return getPackagesFoldersToLink(dirPath, dirent.name);\n }\n\n if (dirent.isSymbolicLink()) {\n const resolvedModuleFrom = resolveModuleFromDir(dir, moduleNameToResolve);\n if (!resolvedModuleFrom) {\n return {\n moduleName,\n path: dirPath,\n };\n }\n return {\n origPath: dirPath,\n moduleName,\n path: resolveModuleDirFromFile(resolvedModuleFrom, moduleName),\n };\n }\n return {\n moduleName,\n path: dirPath,\n };\n });\n return flatten(folders);\n };\n const linksOfAllComponents = componentDirectoryMap.toArray().map(([component, dir]) => {\n const compDirNM = path.join(dir, 'node_modules');\n if (!fs.existsSync(compDirNM)) return undefined;\n // TODO: support modules with scoped packages (start with @) - we need to make this logic 2 levels\n\n const componentPackageName = componentIdToPackageName(component.state._consumer);\n const innerNMofComponentInNM = path.join(rootNodeModules, componentPackageName);\n // If the folder itself is a symlink, do not try to symlink inside it\n if (isPathSymlink(innerNMofComponentInNM)) {\n return undefined;\n }\n const packagesFoldersToLink: NestedModuleFolderEntry[] = getPackagesFoldersToLink(compDirNM);\n fs.ensureDirSync(innerNMofComponentInNM);\n\n const oneComponentLinks: LinkDetail[] = packagesFoldersToLink.map((folderEntry: NestedModuleFolderEntry) => {\n const linkTarget = path.join(innerNMofComponentInNM, 'node_modules', folderEntry?.moduleName);\n const linkSrc = folderEntry.path;\n // This works as well, consider using it instead\n // const linkSrc = folderEntry.origPath || folderEntry.path;\n const origPath = folderEntry.origPath ? `(${folderEntry.origPath})` : '';\n const linkDetail: LinkDetail = {\n packageName: folderEntry.moduleName,\n from: `${linkSrc} ${origPath}`,\n to: linkTarget,\n };\n this.logger.info(\n `linking nested dependency ${folderEntry.moduleName} for component ${component}. link src: ${linkSrc} link target: ${linkTarget}`\n );\n return linkDetail;\n });\n\n const filteredLinks = compact(oneComponentLinks);\n return {\n componentId: component.id.toString(),\n linksDetail: filteredLinks,\n };\n });\n const filteredLinks = compact(linksOfAllComponents);\n return filteredLinks;\n }\n\n private async linkDepsResolvedFromEnv(\n componentDirectoryMap: ComponentMap<string>\n ): Promise<Array<DepsLinkedToEnvResult>> {\n const componentsNeedLinks: {\n component: Component;\n dir: string;\n env;\n resolvedFromEnv;\n envId?: string;\n envDir?: string;\n }[] = [];\n\n const componentsNeedLinksP = componentDirectoryMap.toArray().map(async ([component, dir]) => {\n const policy = await this.dependencyResolver.getPolicy(component);\n const resolvedFromEnv = policy.getResolvedFromEnv();\n // Nothing should be resolved from env, do nothing\n if (!resolvedFromEnv.length) {\n return;\n }\n const env = this.envs.getEnv(component);\n const componentNeedLink = {\n component,\n dir,\n env,\n resolvedFromEnv,\n };\n componentsNeedLinks.push(componentNeedLink);\n });\n\n await Promise.all(componentsNeedLinksP);\n // Stop if there are not components needs to be linked\n if (!componentsNeedLinks || !componentsNeedLinks.length) return [];\n const envsStringIds = componentsNeedLinks.map((obj) => obj.env.id);\n const uniqEnvIds = uniq(envsStringIds);\n const host = this.componentAspect.getHost();\n const resolvedEnvIds = await host.resolveMultipleComponentIds(uniqEnvIds);\n const resolvedAspects = await host.resolveAspects(undefined, resolvedEnvIds);\n const resolvedAspectsIndex = resolvedAspects.reduce((acc, curr) => {\n if (curr.getId) {\n acc[curr.getId] = curr;\n }\n return acc;\n }, {});\n const allLinksP = componentsNeedLinks.map(async (entry) => {\n const oneComponentLinksP: Array<LinkDetail | undefined> = entry.resolvedFromEnv.entries.map(async (depEntry) => {\n const linkTarget = path.join(entry.dir, 'node_modules', depEntry.dependencyId);\n const envDir = resolvedAspectsIndex[entry.env.id].aspectPath;\n const resolvedModule = resolveModuleFromDir(envDir, depEntry.dependencyId);\n if (!resolvedModule) {\n this.logger.console(`could not resolve ${depEntry.dependencyId} from env directory ${envDir}`);\n return undefined;\n }\n const linkSrc = resolveModuleDirFromFile(resolvedModule, depEntry.dependencyId);\n const linkDetail: LinkDetail = {\n packageName: depEntry.dependencyId,\n from: linkSrc,\n to: linkTarget,\n };\n this.logger.info(\n `linking dependency ${depEntry.dependencyId} from env directory ${envDir}. link src: ${linkSrc} link target: ${linkTarget}`\n );\n\n return linkDetail;\n });\n const oneComponentLinks = await Promise.all(oneComponentLinksP);\n const filteredLinks = compact(oneComponentLinks);\n const depsLinkedToEnvResult: DepsLinkedToEnvResult = {\n componentId: entry.component.id.toString(),\n linksDetail: filteredLinks,\n };\n return depsLinkedToEnvResult;\n });\n return Promise.all(allLinksP);\n }\n\n private async linkBitAspectIfNotExist(\n dir: string,\n componentIds: string[]\n ): Promise<CoreAspectLinkResult | undefined> {\n if (!this.aspectLoader.mainAspect) return undefined;\n const mainAspectId = this.aspectLoader.mainAspect.id;\n const existing = componentIds.find((id) => {\n return id === mainAspectId;\n });\n\n if (existing) {\n return undefined;\n }\n const linkDetail = await this.linkBit(dir);\n if (!linkDetail) return undefined;\n return {\n aspectId: mainAspectId,\n linkDetail,\n };\n }\n\n async linkBit(dir: string): Promise<LinkDetail | undefined> {\n if (!this.aspectLoader.mainAspect.packageName) {\n throw new MainAspectNotLinkable();\n }\n const target = path.join(dir, this.aspectLoader.mainAspect.packageName);\n const shouldSymlink = this.removeSymlinkTarget(target);\n if (!shouldSymlink) return undefined;\n const src =\n this._getPkgPathFromCurrentBitDir(this.aspectLoader.mainAspect.packageName) ?? this.aspectLoader.mainAspect.path;\n await fs.ensureDir(path.dirname(target));\n return { packageName: this.aspectLoader.mainAspect.packageName, from: src, to: target };\n }\n\n private async linkNonExistingCoreAspects(\n componentIds: string[],\n opts: {\n targetModulesDir: string;\n mainAspectPath: string;\n hasLocalInstallation?: boolean;\n }\n ): Promise<CoreAspectLinkResult[]> {\n const coreAspectsIds = this.aspectLoader.getCoreAspectIds();\n const filtered = coreAspectsIds.filter((aspectId) => {\n // Remove bit aspect\n if (aspectId === this.aspectLoader.mainAspect?.id) {\n return false;\n }\n // TODO: use the aspect id once default scope is resolved and the component dir map has the id with scope\n const name = getCoreAspectName(aspectId);\n const existing = componentIds.find((componentId) => {\n return componentId === name || componentId === aspectId;\n });\n if (existing) {\n return false;\n }\n return true;\n });\n\n this.logger.debug(`linkNonExistingCoreAspects: linking the following core aspects ${filtered.join()}`);\n\n const results = filtered.map((id) => this.linkCoreAspect(id, opts));\n return compact(results);\n }\n\n /**\n * The core aspects are phantom dependencies of the published envs - an env requires\n * `@teambit/builder` (and `@teambit/ui`, `@teambit/pkg`...) without declaring it, and relies on the\n * running bit installation to provide it. `linkCoreAspectsAndLegacy` is what normally satisfies\n * that, by linking bit's own copies into the workspace's root node_modules.\n *\n * A workspace that authors the core aspects has them as source components instead, so they're\n * excluded from that linking - such a workspace must build and load its own. That leaves the envs'\n * phantom require resolving to a source component, which has no `main` until it's been compiled,\n * so an env resolved from the root (see `resolveEnvsFromRoots`) fails to load during install -\n * before the compile step that would have made it resolvable.\n *\n * Bridge that gap by linking bit's own (always compiled) copies into pnpm's hoisted store. That\n * directory is on the module resolution path of packages inside the virtual store - the published\n * envs - and not on the resolution path of the workspace's own components, so the envs bootstrap\n * against the running bit while the workspace still builds and loads its own core aspects.\n *\n * This is a reconciler - each core aspect converges to \"link present iff its source is still\n * uncompiled\", so the same call both creates the links during bootstrap and removes them once the\n * source components have been compiled.\n *\n * Only reached from a workspace with `linkCoreAspects` off, i.e. one that authors them.\n */\n async syncCoreAspectLinksForEnvs(rootDir: string, componentIds: ComponentID[]): Promise<void> {\n const idsInWorkspace = componentIds.map((id) => id.toString({ ignoreVersion: true }));\n const authoredCoreAspects = this.aspectLoader.getCoreAspectIds().filter((aspectId) => {\n if (aspectId === this.aspectLoader.mainAspect?.id) return false;\n // the same naive comparison done by linkNonExistingCoreAspects, whose filter this inverts\n const name = getCoreAspectName(aspectId);\n return idsInWorkspace.some((id) => id === name || id === aspectId);\n });\n if (!authoredCoreAspects.length) return;\n\n // The privately hoisted directory is where the non-authored core aspects go too (see\n // `linkCoreAspectsToHoistedStore`). It stays project-local under the global virtual store, and\n // is reached from a store slot via `NODE_PATH` rather than by walking up.\n const hoistedStoreDir = path.join(rootDir, 'node_modules', '.pnpm');\n const underGlobalVirtualStore = Boolean(await this.dependencyResolver.getGlobalVirtualStoreDir(rootDir));\n // the hoisted store only exists in a pnpm-managed workspace whose node_modules was actually\n // materialized - anywhere else (a non-pnpm workspace, a lockfile-only install) the directory\n // is on no resolution path, so there is nothing to bridge and it must not be fabricated here.\n // every real install materializes it under both layouts, and both call sites run after the\n // package manager has finished.\n if (!fs.pathExistsSync(hoistedStoreDir)) return;\n\n const links: Record<string, string> = {};\n for (const aspectId of authoredCoreAspects) {\n const packageName = getCoreAspectPackageName(aspectId);\n const linkPath = path.join(hoistedStoreDir, 'node_modules', packageName);\n const workspacePkgDir = path.join(rootDir, 'node_modules', packageName);\n if (this.hasCompiledMain(workspacePkgDir)) {\n // Once the source component is compiled, the workspace's own copy is the one to use. Under\n // the project-local layout the published packages reach it by walking up out of\n // `node_modules/.pnpm`, so the bootstrap bridge is removed as soon as it is redundant.\n // From the global virtual store there is no walking up into the workspace, so the bridge\n // stays - repointed at the compiled workspace copy rather than at the raw source.\n if (!underGlobalVirtualStore) {\n await this.removeCoreAspectBootstrapLink(linkPath, rootDir);\n continue;\n }\n links[packageName] = `link:${workspacePkgDir}`;\n continue;\n }\n const fromDir = this._getCoreAspectSourceDir(aspectId, packageName, rootDir);\n if (fromDir) links[packageName] = `link:${fromDir}`;\n }\n const packagesToLink = Object.keys(links);\n if (!packagesToLink.length) return;\n this.logger.debug(`syncCoreAspectLinksForEnvs: linking ${packagesToLink.join(', ')}`);\n try {\n await createLinks(hoistedStoreDir, links, { skipIfSymlinkValid: true });\n } catch (err: any) {\n // the bridge is best-effort. without it the envs may fail to load during install, which the\n // install flow already tolerates - a broken bridge must not turn that into a fatal error.\n this.logger.warn(\n `syncCoreAspectLinksForEnvs: failed linking core aspects into the hoisted store. ${err.message}`\n );\n }\n }\n\n private hasCompiledMain(pkgDir: string): boolean {\n try {\n const { main } = fs.readJsonSync(path.join(pkgDir, 'package.json'));\n return fs.pathExistsSync(path.join(pkgDir, main || 'index.js'));\n } catch {\n return false;\n }\n }\n\n /**\n * the directory to bridge a core aspect from: the running bit installation's copy. bvm is where a\n * released bit runs from; when bit runs from elsewhere (e.g. installed through a package manager),\n * fall back to the module-resolution strategy aspect-loader uses to locate core aspects.\n *\n * a copy is only usable as a bridge source if its own compiled main exists AND it lives outside\n * the workspace. the second condition is what lets removeCoreAspectBootstrapLink identify this\n * method's links: a workspace-internal source (e.g. a published bit installed as a workspace\n * dependency) would produce a link the cleanup can never tell apart from pnpm's own hoisted\n * entries, shadowing the workspace's compiled sources forever.\n */\n private _getCoreAspectSourceDir(aspectId: string, packageName: string, workspaceDir: string): string | undefined {\n const isUsableSource = (dir: string) => this.hasCompiledMain(dir) && !this._realpathIsInside(dir, workspaceDir);\n const fromBvmDir = this._getPkgPathFromCurrentBitDir(packageName);\n if (fromBvmDir && isUsableSource(fromBvmDir)) return fromBvmDir;\n try {\n const fromRunningBit = getAspectDir(aspectId);\n if (isUsableSource(fromRunningBit)) return fromRunningBit;\n } catch {\n // not resolvable from the running installation either\n }\n return undefined;\n }\n\n /** both paths must exist. compares real paths, as either side may be reached through a symlink. */\n private _realpathIsInside(target: string, dir: string): boolean {\n return fs.realpathSync(target).startsWith(fs.realpathSync(dir) + path.sep);\n }\n\n /**\n * only removes links created by syncCoreAspectLinksForEnvs, identified by resolving OUTSIDE the\n * workspace - an invariant _getCoreAspectSourceDir enforces on every link source, and one nothing\n * else at this location+name violates: pnpm's own hoisted entries always point back into the\n * virtual store. matching the exact bit installation instead would be too strict: a link leaked\n * by an interrupted install may point at a bit version that was since upgraded or removed\n * (dangling), and it must still be cleaned up or it would shadow the workspace's copy forever.\n */\n private async removeCoreAspectBootstrapLink(linkPath: string, workspaceDir: string): Promise<void> {\n try {\n if (!fs.lstatSync(linkPath).isSymbolicLink()) return;\n } catch {\n return; // nothing at this path\n }\n try {\n if (this._realpathIsInside(linkPath, workspaceDir)) return;\n } catch {\n // dangling link - fall through and remove it\n }\n await fs.remove(linkPath);\n }\n\n private isBitRepoWorkspace(dir: string) {\n // A special condition to not link core aspects in bit workspace itself\n if (this.aspectLoader.mainAspect?.path.startsWith(dir)) {\n return true;\n }\n return false;\n }\n\n private linkCoreAspect(\n id: string,\n {\n targetModulesDir,\n mainAspectPath,\n hasLocalInstallation,\n }: {\n targetModulesDir: string;\n mainAspectPath: string;\n hasLocalInstallation?: boolean;\n }\n ): CoreAspectLinkResult | undefined {\n const name = getCoreAspectName(id);\n const packageName = getCoreAspectPackageName(id);\n let aspectDir = path.join(mainAspectPath, 'dist', name);\n const target = path.join(targetModulesDir, packageName);\n const fromDir = this._getPkgPathFromCurrentBitDir(packageName);\n if (fromDir) {\n return { aspectId: id, linkDetail: { packageName, from: fromDir, to: target } };\n }\n const shouldSymlink = this.removeSymlinkTarget(target, hasLocalInstallation);\n if (!shouldSymlink) return undefined;\n const isAspectDirExist = fs.pathExistsSync(aspectDir);\n if (!isAspectDirExist) {\n this.logger.debug(`linkCoreAspect: aspectDir ${aspectDir} does not exist, linking it to ${target}`);\n aspectDir = getAspectDir(id);\n return { aspectId: id, linkDetail: { packageName, from: aspectDir, to: target } };\n }\n\n try {\n // eslint-disable-next-line global-require, import/no-dynamic-require\n const module = require(aspectDir);\n const aspectPath = path.resolve(path.join(module.path, '..', '..'));\n this.logger.debug(`linkCoreAspect: linking aspectPath ${aspectPath} to ${target}`);\n return { aspectId: id, linkDetail: { packageName, from: aspectPath, to: target } };\n } catch (err: any) {\n throw new CoreAspectLinkError(id, err);\n }\n }\n\n /**\n * returns true if it's safe to symlink it later.\n */\n private removeSymlinkTarget(targetPath: string, hasLocalInstallation = false): boolean {\n // TODO: change to fs.lstatSync(dest, {throwIfNoEntry: false});\n // TODO: this requires to upgrade node to v15.3.0 to have the throwIfNoEntry property (maybe upgrade fs-extra will work as well)\n // TODO: we don't use fs.pathExistsSync since it will return false in case the dest is a symlink which will result error on write\n let targetStat: Stats | undefined;\n try {\n targetStat = fs.lstatSync(targetPath);\n // eslint-disable-next-line no-empty\n } catch {}\n if (targetStat && !hasLocalInstallation) {\n // Do not override links created by other means\n if (!targetStat.isSymbolicLink()) {\n this.logger.debug(`removing link target, target ${targetPath} already exist. skipping it`);\n return false;\n }\n return true;\n }\n return true;\n }\n\n private _getPkgPathFromCurrentBitDir(packageName: string): string | undefined {\n if (!this._currentBitDir) return undefined;\n return path.join(this._currentBitDir, 'node_modules', packageName);\n }\n\n private linkNonCorePackages(rootDir: string, packageName: string): LinkDetail {\n const target = path.join(rootDir, 'node_modules', packageName);\n const fromDirBvm = this._getPkgPathFromCurrentBitDir(packageName);\n if (fromDirBvm) {\n return { packageName, from: fromDirBvm, to: target };\n }\n const fromDirBitRepo = getDistDirForDevEnv(packageName);\n return { packageName, from: fromDirBitRepo, to: target };\n }\n\n private linkNonAspectCorePackages(rootDir: string, name: string, mainAspectPath: string): LinkDetail | undefined {\n const distDir = path.join(mainAspectPath, 'dist', name);\n\n const packageName = `@teambit/${name}`;\n const target = path.join(rootDir, 'node_modules', packageName);\n const fromDir = this._getPkgPathFromCurrentBitDir(packageName);\n if (fromDir) {\n return { packageName, from: fromDir, to: target };\n }\n const isDistDirExist = fs.pathExistsSync(distDir);\n if (!isDistDirExist) {\n const newDir = getDistDirForDevEnv(packageName);\n return { packageName, from: newDir, to: target };\n }\n\n try {\n // eslint-disable-next-line global-require, import/no-dynamic-require\n const module = require(distDir);\n const resolvedPath = path.resolve(path.join(module.path, '..', '..'));\n return { packageName, from: resolvedPath, to: target };\n } catch (err: any) {\n throw new NonAspectCorePackageLinkError(err, packageName);\n }\n }\n}\n\n/**\n * When running dev env (bd) we need to get the harmony/legacy folder from the node_modules of the clone\n */\nfunction getDistDirForDevEnv(packageName: string): string {\n let moduleDirectory = require.resolve(packageName);\n let dirPath;\n if (moduleDirectory.includes(packageName)) {\n dirPath = path.join(moduleDirectory, '../..'); // to remove the \"index.js\" at the end\n } else {\n // This is usually required for the @teambit/legacy, as we re inside the nm so we can't find it in the other way\n const nmDir = __dirname.substring(0, __dirname.indexOf('@teambit'));\n dirPath = path.join(nmDir, packageName);\n moduleDirectory = require.resolve(packageName, { paths: [nmDir] });\n }\n if (!fs.existsSync(dirPath)) {\n throw new BitError(`unable to find ${packageName} in ${dirPath}`);\n }\n\n return dirPath;\n}\n\n// TODO: extract to new component\nfunction resolveModuleFromDir(fromDir: string, moduleId: string, silent = true): string | undefined {\n if (silent) {\n return resolveFrom.silent(fromDir, moduleId);\n }\n return resolveFrom(fromDir, moduleId);\n}\n\n// TODO: extract to new component\nfunction resolveModuleDirFromFile(resolvedModulePath: string, moduleId: string): string {\n const NM = 'node_modules';\n if (resolvedModulePath.includes(NM)) {\n return path.join(resolvedModulePath.slice(0, resolvedModulePath.lastIndexOf(NM) + NM.length), moduleId);\n }\n\n const [start, end] = resolvedModulePath.split('@');\n if (!end) return path.basename(resolvedModulePath);\n const versionStr = head(end.split('/'));\n return `${start}@${versionStr}`;\n}\n\nfunction isPathSymlink(folderPath: string): boolean | undefined {\n // TODO: change to fs.lstatSync(dest, {throwIfNoEntry: false}); once upgrade fs-extra\n try {\n const stat = fs.lstatSync(folderPath);\n return stat.isSymbolicLink();\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,iBAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,gBAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA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,EAACnK,OAAO,EAAEiK,QAAQ,CAAC;AACvC;;AAEA;AACA,SAASvH,wBAAwBA,CAAC0H,kBAA0B,EAAEH,QAAgB,EAAU;EACtF,MAAMI,EAAE,GAAG,cAAc;EACzB,IAAID,kBAAkB,CAACT,QAAQ,CAACU,EAAE,CAAC,EAAE;IACnC,OAAOxN,eAAI,CAACC,IAAI,CAACsN,kBAAkB,CAACE,KAAK,CAAC,CAAC,EAAEF,kBAAkB,CAACG,WAAW,CAACF,EAAE,CAAC,GAAGA,EAAE,CAAC3R,MAAM,CAAC,EAAEuR,QAAQ,CAAC;EACzG;EAEA,MAAM,CAACO,KAAK,EAAEC,GAAG,CAAC,GAAGL,kBAAkB,CAACM,KAAK,CAAC,GAAG,CAAC;EAClD,IAAI,CAACD,GAAG,EAAE,OAAO5N,eAAI,CAAC8N,QAAQ,CAACP,kBAAkB,CAAC;EAClD,MAAMQ,UAAU,GAAG,IAAAC,cAAI,EAACJ,GAAG,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC;EACvC,OAAO,GAAGF,KAAK,IAAII,UAAU,EAAE;AACjC;AAEA,SAAS5H,aAAaA,CAAC8H,UAAkB,EAAuB;EAC9D;EACA,IAAI;IACF,MAAMC,IAAI,GAAG/N,kBAAE,CAACwL,SAAS,CAACsC,UAAU,CAAC;IACrC,OAAOC,IAAI,CAAC7I,cAAc,CAAC,CAAC;EAC9B,CAAC,CAAC,MAAM;IACN,OAAOpD,SAAS;EAClB;AACF","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  import type { PeerDependencyRules } from '@pnpm/types';
2
2
  import type { WorkspacePolicyConfigObject } from './policy';
3
- import type { PackageImportMethod } from './package-manager';
3
+ import type { PackageImportMethod, PackageExtension } from './package-manager';
4
4
  export type NodeLinker = 'hoisted' | 'isolated';
5
5
  export type ComponentRangePrefix = '~' | '^' | '+' | '-';
6
6
  export interface DependencyResolverWorkspaceConfig {
@@ -72,6 +72,10 @@ export interface DependencyResolverWorkspaceConfig {
72
72
  capsulesOverrides?: Record<string, string>;
73
73
  nodeLinker?: NodeLinker;
74
74
  packageImportMethod?: PackageImportMethod;
75
+ enableGlobalVirtualStore?: boolean;
76
+ globalVirtualStoreDir?: string;
77
+ patchedDependencies?: Record<string, string>;
78
+ packageExtensions?: Record<string, PackageExtension>;
75
79
  sideEffectsCache?: boolean;
76
80
  rootComponents?: boolean;
77
81
  nodeVersion?: string;
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["dependency-resolver-workspace-config.ts"],"sourcesContent":["import type { PeerDependencyRules } from '@pnpm/types';\nimport type { WorkspacePolicyConfigObject } from './policy';\nimport type { PackageImportMethod } from './package-manager';\n\nexport type NodeLinker = 'hoisted' | 'isolated';\n\nexport type ComponentRangePrefix = '~' | '^' | '+' | '-';\n\nexport interface DependencyResolverWorkspaceConfig {\n policy: WorkspacePolicyConfigObject;\n /**\n * choose the package manager for Bit to use. you can choose between 'npm', 'yarn', 'pnpm'\n * and 'librarian'. our recommendation is use 'librarian' which reduces package duplicates\n * and totally removes the need of a 'node_modules' directory in your project.\n */\n packageManager?: string;\n\n /**\n * A proxy server for out going network requests by the package manager\n * Used for both http and https requests (unless the httpsProxy is defined)\n */\n proxy?: string;\n\n /**\n * A proxy server for outgoing https requests by the package manager (fallback to proxy server if not defined)\n * Use this in case you want different proxy for http and https requests.\n */\n httpsProxy?: string;\n\n /**\n * A path to a file containing one or multiple Certificate Authority signing certificates.\n * allows for multiple CA's, as well as for the CA information to be stored in a file on disk.\n */\n ca?: string;\n\n /**\n * Whether or not to do SSL key validation when making requests to the registry via https\n */\n strictSsl?: string;\n\n /**\n * A client certificate to pass when accessing the registry. Values should be in PEM format (Windows calls it \"Base-64 encoded X.509 (.CER)\") with newlines replaced by the string \"\\n\". For example:\n * cert=\"----BEGIN CERTIFICATE-----\\nXXXX\\nXXXX\\n-----END CERTIFICATE----\"\n * It is not the path to a certificate file (and there is no \"certfile\" option).\n */\n cert?: string;\n\n /**\n * A client key to pass when accessing the registry. Values should be in PEM format with newlines replaced by the string \"\\n\". For example:\n * key=\"----BEGIN PRIVATE KEY-----\\nXXXX\\nXXXX\\n-----END PRIVATE KEY----\"\n * It is not the path to a key file (and there is no \"keyfile\" option).\n */\n key?: string;\n\n /**\n * A comma-separated string of domain extensions that a proxy should not be used for.\n */\n noProxy?: string;\n\n /**\n * The IP address of the local interface to use when making connections to the npm registry.\n */\n localAddress?: string;\n\n /**\n * How many times to retry if Bit fails to fetch from the registry.\n */\n fetchRetries?: number;\n\n /*\n * The exponential factor for retry backoff.\n */\n fetchRetryFactor?: number;\n\n /*\n * The minimum (base) timeout for retrying requests.\n */\n fetchRetryMintimeout?: number;\n\n /*\n * The maximum fallback timeout to ensure the retry factor does not make requests too long.\n */\n fetchRetryMaxtimeout?: number;\n\n /*\n * The maximum amount of time (in milliseconds) to wait for HTTP requests to complete.\n */\n fetchTimeout?: number;\n\n /*\n * The maximum number of connections to use per origin (protocol/host/port combination).\n */\n maxSockets?: number;\n\n /*\n * Controls the maximum number of HTTP(S) requests to process simultaneously.\n */\n networkConcurrency?: number;\n\n /*\n * Set the prefix to use when adding dependency to workspace.jsonc via bit install\n * to lock version to exact version you can use empty string (default)\n */\n savePrefix?: string;\n\n /*\n * in case you want to disable this proxy set this config to false\n *\n */\n installFromBitDevRegistry?: boolean;\n\n /*\n * map of extra arguments to pass to the configured package manager upon the installation\n * of dependencies.\n */\n packageManagerArgs?: string[];\n\n /*\n * This field allows to instruct the package manager to override any dependency in the dependency graph.\n * This is useful to enforce all your packages to use a single version of a dependency, backport a fix,\n * or replace a dependency with a fork.\n */\n overrides?: Record<string, string>;\n\n /**\n * This is similar to overrides, but will only affect installation in capsules.\n * In case overrides is configured and this not, the regular overrides will affect capsules as well.\n * in case both configured, capsulesOverrides will be used for capsules, and overrides will affect the workspace.\n */\n capsulesOverrides?: Record<string, string>;\n\n /*\n * Defines what linker should be used for installing Node.js packages.\n * Supported values are hoisted and isolated.\n */\n nodeLinker?: NodeLinker;\n\n /*\n * Controls the way packages are imported from the store.\n */\n packageImportMethod?: PackageImportMethod;\n\n /*\n * Use and cache the results of (pre/post)install hooks.\n */\n sideEffectsCache?: boolean;\n\n /*\n * The list of components that should be installed in isolation from the workspace.\n * The component's package names should be used in this list, not their component IDs.\n */\n rootComponents?: boolean;\n\n /*\n * The node version to use when checking a package's engines setting.\n */\n nodeVersion?: string;\n\n /*\n * Refuse to install any package that claims to not be compatible with the current Node.js version.\n */\n engineStrict?: boolean;\n\n /*\n * Rules to mute specific peer dependeny warnings.\n */\n peerDependencyRules?: PeerDependencyRules;\n\n /*\n * This setting is \"true\" by default and tells bit to link core aspects to the node_modules of the workspace.\n * It only makes sense to set this to \"false\" in a workspace in which core aspects are actually developed.\n */\n linkCoreAspects?: boolean;\n\n /**\n * When false, Bit will create a shared node_modules directory for all components in a capsule.\n */\n isolatedCapsules?: boolean;\n\n /**\n * Ignore the builds of specific dependencies. The \"preinstall\", \"install\", and \"postinstall\" scripts\n * of the listed packages will not be executed during installation.\n */\n neverBuiltDependencies?: string[];\n\n /**\n * Fine-grained control over dependency lifecycle scripts. Allows explicitly permitting (true), blocking (false), or warning ('warn')\n * for specific dependencies' \"preinstall\", \"install\", and \"postinstall\" scripts during installation.\n */\n allowScripts?: Record<string, boolean | 'warn'>;\n\n /**\n * Set this to true in order to allow all dependencies to run install scripts.\n */\n dangerouslyAllowAllScripts?: boolean;\n\n /**\n * If true, staleness checks for cached data will be bypassed, but missing data will be requested from the server.\n */\n preferOffline?: boolean;\n\n /**\n * When true, components in capsules are symlinked into their own node_modules.\n */\n capsuleSelfReference?: boolean;\n\n /**\n * Tells pnpm which packages should be hoisted to node_modules/.pnpm/node_modules.\n * By default, all packages are hoisted - however, if you know that only some flawed packages have phantom dependencies,\n * you can use this option to exclusively hoist the phantom dependencies (recommended).\n */\n hoistPatterns?: string[];\n\n /**\n * When true, dependencies from the workspace are hoisted to node_modules/.pnpm/node_modules\n * even if they are found in the root node_modules\n */\n hoistInjectedDependencies?: boolean;\n\n /**\n * Tells pnpm to automatically install peer dependencies. It is true by default.\n */\n autoInstallPeers?: boolean;\n\n /**\n * When true (default), pnpm will deduplicate peer dependencies.\n * Set to false to disable peer dependency deduplication.\n */\n dedupePeers?: boolean;\n\n /**\n * When true (default), env peer dependencies defined in env.jsonc are resolved once and merged\n * into the workspace root manifest as regular dependencies, instead of being injected into each\n * component's manifest individually. Conflicts between envs are resolved by picking the version\n * that satisfies the most envs, with a warning logged for any conflicts.\n * Set to false to revert to the legacy per-component env peer injection behavior.\n */\n resolveEnvPeersFromRoot?: boolean;\n\n /**\n * When true, ALL env peer dependencies are forced to the workspace root manifest,\n * even when different envs specify conflicting versions. The best version is chosen\n * (satisfying the most envs) and a warning is logged for unsatisfied envs.\n * When false (default), conflicting peers without `workspaceSingleton` are injected\n * per-component, allowing different envs to use different versions.\n * Only applies when resolveEnvPeersFromRoot is true.\n */\n forceEnvPeersToRoot?: boolean;\n\n /**\n * By default, Bit saves component dependencies with exact versions (pinned) in the package.json,\n * even if the dependency-resolver policy specifies a version range.\n *\n * To preserve the range defined in the policy, set this value to \"+\".\n * To apply a predefined range (\"~\" or \"^\") to other component dependencies not covered by the policy,\n * set this to the desired range symbol.\n */\n componentRangePrefix?: ComponentRangePrefix;\n\n externalPackageManager?: boolean;\n\n /**\n * Defines the minimum number of minutes that must pass after a version is published before pnpm will install it.\n * This applies to all dependencies, including transitive ones.\n */\n minimumReleaseAge?: number;\n\n /**\n * If you set minimumReleaseAge but need certain dependencies to always install the newest version immediately,\n * you can list them under minimumReleaseAgeExclude. The exclusion works by package name or package name pattern\n * and applies to all versions of that package.\n */\n minimumReleaseAgeExclude?: string[];\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["dependency-resolver-workspace-config.ts"],"sourcesContent":["import type { PeerDependencyRules } from '@pnpm/types';\nimport type { WorkspacePolicyConfigObject } from './policy';\nimport type { PackageImportMethod, PackageExtension } from './package-manager';\n\nexport type NodeLinker = 'hoisted' | 'isolated';\n\nexport type ComponentRangePrefix = '~' | '^' | '+' | '-';\n\nexport interface DependencyResolverWorkspaceConfig {\n policy: WorkspacePolicyConfigObject;\n /**\n * choose the package manager for Bit to use. you can choose between 'npm', 'yarn', 'pnpm'\n * and 'librarian'. our recommendation is use 'librarian' which reduces package duplicates\n * and totally removes the need of a 'node_modules' directory in your project.\n */\n packageManager?: string;\n\n /**\n * A proxy server for out going network requests by the package manager\n * Used for both http and https requests (unless the httpsProxy is defined)\n */\n proxy?: string;\n\n /**\n * A proxy server for outgoing https requests by the package manager (fallback to proxy server if not defined)\n * Use this in case you want different proxy for http and https requests.\n */\n httpsProxy?: string;\n\n /**\n * A path to a file containing one or multiple Certificate Authority signing certificates.\n * allows for multiple CA's, as well as for the CA information to be stored in a file on disk.\n */\n ca?: string;\n\n /**\n * Whether or not to do SSL key validation when making requests to the registry via https\n */\n strictSsl?: string;\n\n /**\n * A client certificate to pass when accessing the registry. Values should be in PEM format (Windows calls it \"Base-64 encoded X.509 (.CER)\") with newlines replaced by the string \"\\n\". For example:\n * cert=\"----BEGIN CERTIFICATE-----\\nXXXX\\nXXXX\\n-----END CERTIFICATE----\"\n * It is not the path to a certificate file (and there is no \"certfile\" option).\n */\n cert?: string;\n\n /**\n * A client key to pass when accessing the registry. Values should be in PEM format with newlines replaced by the string \"\\n\". For example:\n * key=\"----BEGIN PRIVATE KEY-----\\nXXXX\\nXXXX\\n-----END PRIVATE KEY----\"\n * It is not the path to a key file (and there is no \"keyfile\" option).\n */\n key?: string;\n\n /**\n * A comma-separated string of domain extensions that a proxy should not be used for.\n */\n noProxy?: string;\n\n /**\n * The IP address of the local interface to use when making connections to the npm registry.\n */\n localAddress?: string;\n\n /**\n * How many times to retry if Bit fails to fetch from the registry.\n */\n fetchRetries?: number;\n\n /*\n * The exponential factor for retry backoff.\n */\n fetchRetryFactor?: number;\n\n /*\n * The minimum (base) timeout for retrying requests.\n */\n fetchRetryMintimeout?: number;\n\n /*\n * The maximum fallback timeout to ensure the retry factor does not make requests too long.\n */\n fetchRetryMaxtimeout?: number;\n\n /*\n * The maximum amount of time (in milliseconds) to wait for HTTP requests to complete.\n */\n fetchTimeout?: number;\n\n /*\n * The maximum number of connections to use per origin (protocol/host/port combination).\n */\n maxSockets?: number;\n\n /*\n * Controls the maximum number of HTTP(S) requests to process simultaneously.\n */\n networkConcurrency?: number;\n\n /*\n * Set the prefix to use when adding dependency to workspace.jsonc via bit install\n * to lock version to exact version you can use empty string (default)\n */\n savePrefix?: string;\n\n /*\n * in case you want to disable this proxy set this config to false\n *\n */\n installFromBitDevRegistry?: boolean;\n\n /*\n * map of extra arguments to pass to the configured package manager upon the installation\n * of dependencies.\n */\n packageManagerArgs?: string[];\n\n /*\n * This field allows to instruct the package manager to override any dependency in the dependency graph.\n * This is useful to enforce all your packages to use a single version of a dependency, backport a fix,\n * or replace a dependency with a fork.\n */\n overrides?: Record<string, string>;\n\n /**\n * This is similar to overrides, but will only affect installation in capsules.\n * In case overrides is configured and this not, the regular overrides will affect capsules as well.\n * in case both configured, capsulesOverrides will be used for capsules, and overrides will affect the workspace.\n */\n capsulesOverrides?: Record<string, string>;\n\n /*\n * Defines what linker should be used for installing Node.js packages.\n * Supported values are hoisted and isolated.\n */\n nodeLinker?: NodeLinker;\n\n /*\n * Controls the way packages are imported from the store.\n */\n packageImportMethod?: PackageImportMethod;\n\n /*\n * Opt in to pnpm's global virtual store. When enabled, dependency directories are created once\n * in a directory shared by all workspaces on the machine, instead of being re-created inside\n * every `node_modules/.pnpm`. This makes installation significantly faster, at the cost of a\n * virtual store that is no longer contained in the workspace.\n * Capsules are unaffected - they always keep the project-local layout. It also has no effect\n * when `nodeLinker` is `hoisted`, which uses no virtual store.\n */\n enableGlobalVirtualStore?: boolean;\n\n /*\n * Path to the global virtual store directory. Defaults to pnpm's own shared `<storeDir>/links`.\n * Only used when `enableGlobalVirtualStore` is on.\n */\n globalVirtualStoreDir?: string;\n\n /*\n * A map of package name (optionally with a version range) to a patch file path,\n * relative to the workspace root. Equivalent to pnpm's `patchedDependencies`.\n */\n patchedDependencies?: Record<string, string>;\n\n /*\n * Declare dependencies that a published package uses but forgot to declare (\"phantom\"\n * dependencies). Equivalent to pnpm's `packageExtensions`.\n * This matters most with `enableGlobalVirtualStore`: a package in the shared store cannot reach\n * anything hoisted into this workspace's `node_modules`, so declaring the dependency is the only\n * way to put it where the package can resolve it.\n */\n packageExtensions?: Record<string, PackageExtension>;\n\n /*\n * Use and cache the results of (pre/post)install hooks.\n */\n sideEffectsCache?: boolean;\n\n /*\n * The list of components that should be installed in isolation from the workspace.\n * The component's package names should be used in this list, not their component IDs.\n */\n rootComponents?: boolean;\n\n /*\n * The node version to use when checking a package's engines setting.\n */\n nodeVersion?: string;\n\n /*\n * Refuse to install any package that claims to not be compatible with the current Node.js version.\n */\n engineStrict?: boolean;\n\n /*\n * Rules to mute specific peer dependeny warnings.\n */\n peerDependencyRules?: PeerDependencyRules;\n\n /*\n * This setting is \"true\" by default and tells bit to link core aspects to the node_modules of the workspace.\n * It only makes sense to set this to \"false\" in a workspace in which core aspects are actually developed.\n */\n linkCoreAspects?: boolean;\n\n /**\n * When false, Bit will create a shared node_modules directory for all components in a capsule.\n */\n isolatedCapsules?: boolean;\n\n /**\n * Ignore the builds of specific dependencies. The \"preinstall\", \"install\", and \"postinstall\" scripts\n * of the listed packages will not be executed during installation.\n */\n neverBuiltDependencies?: string[];\n\n /**\n * Fine-grained control over dependency lifecycle scripts. Allows explicitly permitting (true), blocking (false), or warning ('warn')\n * for specific dependencies' \"preinstall\", \"install\", and \"postinstall\" scripts during installation.\n */\n allowScripts?: Record<string, boolean | 'warn'>;\n\n /**\n * Set this to true in order to allow all dependencies to run install scripts.\n */\n dangerouslyAllowAllScripts?: boolean;\n\n /**\n * If true, staleness checks for cached data will be bypassed, but missing data will be requested from the server.\n */\n preferOffline?: boolean;\n\n /**\n * When true, components in capsules are symlinked into their own node_modules.\n */\n capsuleSelfReference?: boolean;\n\n /**\n * Tells pnpm which packages should be hoisted to node_modules/.pnpm/node_modules.\n * By default, all packages are hoisted - however, if you know that only some flawed packages have phantom dependencies,\n * you can use this option to exclusively hoist the phantom dependencies (recommended).\n */\n hoistPatterns?: string[];\n\n /**\n * When true, dependencies from the workspace are hoisted to node_modules/.pnpm/node_modules\n * even if they are found in the root node_modules\n */\n hoistInjectedDependencies?: boolean;\n\n /**\n * Tells pnpm to automatically install peer dependencies. It is true by default.\n */\n autoInstallPeers?: boolean;\n\n /**\n * When true (default), pnpm will deduplicate peer dependencies.\n * Set to false to disable peer dependency deduplication.\n */\n dedupePeers?: boolean;\n\n /**\n * When true (default), env peer dependencies defined in env.jsonc are resolved once and merged\n * into the workspace root manifest as regular dependencies, instead of being injected into each\n * component's manifest individually. Conflicts between envs are resolved by picking the version\n * that satisfies the most envs, with a warning logged for any conflicts.\n * Set to false to revert to the legacy per-component env peer injection behavior.\n */\n resolveEnvPeersFromRoot?: boolean;\n\n /**\n * When true, ALL env peer dependencies are forced to the workspace root manifest,\n * even when different envs specify conflicting versions. The best version is chosen\n * (satisfying the most envs) and a warning is logged for unsatisfied envs.\n * When false (default), conflicting peers without `workspaceSingleton` are injected\n * per-component, allowing different envs to use different versions.\n * Only applies when resolveEnvPeersFromRoot is true.\n */\n forceEnvPeersToRoot?: boolean;\n\n /**\n * By default, Bit saves component dependencies with exact versions (pinned) in the package.json,\n * even if the dependency-resolver policy specifies a version range.\n *\n * To preserve the range defined in the policy, set this value to \"+\".\n * To apply a predefined range (\"~\" or \"^\") to other component dependencies not covered by the policy,\n * set this to the desired range symbol.\n */\n componentRangePrefix?: ComponentRangePrefix;\n\n externalPackageManager?: boolean;\n\n /**\n * Defines the minimum number of minutes that must pass after a version is published before pnpm will install it.\n * This applies to all dependencies, including transitive ones.\n */\n minimumReleaseAge?: number;\n\n /**\n * If you set minimumReleaseAge but need certain dependencies to always install the newest version immediately,\n * you can list them under minimumReleaseAgeExclude. The exclusion works by package name or package name pattern\n * and applies to all versions of that package.\n */\n minimumReleaseAgeExclude?: string[];\n}\n"],"mappings":"","ignoreList":[]}
@@ -155,6 +155,40 @@ export declare class DependencyResolverMain {
155
155
  isolatedCapsules(): boolean;
156
156
  harmonyVersionInRootPolicy(): string | undefined;
157
157
  nodeLinker(packageManagerName?: string): NodeLinker;
158
+ /**
159
+ * whether dependency directories should be created once in pnpm's global virtual store and
160
+ * shared across workspaces and capsules, rather than re-created inside every
161
+ * `node_modules/.pnpm`.
162
+ *
163
+ * opt-in, in precedence order: the workspace config, then the `enable_global_virtual_store`
164
+ * global config, then off. `BIT_ENABLE_GLOBAL_VIRTUAL_STORE` overrides both - it is what the e2e
165
+ * suite flips to run the whole matrix under the global virtual store.
166
+ *
167
+ * always off under `nodeLinker: hoisted`: the hoisted linker copies packages straight into
168
+ * `node_modules`, so there is no virtual store for the global one to replace. The pnpm adapter
169
+ * forces the engine option off in that case (see `lynx.ts`); reporting it off here too keeps
170
+ * every store-gated behavior (core-aspect links into the hoisted store, `NODE_PATH` bootstrap,
171
+ * the layout-transition guard) consistent with what the engine actually does.
172
+ */
173
+ enableGlobalVirtualStore(): boolean;
174
+ /**
175
+ * the directory the global virtual store materializes dependency directories in, or undefined
176
+ * when the global virtual store is off.
177
+ *
178
+ * pnpm's own shared `<storeDir>/links` root by default (see
179
+ * `PnpmPackageManager.getGlobalVirtualStoreDir` for why the shared root works and is
180
+ * preferable), overridable through the `globalVirtualStoreDir` config. The core aspects being
181
+ * phantom dependencies of every published env is solved outside the store: they are linked into
182
+ * the workspace's private hoisted directory (`DependencyLinker.linkCoreAspectsToHoistedStore`),
183
+ * which the hoisted-resolution bridge puts on the resolution path of store-linked packages.
184
+ */
185
+ getGlobalVirtualStoreDir(rootDir?: string): Promise<string | undefined>;
186
+ /**
187
+ * stable identifier of the bit installation that is running, used to give it a private global
188
+ * virtual store root. Two checkouts of the same bit version ship different core aspects, so the
189
+ * version alone is not enough to tell them apart.
190
+ */
191
+ private bitInstallationId;
158
192
  linkCoreAspects(): boolean;
159
193
  /**
160
194
  * register a new package manager to the dependency resolver.
@@ -86,6 +86,20 @@ function _path() {
86
86
  };
87
87
  return data;
88
88
  }
89
+ function _crypto() {
90
+ const data = require("crypto");
91
+ _crypto = function () {
92
+ return data;
93
+ };
94
+ return data;
95
+ }
96
+ function _bit() {
97
+ const data = require("@teambit/bit.get-bit-version");
98
+ _bit = function () {
99
+ return data;
100
+ };
101
+ return data;
102
+ }
89
103
  function _lodash() {
90
104
  const data = require("lodash");
91
105
  _lodash = function () {
@@ -449,6 +463,71 @@ class DependencyResolverMain {
449
463
  if (pmName === 'teambit.dependencies/yarn') return 'hoisted';
450
464
  return 'isolated';
451
465
  }
466
+
467
+ /**
468
+ * whether dependency directories should be created once in pnpm's global virtual store and
469
+ * shared across workspaces and capsules, rather than re-created inside every
470
+ * `node_modules/.pnpm`.
471
+ *
472
+ * opt-in, in precedence order: the workspace config, then the `enable_global_virtual_store`
473
+ * global config, then off. `BIT_ENABLE_GLOBAL_VIRTUAL_STORE` overrides both - it is what the e2e
474
+ * suite flips to run the whole matrix under the global virtual store.
475
+ *
476
+ * always off under `nodeLinker: hoisted`: the hoisted linker copies packages straight into
477
+ * `node_modules`, so there is no virtual store for the global one to replace. The pnpm adapter
478
+ * forces the engine option off in that case (see `lynx.ts`); reporting it off here too keeps
479
+ * every store-gated behavior (core-aspect links into the hoisted store, `NODE_PATH` bootstrap,
480
+ * the layout-transition guard) consistent with what the engine actually does.
481
+ */
482
+ enableGlobalVirtualStore() {
483
+ if (this.nodeLinker() === 'hoisted') return false;
484
+ const fromEnv = process.env.BIT_ENABLE_GLOBAL_VIRTUAL_STORE;
485
+ if (fromEnv != null && fromEnv !== '') return fromEnv === 'true' || fromEnv === '1';
486
+ if (this.config.enableGlobalVirtualStore != null) return this.config.enableGlobalVirtualStore;
487
+ // the config store surfaces hand-edited values as booleans and CLI-set values as strings
488
+ // (see isolatedCapsules); accept both, plus '1' for parity with the env var
489
+ const fromGlobalConfig = this.configStore.getConfig(_legacy().CFG_ENABLE_GLOBAL_VIRTUAL_STORE);
490
+ return fromGlobalConfig === true || fromGlobalConfig === 'true' || fromGlobalConfig === '1';
491
+ }
492
+
493
+ /**
494
+ * the directory the global virtual store materializes dependency directories in, or undefined
495
+ * when the global virtual store is off.
496
+ *
497
+ * pnpm's own shared `<storeDir>/links` root by default (see
498
+ * `PnpmPackageManager.getGlobalVirtualStoreDir` for why the shared root works and is
499
+ * preferable), overridable through the `globalVirtualStoreDir` config. The core aspects being
500
+ * phantom dependencies of every published env is solved outside the store: they are linked into
501
+ * the workspace's private hoisted directory (`DependencyLinker.linkCoreAspectsToHoistedStore`),
502
+ * which the hoisted-resolution bridge puts on the resolution path of store-linked packages.
503
+ */
504
+ async getGlobalVirtualStoreDir(rootDir) {
505
+ if (!this.enableGlobalVirtualStore()) return undefined;
506
+ if (this.config.globalVirtualStoreDir) return this.config.globalVirtualStoreDir;
507
+ const packageManager = this.getPackageManager();
508
+ if (!packageManager?.getGlobalVirtualStoreDir) return undefined;
509
+ return packageManager.getGlobalVirtualStoreDir({
510
+ packageManagerConfigRootDir: rootDir,
511
+ installationId: this.bitInstallationId()
512
+ });
513
+ }
514
+
515
+ /**
516
+ * stable identifier of the bit installation that is running, used to give it a private global
517
+ * virtual store root. Two checkouts of the same bit version ship different core aspects, so the
518
+ * version alone is not enough to tell them apart.
519
+ */
520
+ bitInstallationId() {
521
+ const mainAspectPath = this.aspectLoader.mainAspect?.path ?? '';
522
+ let realMainAspectPath = mainAspectPath;
523
+ try {
524
+ realMainAspectPath = _fsExtra().default.realpathSync(mainAspectPath);
525
+ } catch {
526
+ // a path we cannot resolve still identifies the installation well enough to key on
527
+ }
528
+ const hash = (0, _crypto().createHash)('sha1').update(realMainAspectPath).digest('hex').slice(0, 10);
529
+ return `${(0, _bit().getBitVersionGracefully)() ?? 'unknown'}-${hash}`;
530
+ }
452
531
  linkCoreAspects() {
453
532
  return this.config.linkCoreAspects ?? DependencyResolverMain.defaultConfig.linkCoreAspects;
454
533
  }
@@ -770,7 +849,7 @@ class DependencyResolverMain {
770
849
  const preInstallSubscribers = this.getPreInstallSubscribers();
771
850
  const postInstallSubscribers = this.getPostInstallSubscribers();
772
851
  // TODO: we should somehow pass the cache root dir to the package manager constructor
773
- return new (_dependencyInstaller().DependencyInstaller)(packageManager, this.aspectLoader, this.logger, this, options.rootDir, cacheRootDir, preInstallSubscribers, postInstallSubscribers, options.nodeLinker || this.nodeLinker(packageManagerName), this.config.packageImportMethod, this.config.sideEffectsCache, this.config.nodeVersion, this.config.engineStrict, this.config.peerDependencyRules, this.config.neverBuiltDependencies, this.config.allowScripts, this.config.dangerouslyAllowAllScripts, this.config.preferOffline, this.config.minimumReleaseAge, this.config.minimumReleaseAgeExclude, options.installingContext);
852
+ return new (_dependencyInstaller().DependencyInstaller)(packageManager, this.aspectLoader, this.logger, this, options.rootDir, cacheRootDir, preInstallSubscribers, postInstallSubscribers, options.nodeLinker || this.nodeLinker(packageManagerName), this.config.packageImportMethod, this.config.sideEffectsCache, this.config.nodeVersion, this.config.engineStrict, this.config.peerDependencyRules, this.config.neverBuiltDependencies, this.config.allowScripts, this.config.dangerouslyAllowAllScripts, this.config.preferOffline, this.config.minimumReleaseAge, this.config.minimumReleaseAgeExclude, this.config.patchedDependencies, this.config.packageExtensions, options.installingContext);
774
853
  }
775
854
  getPreInstallSubscribers() {
776
855
  return this.preInstallSlot.values().flat();