@teambit/dependency-resolver 1.0.1096 → 1.0.1097

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 +46 -0
  19. package/dist/hoisted-resolution-bridge.js +291 -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 +64 -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 +25 -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-1786219819000.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 +29 -28
@@ -4,7 +4,7 @@ import { type DependenciesGraph } from '@teambit/objects';
4
4
  import type { Logger } from '@teambit/logger';
5
5
  import type { PathAbsolute } from '@teambit/toolbox.path.path';
6
6
  import type { PeerDependencyRules, ProjectManifest } from '@pnpm/types';
7
- import type { PackageManager, PackageManagerInstallOptions, PackageImportMethod } from './package-manager';
7
+ import type { PackageManager, PackageManagerInstallOptions, PackageImportMethod, PackageExtension } from './package-manager';
8
8
  import type { WorkspacePolicy } from './policy';
9
9
  import type { DependencyResolverMain } from './dependency-resolver.main.runtime';
10
10
  export type DepInstallerContext = {
@@ -65,12 +65,77 @@ export declare class DependencyInstaller {
65
65
  private preferOffline?;
66
66
  private minimumReleaseAge?;
67
67
  private minimumReleaseAgeExclude?;
68
+ private patchedDependencies?;
69
+ private packageExtensions?;
68
70
  private installingContext;
69
71
  constructor(
70
72
  /**
71
73
  * package manager instance.
72
74
  */
73
- packageManager: PackageManager, aspectLoader: AspectLoaderMain, logger: Logger, dependencyResolver: DependencyResolverMain, rootDir?: string | PathAbsolute | undefined, cacheRootDir?: string | PathAbsolute | undefined, preInstallSubscriberList?: PreInstallSubscriberList | undefined, postInstallSubscriberList?: PostInstallSubscriberList | undefined, nodeLinker?: 'hoisted' | 'isolated' | undefined, packageImportMethod?: PackageImportMethod | undefined, sideEffectsCache?: boolean | undefined, nodeVersion?: string | undefined, engineStrict?: boolean | undefined, peerDependencyRules?: PeerDependencyRules | undefined, neverBuiltDependencies?: string[] | undefined, allowScripts?: Record<string, boolean | 'warn'> | undefined, dangerouslyAllowAllScripts?: boolean | undefined, preferOffline?: boolean | undefined, minimumReleaseAge?: number | undefined, minimumReleaseAgeExclude?: string[] | undefined, installingContext?: DepInstallerContext);
75
+ packageManager: PackageManager, aspectLoader: AspectLoaderMain, logger: Logger, dependencyResolver: DependencyResolverMain, rootDir?: string | PathAbsolute | undefined, cacheRootDir?: string | PathAbsolute | undefined, preInstallSubscriberList?: PreInstallSubscriberList | undefined, postInstallSubscriberList?: PostInstallSubscriberList | undefined, nodeLinker?: 'hoisted' | 'isolated' | undefined, packageImportMethod?: PackageImportMethod | undefined, sideEffectsCache?: boolean | undefined, nodeVersion?: string | undefined, engineStrict?: boolean | undefined, peerDependencyRules?: PeerDependencyRules | undefined, neverBuiltDependencies?: string[] | undefined, allowScripts?: Record<string, boolean | 'warn'> | undefined, dangerouslyAllowAllScripts?: boolean | undefined, preferOffline?: boolean | undefined, minimumReleaseAge?: number | undefined, minimumReleaseAgeExclude?: string[] | undefined, patchedDependencies?: Record<string, string> | undefined, packageExtensions?: Record<string, PackageExtension> | undefined, installingContext?: DepInstallerContext);
76
+ /**
77
+ * `packageExtensions` bit ships for published envs whose `tsconfig.json` `extends` a package
78
+ * they never declare, merged under the workspace's own `packageExtensions` so a user entry for
79
+ * the same package always wins.
80
+ *
81
+ * Only applied under the global virtual store. TypeScript resolves `extends` with its own
82
+ * resolver, walking up from the tsconfig's real location: under the project-local layout that
83
+ * walk passes pnpm's privately hoisted `node_modules/.pnpm/node_modules`, which catches any
84
+ * phantom dependency, so these envs work by accident. A global-store slot walks up into the
85
+ * store and finds nothing. Declaring the missing dependency via `packageExtensions` - pnpm's
86
+ * documented remedy for exactly this - places the real package inside the slot's
87
+ * `node_modules`, where the tsconfig resolver finds it.
88
+ *
89
+ * An extension merges *underneath* the manifest (it only adds entries the package lacks), an
90
+ * entry whose package never installs is not an error (unlike `patchedDependencies`), and a
91
+ * `name@range` key scopes an entry to the versions that need it. None of these envs import
92
+ * their extends-target at runtime - the reference lives only in config files - so the added
93
+ * registry copy cannot shadow the host-provided core-aspect singletons.
94
+ *
95
+ * The list covers teambit's own published envs known to carry the phantom `extends`
96
+ * (react-env fixed it in 2.x by inlining, hence the `@1` scope). Third-party envs with the
97
+ * same shape are covered by the user-level `packageExtensions` config this merges under.
98
+ *
99
+ * Both halves of every entry are version-scoped. The keys cover only the majors shipped and
100
+ * verified to carry the phantom - a future major of an env must be re-verified before its
101
+ * range moves, rather than inheriting the workaround (and its injected dependency edge)
102
+ * automatically. The added dependencies are caret-pinned to the major whose file layout the
103
+ * extension exists for - a floating `*` would follow a future major that may not keep
104
+ * `typescript/tsconfig.json` (or the rspack env's `config/`) where the extending tsconfigs
105
+ * point, and would drift across installs.
106
+ */
107
+ private withBuiltInPackageExtensions;
108
+ /**
109
+ * Patch paths are configured relative to the workspace root, but pnpm resolves a relative one
110
+ * from the directory it is installing in. Those coincide for a workspace install and do not for
111
+ * a capsule install, which runs in the capsules directory - the patch would be looked for
112
+ * under the capsule root and the install would fail on the missing file.
113
+ *
114
+ * So capsule installs get absolute paths, resolved against the workspace root the caller passes
115
+ * as the package manager config root. Workspace installs keep the configured spelling: pnpm
116
+ * records it in the lockfile, and an absolute path there would be machine-specific.
117
+ */
118
+ private resolvePatchPaths;
119
+ /**
120
+ * Refuse an install that would switch this workspace between the project-local and the global
121
+ * virtual store while the running bit is installed inside this workspace's `node_modules`.
122
+ *
123
+ * Both layouts are safe in steady state: repeat installs preserve the top-level package
124
+ * directories the running process resolves from, and the end-of-install compile refreshes the
125
+ * per-variant copies (`.pnpm` entries or store slots). A layout *switch* is different - it
126
+ * relocates every injected component package, rebuilding the top-level directories from
127
+ * source, so their compiled `dist` disappears mid-install. A bit running from those very
128
+ * directories loses its own code before it can reach the compile step that would restore it,
129
+ * and dies leaving `node_modules` unusable. The transition has to run once from a bit
130
+ * installation outside the workspace; detect the combination up front and fail before
131
+ * anything is rewritten.
132
+ *
133
+ * The current layout is read off `node_modules/.modules.yaml`: pnpm records `virtualStoreDir`
134
+ * as `.pnpm` for the project-local layout and as a path escaping the workspace for the global
135
+ * one. No manifest (fresh install) or an unreadable one means nothing can be mid-flight -
136
+ * a fresh install writes whichever layout is requested.
137
+ */
138
+ private assertSafeVirtualStoreTransition;
74
139
  install(rootDir: string | undefined, rootPolicy: WorkspacePolicy, componentDirectoryMap: ComponentMap<string>, options?: InstallOptions, packageManagerOptions?: PackageManagerInstallOptions): Promise<{
75
140
  dependenciesChanged: boolean;
76
141
  }>;
@@ -32,6 +32,13 @@ function _exceptions() {
32
32
  };
33
33
  return data;
34
34
  }
35
+ function _hoistedResolutionBridge() {
36
+ const data = require("./hoisted-resolution-bridge");
37
+ _hoistedResolutionBridge = function () {
38
+ return data;
39
+ };
40
+ return data;
41
+ }
35
42
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
36
43
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
37
44
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -53,7 +60,7 @@ class DependencyInstaller {
53
60
  /**
54
61
  * package manager instance.
55
62
  */
56
- packageManager, aspectLoader, logger, dependencyResolver, rootDir, cacheRootDir, preInstallSubscriberList, postInstallSubscriberList, nodeLinker, packageImportMethod, sideEffectsCache, nodeVersion, engineStrict, peerDependencyRules, neverBuiltDependencies, allowScripts, dangerouslyAllowAllScripts, preferOffline, minimumReleaseAge, minimumReleaseAgeExclude, installingContext = {}) {
63
+ packageManager, aspectLoader, logger, dependencyResolver, rootDir, cacheRootDir, preInstallSubscriberList, postInstallSubscriberList, nodeLinker, packageImportMethod, sideEffectsCache, nodeVersion, engineStrict, peerDependencyRules, neverBuiltDependencies, allowScripts, dangerouslyAllowAllScripts, preferOffline, minimumReleaseAge, minimumReleaseAgeExclude, patchedDependencies, packageExtensions, installingContext = {}) {
57
64
  this.packageManager = packageManager;
58
65
  this.aspectLoader = aspectLoader;
59
66
  this.logger = logger;
@@ -74,8 +81,131 @@ class DependencyInstaller {
74
81
  this.preferOffline = preferOffline;
75
82
  this.minimumReleaseAge = minimumReleaseAge;
76
83
  this.minimumReleaseAgeExclude = minimumReleaseAgeExclude;
84
+ this.patchedDependencies = patchedDependencies;
85
+ this.packageExtensions = packageExtensions;
77
86
  this.installingContext = installingContext;
78
87
  }
88
+
89
+ /**
90
+ * `packageExtensions` bit ships for published envs whose `tsconfig.json` `extends` a package
91
+ * they never declare, merged under the workspace's own `packageExtensions` so a user entry for
92
+ * the same package always wins.
93
+ *
94
+ * Only applied under the global virtual store. TypeScript resolves `extends` with its own
95
+ * resolver, walking up from the tsconfig's real location: under the project-local layout that
96
+ * walk passes pnpm's privately hoisted `node_modules/.pnpm/node_modules`, which catches any
97
+ * phantom dependency, so these envs work by accident. A global-store slot walks up into the
98
+ * store and finds nothing. Declaring the missing dependency via `packageExtensions` - pnpm's
99
+ * documented remedy for exactly this - places the real package inside the slot's
100
+ * `node_modules`, where the tsconfig resolver finds it.
101
+ *
102
+ * An extension merges *underneath* the manifest (it only adds entries the package lacks), an
103
+ * entry whose package never installs is not an error (unlike `patchedDependencies`), and a
104
+ * `name@range` key scopes an entry to the versions that need it. None of these envs import
105
+ * their extends-target at runtime - the reference lives only in config files - so the added
106
+ * registry copy cannot shadow the host-provided core-aspect singletons.
107
+ *
108
+ * The list covers teambit's own published envs known to carry the phantom `extends`
109
+ * (react-env fixed it in 2.x by inlining, hence the `@1` scope). Third-party envs with the
110
+ * same shape are covered by the user-level `packageExtensions` config this merges under.
111
+ *
112
+ * Both halves of every entry are version-scoped. The keys cover only the majors shipped and
113
+ * verified to carry the phantom - a future major of an env must be re-verified before its
114
+ * range moves, rather than inheriting the workaround (and its injected dependency edge)
115
+ * automatically. The added dependencies are caret-pinned to the major whose file layout the
116
+ * extension exists for - a floating `*` would follow a future major that may not keep
117
+ * `typescript/tsconfig.json` (or the rspack env's `config/`) where the extending tsconfigs
118
+ * point, and would drift across installs.
119
+ */
120
+ withBuiltInPackageExtensions(fromConfig, enableGlobalVirtualStore) {
121
+ if (!enableGlobalVirtualStore) return fromConfig;
122
+ const react = {
123
+ dependencies: {
124
+ '@teambit/react': '^1.0.0'
125
+ }
126
+ };
127
+ const builtIn = {
128
+ '@teambit/node.envs.node-babel-mocha@<3': react,
129
+ '@teambit/node.envs.node-typescript-mocha@<3': react,
130
+ '@teambit/react.internal.base-react-env@1': react,
131
+ '@teambit/rspack.envs.react-env@<2': react,
132
+ '@teambit/react.react-env@1': react,
133
+ '@teambit/cloud.envs.cloud-react@0': {
134
+ dependencies: {
135
+ '@teambit/rspack.envs.react-env': '^1.0.0'
136
+ }
137
+ }
138
+ };
139
+ return _objectSpread(_objectSpread({}, builtIn), fromConfig);
140
+ }
141
+
142
+ /**
143
+ * Patch paths are configured relative to the workspace root, but pnpm resolves a relative one
144
+ * from the directory it is installing in. Those coincide for a workspace install and do not for
145
+ * a capsule install, which runs in the capsules directory - the patch would be looked for
146
+ * under the capsule root and the install would fail on the missing file.
147
+ *
148
+ * So capsule installs get absolute paths, resolved against the workspace root the caller passes
149
+ * as the package manager config root. Workspace installs keep the configured spelling: pnpm
150
+ * records it in the lockfile, and an absolute path there would be machine-specific.
151
+ */
152
+ resolvePatchPaths(installRootDir, packageManagerConfigRootDir) {
153
+ if (!this.patchedDependencies) return undefined;
154
+ if (!packageManagerConfigRootDir || packageManagerConfigRootDir === installRootDir) {
155
+ return this.patchedDependencies;
156
+ }
157
+ return Object.fromEntries(Object.entries(this.patchedDependencies).map(([selector, patchPath]) => [selector, _path().default.isAbsolute(patchPath) ? patchPath : _path().default.join(packageManagerConfigRootDir, patchPath)]));
158
+ }
159
+
160
+ /**
161
+ * Refuse an install that would switch this workspace between the project-local and the global
162
+ * virtual store while the running bit is installed inside this workspace's `node_modules`.
163
+ *
164
+ * Both layouts are safe in steady state: repeat installs preserve the top-level package
165
+ * directories the running process resolves from, and the end-of-install compile refreshes the
166
+ * per-variant copies (`.pnpm` entries or store slots). A layout *switch* is different - it
167
+ * relocates every injected component package, rebuilding the top-level directories from
168
+ * source, so their compiled `dist` disappears mid-install. A bit running from those very
169
+ * directories loses its own code before it can reach the compile step that would restore it,
170
+ * and dies leaving `node_modules` unusable. The transition has to run once from a bit
171
+ * installation outside the workspace; detect the combination up front and fail before
172
+ * anything is rewritten.
173
+ *
174
+ * The current layout is read off `node_modules/.modules.yaml`: pnpm records `virtualStoreDir`
175
+ * as `.pnpm` for the project-local layout and as a path escaping the workspace for the global
176
+ * one. No manifest (fresh install) or an unreadable one means nothing can be mid-flight -
177
+ * a fresh install writes whichever layout is requested.
178
+ */
179
+ async assertSafeVirtualStoreTransition(finalRootDir, enableGlobalVirtualStore) {
180
+ const modulesDir = _path().default.join(finalRootDir, 'node_modules');
181
+ let modulesManifest;
182
+ try {
183
+ modulesManifest = await _fsExtra().default.readFile(_path().default.join(modulesDir, '.modules.yaml'), 'utf8');
184
+ } catch {
185
+ return;
186
+ }
187
+ // same reader as the bootstrap-time layout gate, so the guard and the bridge can never
188
+ // disagree about which layout the workspace is currently on
189
+ const virtualStoreDir = (0, _hoistedResolutionBridge().parseRecordedVirtualStoreDir)(modulesManifest);
190
+ if (!virtualStoreDir) return;
191
+ // compare real paths on both sides: resolving the recorded dir against the as-given (possibly
192
+ // symlinked) workspace spelling while comparing to the workspace's realpath would misread a
193
+ // project-local store as global for a workspace reached through a symlink
194
+ const workspaceRealpath = await _fsExtra().default.realpath(finalRootDir).catch(() => finalRootDir);
195
+ const resolvedStoreDir = _path().default.resolve(workspaceRealpath, 'node_modules', virtualStoreDir);
196
+ const storeRealpath = await _fsExtra().default.realpath(resolvedStoreDir).catch(() => resolvedStoreDir);
197
+ const currentIsGlobal = !(0, _hoistedResolutionBridge().isPathInsideOrEqual)(storeRealpath, workspaceRealpath);
198
+ if (currentIsGlobal === enableGlobalVirtualStore) return;
199
+
200
+ // the switch only endangers a bit whose own code lives inside the node_modules being
201
+ // rewritten. `__dirname` sits in the running installation's copy of this component; injected
202
+ // workspace packages are real directories, so a workspace-provided bit resolves under the
203
+ // workspace realpath while bvm/global installations resolve elsewhere.
204
+ const runningFrom = await _fsExtra().default.realpath(__dirname).catch(() => __dirname);
205
+ const selfHosted = (0, _hoistedResolutionBridge().isPathInsideOrEqual)(runningFrom, _path().default.join(workspaceRealpath, 'node_modules'));
206
+ if (!selfHosted) return;
207
+ throw new (_exceptions().SelfHostedVirtualStoreTransition)(finalRootDir, enableGlobalVirtualStore);
208
+ }
79
209
  async install(rootDir, rootPolicy, componentDirectoryMap, options = DEFAULT_INSTALL_OPTIONS, packageManagerOptions = DEFAULT_PM_INSTALL_OPTIONS) {
80
210
  const finalRootDir = rootDir ?? this.rootDir;
81
211
  if (!finalRootDir) {
@@ -108,6 +238,11 @@ class DependencyInstaller {
108
238
  if (!finalRootDir) {
109
239
  throw new (_exceptions().RootDirNotDefined)();
110
240
  }
241
+ // guard here rather than in `install()`: workspace installs enter through this method
242
+ // directly (InstallMain._installModules), so `install()` is not a choke point.
243
+ if (!this.installingContext?.inCapsule) {
244
+ await this.assertSafeVirtualStoreTransition(finalRootDir, this.dependencyResolver.enableGlobalVirtualStore());
245
+ }
111
246
  if (options.linkedDependencies) {
112
247
  manifests = JSON.parse(JSON.stringify(manifests));
113
248
  const linkedDependencies = JSON.parse(JSON.stringify(options.linkedDependencies));
@@ -143,6 +278,18 @@ class DependencyInstaller {
143
278
  cacheRootDir: this.cacheRootDir,
144
279
  nodeLinker: this.nodeLinker,
145
280
  packageImportMethod: this.packageImportMethod,
281
+ // Capsules stay on the project-local virtual store even when the global one is enabled.
282
+ // A capsule is a self-contained build sandbox, and TypeScript's declaration emit relies on
283
+ // that: it names the type of an inferred value (`compiler()` returning a `@teambit/compiler`
284
+ // type, say) through the package that declares it, and can only do so while that package
285
+ // sits inside the capsule. Moving env and aspect packages out to the shared store makes
286
+ // `bit build` of any custom env fail with TS2742 ("cannot be named without a reference to
287
+ // ../../../node_modules/@teambit/compiler"). Workspace installs - the ones a user actually
288
+ // waits on repeatedly - still get the global store.
289
+ enableGlobalVirtualStore: !this.installingContext?.inCapsule && this.dependencyResolver.enableGlobalVirtualStore(),
290
+ globalVirtualStoreDir: this.installingContext?.inCapsule ? undefined : await this.dependencyResolver.getGlobalVirtualStoreDir(finalRootDir),
291
+ patchedDependencies: this.resolvePatchPaths(finalRootDir, options.packageManagerConfigRootDir),
292
+ packageExtensions: this.withBuiltInPackageExtensions(this.packageExtensions, !this.installingContext?.inCapsule && this.dependencyResolver.enableGlobalVirtualStore()),
146
293
  minimumReleaseAge: this.minimumReleaseAge,
147
294
  minimumReleaseAgeExclude: this.minimumReleaseAgeExclude,
148
295
  sideEffectsCache: this.sideEffectsCache,
@@ -159,6 +306,13 @@ class DependencyInstaller {
159
306
  dependenciesGraph: options.dependenciesGraph,
160
307
  forcedHarmonyVersion: options.forcedHarmonyVersion
161
308
  }, packageManagerOptions);
309
+ if (this.installingContext?.inCapsule) {
310
+ // the capsule invariant is non-negotiable: caller-provided packageManagerOptions spread
311
+ // last for every other option's sake, but must not move a capsule onto the global store
312
+ // (see the comment above on TypeScript's declaration emit)
313
+ calculatedPmOpts.enableGlobalVirtualStore = false;
314
+ calculatedPmOpts.globalVirtualStoreDir = undefined;
315
+ }
162
316
  if (options.installTeambitBit) {
163
317
  if (!mainAspect.version || !mainAspect.packageName) {
164
318
  throw new (_exceptions().MainAspectNotInstallable)();
@@ -1 +1 @@
1
- {"version":3,"names":["_pMapSeries","data","_interopRequireDefault","require","_path","_fsExtra","_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_PM_INSTALL_OPTIONS","dedupe","copyPeerToRuntimeOnRoot","copyPeerToRuntimeOnComponents","installPeersFromEnvs","DEFAULT_INSTALL_OPTIONS","installTeambitBit","excludeExtensionsDependencies","DependencyInstaller","constructor","packageManager","aspectLoader","logger","dependencyResolver","rootDir","cacheRootDir","preInstallSubscriberList","postInstallSubscriberList","nodeLinker","packageImportMethod","sideEffectsCache","nodeVersion","engineStrict","peerDependencyRules","neverBuiltDependencies","allowScripts","dangerouslyAllowAllScripts","preferOffline","minimumReleaseAge","minimumReleaseAgeExclude","installingContext","install","rootPolicy","componentDirectoryMap","options","packageManagerOptions","finalRootDir","RootDirNotDefined","manifests","getComponentManifests","resolveVersionsFromDependenciesOnly","referenceLocalPackages","rootComponentsForCapsules","includeAllEnvPeers","installComponents","args","runPrePostSubscribers","mainAspect","linkedDependencies","JSON","parse","stringify","forcedHarmonyVersion","dependencies","directDeps","Set","values","manifest","depName","devDependencies","add","name","has","entries","dir","linkedDeps","isJsonCmd","process","argv","includes","hidePackageManagerOutput","Boolean","inCapsule","env","VERBOSE_PM_OUTPUT","calculatedPmOpts","packageManagerConfigRootDir","dedupeInjectedDeps","dependenciesGraph","version","packageName","MainAspectNotInstallable","dependencyId","lifecycleType","rootComponents","keepExistingModulesDir","cleanCompsNodeModules","err","debug","messagePrefix","messageSuffix","message","setStatusLine","startTime","hrtime","installResult","consoleSuccess","pruneModules","dependencyFilterFn","resolveEnvPeersFromRoot","hasRootComponents","filterComponentsFromManifests","createManifestForComponentsWithoutDependencies","workspaceManifest","getWorkspaceManifest","undefined","components","toArray","reduce","acc","component","getPackageName","componentsManifestsMap","get","toJson","copyPeerToRuntime","peerOverrides","promises","map","nmDir","path","join","fs","remove","Promise","all","subscribers","type","mapSeries","subscriber","exports"],"sources":["dependency-installer.ts"],"sourcesContent":["import mapSeries from 'p-map-series';\nimport path from 'path';\nimport fs from 'fs-extra';\nimport type { MainAspect, AspectLoaderMain } from '@teambit/aspect-loader';\nimport type { ComponentMap } from '@teambit/component';\nimport { type DependenciesGraph } from '@teambit/objects';\nimport type { Logger } from '@teambit/logger';\nimport type { PathAbsolute } from '@teambit/toolbox.path.path';\nimport type { PeerDependencyRules, ProjectManifest } from '@pnpm/types';\nimport { MainAspectNotInstallable, RootDirNotDefined } from './exceptions';\nimport type { PackageManager, PackageManagerInstallOptions, PackageImportMethod } from './package-manager';\nimport type { WorkspacePolicy } from './policy';\nimport type { CreateFromComponentsOptions } from './manifest';\nimport type { DependencyResolverMain } from './dependency-resolver.main.runtime';\n\nconst DEFAULT_PM_INSTALL_OPTIONS: PackageManagerInstallOptions = {\n dedupe: true,\n copyPeerToRuntimeOnRoot: true,\n copyPeerToRuntimeOnComponents: false,\n installPeersFromEnvs: false,\n};\n\nconst DEFAULT_INSTALL_OPTIONS: InstallOptions = {\n installTeambitBit: false,\n excludeExtensionsDependencies: false,\n};\n\nexport type DepInstallerContext = {\n inCapsule?: boolean;\n};\n\nexport type InstallArgs = {\n rootDir: string | undefined;\n rootPolicy: WorkspacePolicy;\n componentDirectoryMap: ComponentMap<string>;\n options: InstallOptions;\n packageManagerOptions: PackageManagerInstallOptions;\n};\n\nexport type InstallOptions = {\n installTeambitBit: boolean;\n packageManagerConfigRootDir?: string;\n resolveVersionsFromDependenciesOnly?: boolean;\n linkedDependencies?: Record<string, Record<string, string>>;\n forcedHarmonyVersion?: string;\n excludeExtensionsDependencies?: boolean;\n dedupeInjectedDeps?: boolean;\n dependenciesGraph?: DependenciesGraph;\n};\n\nexport type GetComponentManifestsOptions = {\n componentDirectoryMap: ComponentMap<string>;\n rootPolicy: WorkspacePolicy;\n rootDir: string;\n resolveVersionsFromDependenciesOnly?: boolean;\n referenceLocalPackages?: boolean;\n includeAllEnvPeers?: boolean;\n hasRootComponents?: boolean;\n excludeExtensionsDependencies?: boolean;\n} & Pick<\n PackageManagerInstallOptions,\n | 'dedupe'\n | 'dependencyFilterFn'\n | 'copyPeerToRuntimeOnComponents'\n | 'copyPeerToRuntimeOnRoot'\n | 'installPeersFromEnvs'\n | 'resolveEnvPeersFromRoot'\n>;\n\nexport type PreInstallSubscriber = (installer: DependencyInstaller, installArgs: InstallArgs) => Promise<void>;\nexport type PreInstallSubscriberList = Array<PreInstallSubscriber>;\n\nexport type PostInstallSubscriber = (installer: DependencyInstaller, installArgs: InstallArgs) => Promise<void>;\nexport type PostInstallSubscriberList = Array<PostInstallSubscriber>;\n\nexport class DependencyInstaller {\n constructor(\n /**\n * package manager instance.\n */\n private packageManager: PackageManager,\n\n private aspectLoader: AspectLoaderMain,\n\n private logger: Logger,\n\n private dependencyResolver: DependencyResolverMain,\n\n private rootDir?: string | PathAbsolute,\n\n private cacheRootDir?: string | PathAbsolute,\n\n private preInstallSubscriberList?: PreInstallSubscriberList,\n\n private postInstallSubscriberList?: PostInstallSubscriberList,\n\n private nodeLinker?: 'hoisted' | 'isolated',\n\n private packageImportMethod?: PackageImportMethod,\n\n private sideEffectsCache?: boolean,\n\n private nodeVersion?: string,\n\n private engineStrict?: boolean,\n\n private peerDependencyRules?: PeerDependencyRules,\n\n private neverBuiltDependencies?: string[],\n\n private allowScripts?: Record<string, boolean | 'warn'>,\n\n private dangerouslyAllowAllScripts?: boolean,\n\n private preferOffline?: boolean,\n\n private minimumReleaseAge?: number,\n\n private minimumReleaseAgeExclude?: string[],\n\n private installingContext: DepInstallerContext = {}\n ) {}\n\n async install(\n rootDir: string | undefined,\n rootPolicy: WorkspacePolicy,\n componentDirectoryMap: ComponentMap<string>,\n options: InstallOptions = DEFAULT_INSTALL_OPTIONS,\n packageManagerOptions: PackageManagerInstallOptions = DEFAULT_PM_INSTALL_OPTIONS\n ) {\n const finalRootDir = rootDir ?? this.rootDir;\n if (!finalRootDir) {\n throw new RootDirNotDefined();\n }\n const { manifests } = await this.getComponentManifests({\n ...packageManagerOptions,\n componentDirectoryMap,\n rootPolicy,\n rootDir: finalRootDir,\n resolveVersionsFromDependenciesOnly: options.resolveVersionsFromDependenciesOnly,\n referenceLocalPackages: packageManagerOptions.rootComponentsForCapsules,\n includeAllEnvPeers: packageManagerOptions.rootComponentsForCapsules,\n excludeExtensionsDependencies: options.excludeExtensionsDependencies,\n });\n return this.installComponents(\n finalRootDir,\n manifests,\n rootPolicy,\n componentDirectoryMap,\n options,\n packageManagerOptions\n );\n }\n\n async installComponents(\n rootDir: string | undefined,\n manifests: Record<string, ProjectManifest>,\n rootPolicy: WorkspacePolicy,\n componentDirectoryMap: ComponentMap<string>,\n options: InstallOptions = DEFAULT_INSTALL_OPTIONS,\n packageManagerOptions: PackageManagerInstallOptions = DEFAULT_PM_INSTALL_OPTIONS\n ): Promise<{ dependenciesChanged: boolean }> {\n const args = {\n componentDirectoryMap,\n options,\n packageManagerOptions,\n rootDir,\n rootPolicy,\n };\n await this.runPrePostSubscribers(this.preInstallSubscriberList, 'pre', args);\n const mainAspect: MainAspect = this.aspectLoader.mainAspect;\n const finalRootDir = rootDir || this.rootDir;\n if (!finalRootDir) {\n throw new RootDirNotDefined();\n }\n if (options.linkedDependencies) {\n manifests = JSON.parse(JSON.stringify(manifests));\n const linkedDependencies = JSON.parse(\n JSON.stringify(options.linkedDependencies)\n ) as typeof options.linkedDependencies;\n if (linkedDependencies[finalRootDir]) {\n if (options.forcedHarmonyVersion == null && manifests[finalRootDir].dependencies?.['@teambit/harmony']) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n delete manifests[finalRootDir].dependencies!['@teambit/harmony'];\n }\n const directDeps = new Set<string>();\n Object.values(manifests).forEach((manifest) => {\n for (const depName of Object.keys({ ...manifest.dependencies, ...manifest.devDependencies })) {\n directDeps.add(depName);\n }\n });\n for (const manifest of Object.values(manifests)) {\n if (manifest.name && directDeps.has(manifest.name)) {\n delete linkedDependencies[finalRootDir][manifest.name];\n }\n }\n }\n Object.entries(linkedDependencies).forEach(([dir, linkedDeps]) => {\n if (!manifests[dir]) {\n manifests[dir] = {};\n }\n manifests[dir].dependencies = {\n ...linkedDeps,\n ...manifests[dir].dependencies,\n };\n });\n }\n const isJsonCmd = process.argv.includes('--json') || process.argv.includes('-j');\n const hidePackageManagerOutput =\n Boolean(this.installingContext.inCapsule && process.env.VERBOSE_PM_OUTPUT !== 'true') || isJsonCmd;\n\n // Make sure to take other default if passed options with only one option\n const calculatedPmOpts = {\n ...DEFAULT_PM_INSTALL_OPTIONS,\n cacheRootDir: this.cacheRootDir,\n nodeLinker: this.nodeLinker,\n packageImportMethod: this.packageImportMethod,\n minimumReleaseAge: this.minimumReleaseAge,\n minimumReleaseAgeExclude: this.minimumReleaseAgeExclude,\n sideEffectsCache: this.sideEffectsCache,\n nodeVersion: this.nodeVersion,\n engineStrict: this.engineStrict,\n packageManagerConfigRootDir: options.packageManagerConfigRootDir,\n peerDependencyRules: this.peerDependencyRules,\n hidePackageManagerOutput,\n neverBuiltDependencies: this.neverBuiltDependencies,\n allowScripts: this.allowScripts,\n dangerouslyAllowAllScripts: this.dangerouslyAllowAllScripts,\n preferOffline: this.preferOffline,\n dedupeInjectedDeps: options.dedupeInjectedDeps,\n dependenciesGraph: options.dependenciesGraph,\n forcedHarmonyVersion: options.forcedHarmonyVersion,\n ...packageManagerOptions,\n };\n if (options.installTeambitBit) {\n if (!mainAspect.version || !mainAspect.packageName) {\n throw new MainAspectNotInstallable();\n }\n const version = mainAspect.version;\n rootPolicy.add({\n dependencyId: mainAspect.packageName,\n lifecycleType: 'runtime',\n value: {\n version,\n },\n });\n }\n\n if (!packageManagerOptions.rootComponents && !packageManagerOptions.keepExistingModulesDir) {\n try {\n // Remove node modules dir for all components dirs, since it might contain left overs from previous install.\n //\n // This is not needed when \"rootComponents\" are used, as in that case the package manager handles the node_modules\n // and it never leaves node_modules in a broken state.\n // Removing node_modules in that case would delete useful state information that is used by Yarn or pnpm.\n await this.cleanCompsNodeModules(componentDirectoryMap);\n } catch (err) {\n this.logger.debug('failed to remove node_modules directories from components', err);\n // A failure to remove the node_modules directory should not cause the process to fail\n }\n }\n\n const messagePrefix = 'running package installation';\n const messageSuffix = `using ${this.packageManager.name}`;\n const message = this.installingContext?.inCapsule\n ? `(capsule) ${messagePrefix} in root dir ${this.rootDir} ${messageSuffix}`\n : `${messagePrefix} ${messageSuffix}`;\n if (!hidePackageManagerOutput) {\n this.logger.setStatusLine(message);\n }\n const startTime = process.hrtime();\n\n // TODO: the cache should be probably passed to the package manager constructor not to the install function\n const installResult = await this.packageManager.install(\n {\n rootDir: finalRootDir,\n manifests,\n componentDirectoryMap,\n },\n calculatedPmOpts\n );\n if (!hidePackageManagerOutput) {\n this.logger.consoleSuccess(`done ${message}`, startTime);\n }\n await this.runPrePostSubscribers(this.postInstallSubscriberList, 'post', args);\n return installResult;\n }\n\n public async pruneModules(rootDir: string): Promise<void> {\n if (!this.packageManager.pruneModules) {\n return;\n }\n await this.packageManager.pruneModules(rootDir);\n }\n\n /**\n * Compute all the component manifests (a.k.a. package.json files) that should be passed to the package manager\n * in order to install the dependencies.\n */\n public async getComponentManifests({\n componentDirectoryMap,\n rootPolicy,\n rootDir,\n dedupe,\n dependencyFilterFn,\n copyPeerToRuntimeOnComponents,\n copyPeerToRuntimeOnRoot,\n installPeersFromEnvs,\n resolveEnvPeersFromRoot,\n resolveVersionsFromDependenciesOnly,\n referenceLocalPackages,\n includeAllEnvPeers,\n hasRootComponents,\n excludeExtensionsDependencies,\n }: GetComponentManifestsOptions): Promise<{\n manifests: Record<string, ProjectManifest>;\n peerOverrides: Record<string, string>;\n }> {\n const options: CreateFromComponentsOptions = {\n filterComponentsFromManifests: true,\n createManifestForComponentsWithoutDependencies: true,\n dedupe,\n dependencyFilterFn,\n resolveVersionsFromDependenciesOnly,\n referenceLocalPackages,\n includeAllEnvPeers,\n hasRootComponents,\n excludeExtensionsDependencies,\n };\n const workspaceManifest = await this.dependencyResolver.getWorkspaceManifest(\n undefined,\n undefined,\n rootPolicy,\n rootDir,\n componentDirectoryMap.components,\n options,\n this.installingContext\n );\n const manifests: Record<string, ProjectManifest> = componentDirectoryMap\n .toArray()\n .reduce((acc, [component, dir]) => {\n const packageName = this.dependencyResolver.getPackageName(component);\n const manifest = workspaceManifest.componentsManifestsMap.get(packageName);\n if (manifest) {\n acc[dir] = manifest.toJson({ copyPeerToRuntime: copyPeerToRuntimeOnComponents });\n }\n return acc;\n }, {});\n if (!manifests[rootDir]) {\n manifests[rootDir] = workspaceManifest.toJson({\n copyPeerToRuntime: copyPeerToRuntimeOnRoot,\n installPeersFromEnvs,\n resolveEnvPeersFromRoot,\n });\n }\n return { manifests, peerOverrides: workspaceManifest.peerOverrides };\n }\n\n private async cleanCompsNodeModules(componentDirectoryMap: ComponentMap<string>) {\n const promises = componentDirectoryMap.toArray().map(([, dir]) => {\n const nmDir = path.join(dir, 'node_modules');\n return fs.remove(nmDir);\n });\n return Promise.all(promises);\n }\n\n private async runPrePostSubscribers(\n subscribers: PreInstallSubscriberList | PostInstallSubscriberList = [],\n type: 'pre' | 'post',\n args: InstallArgs\n ): Promise<void> {\n const message = this.installingContext?.inCapsule\n ? `(capsule) running ${type} install subscribers in root dir ${this.rootDir}`\n : `running ${type} install subscribers`;\n if (!this.installingContext?.inCapsule) {\n this.logger.setStatusLine(message);\n }\n await mapSeries(subscribers, async (subscriber) => {\n return subscriber(this, args);\n });\n if (!this.installingContext?.inCapsule) {\n this.logger.consoleSuccess(message);\n }\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,WAAA,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,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,SAAA;EAAA,MAAAJ,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAE,QAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAOA,SAAAK,YAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,WAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA2E,SAAAC,uB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,WAAW,EAAE,MAAOG,UAAU,IAAK;MACjD,OAAOA,UAAU,CAAC,IAAI,EAAEpF,IAAI,CAAC;IAC/B,CAAC,CAAC;IACF,IAAI,CAAC,IAAI,CAACf,iBAAiB,EAAE0C,SAAS,EAAE;MACtC,IAAI,CAAC5D,MAAM,CAACoF,cAAc,CAACL,OAAO,CAAC;IACrC;EACF;AACF;AAACuC,OAAA,CAAA1H,mBAAA,GAAAA,mBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_pMapSeries","data","_interopRequireDefault","require","_path","_fsExtra","_exceptions","_hoistedResolutionBridge","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_PM_INSTALL_OPTIONS","dedupe","copyPeerToRuntimeOnRoot","copyPeerToRuntimeOnComponents","installPeersFromEnvs","DEFAULT_INSTALL_OPTIONS","installTeambitBit","excludeExtensionsDependencies","DependencyInstaller","constructor","packageManager","aspectLoader","logger","dependencyResolver","rootDir","cacheRootDir","preInstallSubscriberList","postInstallSubscriberList","nodeLinker","packageImportMethod","sideEffectsCache","nodeVersion","engineStrict","peerDependencyRules","neverBuiltDependencies","allowScripts","dangerouslyAllowAllScripts","preferOffline","minimumReleaseAge","minimumReleaseAgeExclude","patchedDependencies","packageExtensions","installingContext","withBuiltInPackageExtensions","fromConfig","enableGlobalVirtualStore","react","dependencies","builtIn","resolvePatchPaths","installRootDir","packageManagerConfigRootDir","undefined","fromEntries","entries","map","selector","patchPath","path","isAbsolute","join","assertSafeVirtualStoreTransition","finalRootDir","modulesDir","modulesManifest","fs","readFile","virtualStoreDir","parseRecordedVirtualStoreDir","workspaceRealpath","realpath","catch","resolvedStoreDir","resolve","storeRealpath","currentIsGlobal","isPathInsideOrEqual","runningFrom","__dirname","selfHosted","SelfHostedVirtualStoreTransition","install","rootPolicy","componentDirectoryMap","options","packageManagerOptions","RootDirNotDefined","manifests","getComponentManifests","resolveVersionsFromDependenciesOnly","referenceLocalPackages","rootComponentsForCapsules","includeAllEnvPeers","installComponents","args","runPrePostSubscribers","mainAspect","inCapsule","linkedDependencies","JSON","parse","stringify","forcedHarmonyVersion","directDeps","Set","values","manifest","depName","devDependencies","add","name","has","dir","linkedDeps","isJsonCmd","process","argv","includes","hidePackageManagerOutput","Boolean","env","VERBOSE_PM_OUTPUT","calculatedPmOpts","globalVirtualStoreDir","getGlobalVirtualStoreDir","dedupeInjectedDeps","dependenciesGraph","version","packageName","MainAspectNotInstallable","dependencyId","lifecycleType","rootComponents","keepExistingModulesDir","cleanCompsNodeModules","err","debug","messagePrefix","messageSuffix","message","setStatusLine","startTime","hrtime","installResult","consoleSuccess","pruneModules","dependencyFilterFn","resolveEnvPeersFromRoot","hasRootComponents","filterComponentsFromManifests","createManifestForComponentsWithoutDependencies","workspaceManifest","getWorkspaceManifest","components","toArray","reduce","acc","component","getPackageName","componentsManifestsMap","get","toJson","copyPeerToRuntime","peerOverrides","promises","nmDir","remove","Promise","all","subscribers","type","mapSeries","subscriber","exports"],"sources":["dependency-installer.ts"],"sourcesContent":["import mapSeries from 'p-map-series';\nimport path from 'path';\nimport fs from 'fs-extra';\nimport type { MainAspect, AspectLoaderMain } from '@teambit/aspect-loader';\nimport type { ComponentMap } from '@teambit/component';\nimport { type DependenciesGraph } from '@teambit/objects';\nimport type { Logger } from '@teambit/logger';\nimport type { PathAbsolute } from '@teambit/toolbox.path.path';\nimport type { PeerDependencyRules, ProjectManifest } from '@pnpm/types';\nimport { MainAspectNotInstallable, RootDirNotDefined, SelfHostedVirtualStoreTransition } from './exceptions';\nimport { isPathInsideOrEqual, parseRecordedVirtualStoreDir } from './hoisted-resolution-bridge';\nimport type {\n PackageManager,\n PackageManagerInstallOptions,\n PackageImportMethod,\n PackageExtension,\n} from './package-manager';\nimport type { WorkspacePolicy } from './policy';\nimport type { CreateFromComponentsOptions } from './manifest';\nimport type { DependencyResolverMain } from './dependency-resolver.main.runtime';\n\nconst DEFAULT_PM_INSTALL_OPTIONS: PackageManagerInstallOptions = {\n dedupe: true,\n copyPeerToRuntimeOnRoot: true,\n copyPeerToRuntimeOnComponents: false,\n installPeersFromEnvs: false,\n};\n\nconst DEFAULT_INSTALL_OPTIONS: InstallOptions = {\n installTeambitBit: false,\n excludeExtensionsDependencies: false,\n};\n\nexport type DepInstallerContext = {\n inCapsule?: boolean;\n};\n\nexport type InstallArgs = {\n rootDir: string | undefined;\n rootPolicy: WorkspacePolicy;\n componentDirectoryMap: ComponentMap<string>;\n options: InstallOptions;\n packageManagerOptions: PackageManagerInstallOptions;\n};\n\nexport type InstallOptions = {\n installTeambitBit: boolean;\n packageManagerConfigRootDir?: string;\n resolveVersionsFromDependenciesOnly?: boolean;\n linkedDependencies?: Record<string, Record<string, string>>;\n forcedHarmonyVersion?: string;\n excludeExtensionsDependencies?: boolean;\n dedupeInjectedDeps?: boolean;\n dependenciesGraph?: DependenciesGraph;\n};\n\nexport type GetComponentManifestsOptions = {\n componentDirectoryMap: ComponentMap<string>;\n rootPolicy: WorkspacePolicy;\n rootDir: string;\n resolveVersionsFromDependenciesOnly?: boolean;\n referenceLocalPackages?: boolean;\n includeAllEnvPeers?: boolean;\n hasRootComponents?: boolean;\n excludeExtensionsDependencies?: boolean;\n} & Pick<\n PackageManagerInstallOptions,\n | 'dedupe'\n | 'dependencyFilterFn'\n | 'copyPeerToRuntimeOnComponents'\n | 'copyPeerToRuntimeOnRoot'\n | 'installPeersFromEnvs'\n | 'resolveEnvPeersFromRoot'\n>;\n\nexport type PreInstallSubscriber = (installer: DependencyInstaller, installArgs: InstallArgs) => Promise<void>;\nexport type PreInstallSubscriberList = Array<PreInstallSubscriber>;\n\nexport type PostInstallSubscriber = (installer: DependencyInstaller, installArgs: InstallArgs) => Promise<void>;\nexport type PostInstallSubscriberList = Array<PostInstallSubscriber>;\n\nexport class DependencyInstaller {\n constructor(\n /**\n * package manager instance.\n */\n private packageManager: PackageManager,\n\n private aspectLoader: AspectLoaderMain,\n\n private logger: Logger,\n\n private dependencyResolver: DependencyResolverMain,\n\n private rootDir?: string | PathAbsolute,\n\n private cacheRootDir?: string | PathAbsolute,\n\n private preInstallSubscriberList?: PreInstallSubscriberList,\n\n private postInstallSubscriberList?: PostInstallSubscriberList,\n\n private nodeLinker?: 'hoisted' | 'isolated',\n\n private packageImportMethod?: PackageImportMethod,\n\n private sideEffectsCache?: boolean,\n\n private nodeVersion?: string,\n\n private engineStrict?: boolean,\n\n private peerDependencyRules?: PeerDependencyRules,\n\n private neverBuiltDependencies?: string[],\n\n private allowScripts?: Record<string, boolean | 'warn'>,\n\n private dangerouslyAllowAllScripts?: boolean,\n\n private preferOffline?: boolean,\n\n private minimumReleaseAge?: number,\n\n private minimumReleaseAgeExclude?: string[],\n\n private patchedDependencies?: Record<string, string>,\n\n private packageExtensions?: Record<string, PackageExtension>,\n\n private installingContext: DepInstallerContext = {}\n ) {}\n\n /**\n * `packageExtensions` bit ships for published envs whose `tsconfig.json` `extends` a package\n * they never declare, merged under the workspace's own `packageExtensions` so a user entry for\n * the same package always wins.\n *\n * Only applied under the global virtual store. TypeScript resolves `extends` with its own\n * resolver, walking up from the tsconfig's real location: under the project-local layout that\n * walk passes pnpm's privately hoisted `node_modules/.pnpm/node_modules`, which catches any\n * phantom dependency, so these envs work by accident. A global-store slot walks up into the\n * store and finds nothing. Declaring the missing dependency via `packageExtensions` - pnpm's\n * documented remedy for exactly this - places the real package inside the slot's\n * `node_modules`, where the tsconfig resolver finds it.\n *\n * An extension merges *underneath* the manifest (it only adds entries the package lacks), an\n * entry whose package never installs is not an error (unlike `patchedDependencies`), and a\n * `name@range` key scopes an entry to the versions that need it. None of these envs import\n * their extends-target at runtime - the reference lives only in config files - so the added\n * registry copy cannot shadow the host-provided core-aspect singletons.\n *\n * The list covers teambit's own published envs known to carry the phantom `extends`\n * (react-env fixed it in 2.x by inlining, hence the `@1` scope). Third-party envs with the\n * same shape are covered by the user-level `packageExtensions` config this merges under.\n *\n * Both halves of every entry are version-scoped. The keys cover only the majors shipped and\n * verified to carry the phantom - a future major of an env must be re-verified before its\n * range moves, rather than inheriting the workaround (and its injected dependency edge)\n * automatically. The added dependencies are caret-pinned to the major whose file layout the\n * extension exists for - a floating `*` would follow a future major that may not keep\n * `typescript/tsconfig.json` (or the rspack env's `config/`) where the extending tsconfigs\n * point, and would drift across installs.\n */\n private withBuiltInPackageExtensions(\n fromConfig: Record<string, PackageExtension> | undefined,\n enableGlobalVirtualStore: boolean\n ): Record<string, PackageExtension> | undefined {\n if (!enableGlobalVirtualStore) return fromConfig;\n const react = { dependencies: { '@teambit/react': '^1.0.0' } };\n const builtIn: Record<string, PackageExtension> = {\n '@teambit/node.envs.node-babel-mocha@<3': react,\n '@teambit/node.envs.node-typescript-mocha@<3': react,\n '@teambit/react.internal.base-react-env@1': react,\n '@teambit/rspack.envs.react-env@<2': react,\n '@teambit/react.react-env@1': react,\n '@teambit/cloud.envs.cloud-react@0': {\n dependencies: { '@teambit/rspack.envs.react-env': '^1.0.0' },\n },\n };\n return { ...builtIn, ...fromConfig };\n }\n\n /**\n * Patch paths are configured relative to the workspace root, but pnpm resolves a relative one\n * from the directory it is installing in. Those coincide for a workspace install and do not for\n * a capsule install, which runs in the capsules directory - the patch would be looked for\n * under the capsule root and the install would fail on the missing file.\n *\n * So capsule installs get absolute paths, resolved against the workspace root the caller passes\n * as the package manager config root. Workspace installs keep the configured spelling: pnpm\n * records it in the lockfile, and an absolute path there would be machine-specific.\n */\n private resolvePatchPaths(\n installRootDir: string,\n packageManagerConfigRootDir?: string\n ): Record<string, string> | undefined {\n if (!this.patchedDependencies) return undefined;\n if (!packageManagerConfigRootDir || packageManagerConfigRootDir === installRootDir) {\n return this.patchedDependencies;\n }\n return Object.fromEntries(\n Object.entries(this.patchedDependencies).map(([selector, patchPath]) => [\n selector,\n path.isAbsolute(patchPath) ? patchPath : path.join(packageManagerConfigRootDir, patchPath),\n ])\n );\n }\n\n /**\n * Refuse an install that would switch this workspace between the project-local and the global\n * virtual store while the running bit is installed inside this workspace's `node_modules`.\n *\n * Both layouts are safe in steady state: repeat installs preserve the top-level package\n * directories the running process resolves from, and the end-of-install compile refreshes the\n * per-variant copies (`.pnpm` entries or store slots). A layout *switch* is different - it\n * relocates every injected component package, rebuilding the top-level directories from\n * source, so their compiled `dist` disappears mid-install. A bit running from those very\n * directories loses its own code before it can reach the compile step that would restore it,\n * and dies leaving `node_modules` unusable. The transition has to run once from a bit\n * installation outside the workspace; detect the combination up front and fail before\n * anything is rewritten.\n *\n * The current layout is read off `node_modules/.modules.yaml`: pnpm records `virtualStoreDir`\n * as `.pnpm` for the project-local layout and as a path escaping the workspace for the global\n * one. No manifest (fresh install) or an unreadable one means nothing can be mid-flight -\n * a fresh install writes whichever layout is requested.\n */\n private async assertSafeVirtualStoreTransition(finalRootDir: string, enableGlobalVirtualStore: boolean) {\n const modulesDir = path.join(finalRootDir, 'node_modules');\n let modulesManifest: string;\n try {\n modulesManifest = await fs.readFile(path.join(modulesDir, '.modules.yaml'), 'utf8');\n } catch {\n return;\n }\n // same reader as the bootstrap-time layout gate, so the guard and the bridge can never\n // disagree about which layout the workspace is currently on\n const virtualStoreDir = parseRecordedVirtualStoreDir(modulesManifest);\n if (!virtualStoreDir) return;\n // compare real paths on both sides: resolving the recorded dir against the as-given (possibly\n // symlinked) workspace spelling while comparing to the workspace's realpath would misread a\n // project-local store as global for a workspace reached through a symlink\n const workspaceRealpath = await fs.realpath(finalRootDir).catch(() => finalRootDir);\n const resolvedStoreDir = path.resolve(workspaceRealpath, 'node_modules', virtualStoreDir);\n const storeRealpath = await fs.realpath(resolvedStoreDir).catch(() => resolvedStoreDir);\n const currentIsGlobal = !isPathInsideOrEqual(storeRealpath, workspaceRealpath);\n if (currentIsGlobal === enableGlobalVirtualStore) return;\n\n // the switch only endangers a bit whose own code lives inside the node_modules being\n // rewritten. `__dirname` sits in the running installation's copy of this component; injected\n // workspace packages are real directories, so a workspace-provided bit resolves under the\n // workspace realpath while bvm/global installations resolve elsewhere.\n const runningFrom = await fs.realpath(__dirname).catch(() => __dirname);\n const selfHosted = isPathInsideOrEqual(runningFrom, path.join(workspaceRealpath, 'node_modules'));\n if (!selfHosted) return;\n throw new SelfHostedVirtualStoreTransition(finalRootDir, enableGlobalVirtualStore);\n }\n\n async install(\n rootDir: string | undefined,\n rootPolicy: WorkspacePolicy,\n componentDirectoryMap: ComponentMap<string>,\n options: InstallOptions = DEFAULT_INSTALL_OPTIONS,\n packageManagerOptions: PackageManagerInstallOptions = DEFAULT_PM_INSTALL_OPTIONS\n ) {\n const finalRootDir = rootDir ?? this.rootDir;\n if (!finalRootDir) {\n throw new RootDirNotDefined();\n }\n const { manifests } = await this.getComponentManifests({\n ...packageManagerOptions,\n componentDirectoryMap,\n rootPolicy,\n rootDir: finalRootDir,\n resolveVersionsFromDependenciesOnly: options.resolveVersionsFromDependenciesOnly,\n referenceLocalPackages: packageManagerOptions.rootComponentsForCapsules,\n includeAllEnvPeers: packageManagerOptions.rootComponentsForCapsules,\n excludeExtensionsDependencies: options.excludeExtensionsDependencies,\n });\n return this.installComponents(\n finalRootDir,\n manifests,\n rootPolicy,\n componentDirectoryMap,\n options,\n packageManagerOptions\n );\n }\n\n async installComponents(\n rootDir: string | undefined,\n manifests: Record<string, ProjectManifest>,\n rootPolicy: WorkspacePolicy,\n componentDirectoryMap: ComponentMap<string>,\n options: InstallOptions = DEFAULT_INSTALL_OPTIONS,\n packageManagerOptions: PackageManagerInstallOptions = DEFAULT_PM_INSTALL_OPTIONS\n ): Promise<{ dependenciesChanged: boolean }> {\n const args = {\n componentDirectoryMap,\n options,\n packageManagerOptions,\n rootDir,\n rootPolicy,\n };\n await this.runPrePostSubscribers(this.preInstallSubscriberList, 'pre', args);\n const mainAspect: MainAspect = this.aspectLoader.mainAspect;\n const finalRootDir = rootDir || this.rootDir;\n if (!finalRootDir) {\n throw new RootDirNotDefined();\n }\n // guard here rather than in `install()`: workspace installs enter through this method\n // directly (InstallMain._installModules), so `install()` is not a choke point.\n if (!this.installingContext?.inCapsule) {\n await this.assertSafeVirtualStoreTransition(\n finalRootDir,\n this.dependencyResolver.enableGlobalVirtualStore()\n );\n }\n if (options.linkedDependencies) {\n manifests = JSON.parse(JSON.stringify(manifests));\n const linkedDependencies = JSON.parse(\n JSON.stringify(options.linkedDependencies)\n ) as typeof options.linkedDependencies;\n if (linkedDependencies[finalRootDir]) {\n if (options.forcedHarmonyVersion == null && manifests[finalRootDir].dependencies?.['@teambit/harmony']) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n delete manifests[finalRootDir].dependencies!['@teambit/harmony'];\n }\n const directDeps = new Set<string>();\n Object.values(manifests).forEach((manifest) => {\n for (const depName of Object.keys({ ...manifest.dependencies, ...manifest.devDependencies })) {\n directDeps.add(depName);\n }\n });\n for (const manifest of Object.values(manifests)) {\n if (manifest.name && directDeps.has(manifest.name)) {\n delete linkedDependencies[finalRootDir][manifest.name];\n }\n }\n }\n Object.entries(linkedDependencies).forEach(([dir, linkedDeps]) => {\n if (!manifests[dir]) {\n manifests[dir] = {};\n }\n manifests[dir].dependencies = {\n ...linkedDeps,\n ...manifests[dir].dependencies,\n };\n });\n }\n const isJsonCmd = process.argv.includes('--json') || process.argv.includes('-j');\n const hidePackageManagerOutput =\n Boolean(this.installingContext.inCapsule && process.env.VERBOSE_PM_OUTPUT !== 'true') || isJsonCmd;\n\n // Make sure to take other default if passed options with only one option\n const calculatedPmOpts = {\n ...DEFAULT_PM_INSTALL_OPTIONS,\n cacheRootDir: this.cacheRootDir,\n nodeLinker: this.nodeLinker,\n packageImportMethod: this.packageImportMethod,\n // Capsules stay on the project-local virtual store even when the global one is enabled.\n // A capsule is a self-contained build sandbox, and TypeScript's declaration emit relies on\n // that: it names the type of an inferred value (`compiler()` returning a `@teambit/compiler`\n // type, say) through the package that declares it, and can only do so while that package\n // sits inside the capsule. Moving env and aspect packages out to the shared store makes\n // `bit build` of any custom env fail with TS2742 (\"cannot be named without a reference to\n // ../../../node_modules/@teambit/compiler\"). Workspace installs - the ones a user actually\n // waits on repeatedly - still get the global store.\n enableGlobalVirtualStore:\n !this.installingContext?.inCapsule && this.dependencyResolver.enableGlobalVirtualStore(),\n globalVirtualStoreDir: this.installingContext?.inCapsule\n ? undefined\n : await this.dependencyResolver.getGlobalVirtualStoreDir(finalRootDir),\n patchedDependencies: this.resolvePatchPaths(finalRootDir, options.packageManagerConfigRootDir),\n packageExtensions: this.withBuiltInPackageExtensions(\n this.packageExtensions,\n !this.installingContext?.inCapsule && this.dependencyResolver.enableGlobalVirtualStore()\n ),\n minimumReleaseAge: this.minimumReleaseAge,\n minimumReleaseAgeExclude: this.minimumReleaseAgeExclude,\n sideEffectsCache: this.sideEffectsCache,\n nodeVersion: this.nodeVersion,\n engineStrict: this.engineStrict,\n packageManagerConfigRootDir: options.packageManagerConfigRootDir,\n peerDependencyRules: this.peerDependencyRules,\n hidePackageManagerOutput,\n neverBuiltDependencies: this.neverBuiltDependencies,\n allowScripts: this.allowScripts,\n dangerouslyAllowAllScripts: this.dangerouslyAllowAllScripts,\n preferOffline: this.preferOffline,\n dedupeInjectedDeps: options.dedupeInjectedDeps,\n dependenciesGraph: options.dependenciesGraph,\n forcedHarmonyVersion: options.forcedHarmonyVersion,\n ...packageManagerOptions,\n };\n if (this.installingContext?.inCapsule) {\n // the capsule invariant is non-negotiable: caller-provided packageManagerOptions spread\n // last for every other option's sake, but must not move a capsule onto the global store\n // (see the comment above on TypeScript's declaration emit)\n calculatedPmOpts.enableGlobalVirtualStore = false;\n calculatedPmOpts.globalVirtualStoreDir = undefined;\n }\n if (options.installTeambitBit) {\n if (!mainAspect.version || !mainAspect.packageName) {\n throw new MainAspectNotInstallable();\n }\n const version = mainAspect.version;\n rootPolicy.add({\n dependencyId: mainAspect.packageName,\n lifecycleType: 'runtime',\n value: {\n version,\n },\n });\n }\n\n if (!packageManagerOptions.rootComponents && !packageManagerOptions.keepExistingModulesDir) {\n try {\n // Remove node modules dir for all components dirs, since it might contain left overs from previous install.\n //\n // This is not needed when \"rootComponents\" are used, as in that case the package manager handles the node_modules\n // and it never leaves node_modules in a broken state.\n // Removing node_modules in that case would delete useful state information that is used by Yarn or pnpm.\n await this.cleanCompsNodeModules(componentDirectoryMap);\n } catch (err) {\n this.logger.debug('failed to remove node_modules directories from components', err);\n // A failure to remove the node_modules directory should not cause the process to fail\n }\n }\n\n const messagePrefix = 'running package installation';\n const messageSuffix = `using ${this.packageManager.name}`;\n const message = this.installingContext?.inCapsule\n ? `(capsule) ${messagePrefix} in root dir ${this.rootDir} ${messageSuffix}`\n : `${messagePrefix} ${messageSuffix}`;\n if (!hidePackageManagerOutput) {\n this.logger.setStatusLine(message);\n }\n const startTime = process.hrtime();\n\n // TODO: the cache should be probably passed to the package manager constructor not to the install function\n const installResult = await this.packageManager.install(\n {\n rootDir: finalRootDir,\n manifests,\n componentDirectoryMap,\n },\n calculatedPmOpts\n );\n if (!hidePackageManagerOutput) {\n this.logger.consoleSuccess(`done ${message}`, startTime);\n }\n await this.runPrePostSubscribers(this.postInstallSubscriberList, 'post', args);\n return installResult;\n }\n\n public async pruneModules(rootDir: string): Promise<void> {\n if (!this.packageManager.pruneModules) {\n return;\n }\n await this.packageManager.pruneModules(rootDir);\n }\n\n /**\n * Compute all the component manifests (a.k.a. package.json files) that should be passed to the package manager\n * in order to install the dependencies.\n */\n public async getComponentManifests({\n componentDirectoryMap,\n rootPolicy,\n rootDir,\n dedupe,\n dependencyFilterFn,\n copyPeerToRuntimeOnComponents,\n copyPeerToRuntimeOnRoot,\n installPeersFromEnvs,\n resolveEnvPeersFromRoot,\n resolveVersionsFromDependenciesOnly,\n referenceLocalPackages,\n includeAllEnvPeers,\n hasRootComponents,\n excludeExtensionsDependencies,\n }: GetComponentManifestsOptions): Promise<{\n manifests: Record<string, ProjectManifest>;\n peerOverrides: Record<string, string>;\n }> {\n const options: CreateFromComponentsOptions = {\n filterComponentsFromManifests: true,\n createManifestForComponentsWithoutDependencies: true,\n dedupe,\n dependencyFilterFn,\n resolveVersionsFromDependenciesOnly,\n referenceLocalPackages,\n includeAllEnvPeers,\n hasRootComponents,\n excludeExtensionsDependencies,\n };\n const workspaceManifest = await this.dependencyResolver.getWorkspaceManifest(\n undefined,\n undefined,\n rootPolicy,\n rootDir,\n componentDirectoryMap.components,\n options,\n this.installingContext\n );\n const manifests: Record<string, ProjectManifest> = componentDirectoryMap\n .toArray()\n .reduce((acc, [component, dir]) => {\n const packageName = this.dependencyResolver.getPackageName(component);\n const manifest = workspaceManifest.componentsManifestsMap.get(packageName);\n if (manifest) {\n acc[dir] = manifest.toJson({ copyPeerToRuntime: copyPeerToRuntimeOnComponents });\n }\n return acc;\n }, {});\n if (!manifests[rootDir]) {\n manifests[rootDir] = workspaceManifest.toJson({\n copyPeerToRuntime: copyPeerToRuntimeOnRoot,\n installPeersFromEnvs,\n resolveEnvPeersFromRoot,\n });\n }\n return { manifests, peerOverrides: workspaceManifest.peerOverrides };\n }\n\n private async cleanCompsNodeModules(componentDirectoryMap: ComponentMap<string>) {\n const promises = componentDirectoryMap.toArray().map(([, dir]) => {\n const nmDir = path.join(dir, 'node_modules');\n return fs.remove(nmDir);\n });\n return Promise.all(promises);\n }\n\n private async runPrePostSubscribers(\n subscribers: PreInstallSubscriberList | PostInstallSubscriberList = [],\n type: 'pre' | 'post',\n args: InstallArgs\n ): Promise<void> {\n const message = this.installingContext?.inCapsule\n ? `(capsule) running ${type} install subscribers in root dir ${this.rootDir}`\n : `running ${type} install subscribers`;\n if (!this.installingContext?.inCapsule) {\n this.logger.setStatusLine(message);\n }\n await mapSeries(subscribers, async (subscriber) => {\n return subscriber(this, args);\n });\n if (!this.installingContext?.inCapsule) {\n this.logger.consoleSuccess(message);\n }\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,YAAA;EAAA,MAAAC,IAAA,G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,GAAG3G,eAAI,CAACE,IAAI,CAACoD,GAAG,EAAE,cAAc,CAAC;MAC5C,OAAO/C,kBAAE,CAACqG,MAAM,CAACD,KAAK,CAAC;IACzB,CAAC,CAAC;IACF,OAAOE,OAAO,CAACC,GAAG,CAACJ,QAAQ,CAAC;EAC9B;EAEA,MAAcrE,qBAAqBA,CACjC0E,WAAiE,GAAG,EAAE,EACtEC,IAAoB,EACpB5E,IAAiB,EACF;IACf,MAAM6C,OAAO,GAAG,IAAI,CAACjG,iBAAiB,EAAEuD,SAAS,GAC7C,qBAAqByE,IAAI,oCAAoC,IAAI,CAAClJ,OAAO,EAAE,GAC3E,WAAWkJ,IAAI,sBAAsB;IACzC,IAAI,CAAC,IAAI,CAAChI,iBAAiB,EAAEuD,SAAS,EAAE;MACtC,IAAI,CAAC3E,MAAM,CAACsH,aAAa,CAACD,OAAO,CAAC;IACpC;IACA,MAAM,IAAAgC,qBAAS,EAACF,WAAW,EAAE,MAAOG,UAAU,IAAK;MACjD,OAAOA,UAAU,CAAC,IAAI,EAAE9E,IAAI,CAAC;IAC/B,CAAC,CAAC;IACF,IAAI,CAAC,IAAI,CAACpD,iBAAiB,EAAEuD,SAAS,EAAE;MACtC,IAAI,CAAC3E,MAAM,CAAC0H,cAAc,CAACL,OAAO,CAAC;IACrC;EACF;AACF;AAACkC,OAAA,CAAA3J,mBAAA,GAAAA,mBAAA","ignoreList":[]}
@@ -94,6 +94,29 @@ export declare class DependencyLinker {
94
94
  linkedRootDeps: Record<string, string>;
95
95
  linkResults: LinkResults;
96
96
  }>;
97
+ /**
98
+ * The core aspects are phantom dependencies of every published env and aspect - they are required
99
+ * without being declared, and the running bit installation provides them. Under the project-local
100
+ * virtual store that works because a package in `node_modules/.pnpm` resolves them by walking up
101
+ * into the workspace's root `node_modules`, where they are linked as root dependencies.
102
+ *
103
+ * A package in the global virtual store has no workspace to walk up into: it lives under
104
+ * `<storeDir>/links/<scope>/<name>/<version>/<hash>`, shared with every other project on the
105
+ * machine. pnpm's answer for exactly this case is the privately hoisted directory: it stays
106
+ * project-local at `<rootDir>/node_modules/.pnpm/node_modules` even under the global virtual
107
+ * store, and is put on the module resolution path via `NODE_PATH` and an ESM loader (see
108
+ * `ensureHoistedDependencyResolution` in the hoisted-resolution bridge, which does that for
109
+ * bit's own process and the ones it spawns).
110
+ *
111
+ * So the core aspects are linked there rather than mirrored into the store. Nothing is written
112
+ * inside the store itself, which is what lets bit use pnpm's shared `<storeDir>/links` instead of
113
+ * a root private to one bit installation - slots are then shared across bit versions and with
114
+ * every other pnpm project, and `pnpm store prune` can reason about them.
115
+ *
116
+ * Only the links that come from the bit installation go here - the workspace's own component
117
+ * links stay in the workspace's root `node_modules`.
118
+ */
119
+ private linkCoreAspectsToHoistedStore;
97
120
  private linkDetailToLocalDepEntry;
98
121
  private _calculateLinks;
99
122
  _getLinksToPeers(componentDirectoryMap: ComponentMap<string>, options: {
@@ -143,11 +143,71 @@ class DependencyLinker {
143
143
  localLinks.push(this.linkDetailToLocalDepEntry(link.linksDetail));
144
144
  });
145
145
  }
146
+ await this.linkCoreAspectsToHoistedStore(rootDir, linkResults);
146
147
  return {
147
148
  linkedRootDeps: Object.fromEntries(localLinks.map(([key, value]) => [key, `link:${value}`])),
148
149
  linkResults
149
150
  };
150
151
  }
152
+
153
+ /**
154
+ * The core aspects are phantom dependencies of every published env and aspect - they are required
155
+ * without being declared, and the running bit installation provides them. Under the project-local
156
+ * virtual store that works because a package in `node_modules/.pnpm` resolves them by walking up
157
+ * into the workspace's root `node_modules`, where they are linked as root dependencies.
158
+ *
159
+ * A package in the global virtual store has no workspace to walk up into: it lives under
160
+ * `<storeDir>/links/<scope>/<name>/<version>/<hash>`, shared with every other project on the
161
+ * machine. pnpm's answer for exactly this case is the privately hoisted directory: it stays
162
+ * project-local at `<rootDir>/node_modules/.pnpm/node_modules` even under the global virtual
163
+ * store, and is put on the module resolution path via `NODE_PATH` and an ESM loader (see
164
+ * `ensureHoistedDependencyResolution` in the hoisted-resolution bridge, which does that for
165
+ * bit's own process and the ones it spawns).
166
+ *
167
+ * So the core aspects are linked there rather than mirrored into the store. Nothing is written
168
+ * inside the store itself, which is what lets bit use pnpm's shared `<storeDir>/links` instead of
169
+ * a root private to one bit installation - slots are then shared across bit versions and with
170
+ * every other pnpm project, and `pnpm store prune` can reason about them.
171
+ *
172
+ * Only the links that come from the bit installation go here - the workspace's own component
173
+ * links stay in the workspace's root `node_modules`.
174
+ */
175
+ async linkCoreAspectsToHoistedStore(rootDir, linkResults) {
176
+ // capsules stay on the project-local virtual store (see the installer's capsule invariant),
177
+ // where packages reach the core aspects by walking up to the capsule root - the hoisted-store
178
+ // bridge is a global-virtual-store mechanism and must not write into capsule layouts
179
+ if (this.linkingContext?.inCapsule) return;
180
+ const finalRootDir = rootDir ?? this.rootDir;
181
+ if (!finalRootDir) return;
182
+ if (!(await this.dependencyResolver.getGlobalVirtualStoreDir(finalRootDir))) return;
183
+ const links = {};
184
+ const addLink = linkDetail => {
185
+ if (!linkDetail) return;
186
+ const [packageName, from] = this.linkDetailToLocalDepEntry(linkDetail);
187
+ links[packageName] = `link:${from}`;
188
+ };
189
+ addLink(linkResults.teambitBitLink?.linkDetail);
190
+ linkResults.coreAspectsLinks?.forEach(link => addLink(link.linkDetail));
191
+ addLink(linkResults.harmonyLink);
192
+ addLink(linkResults.teambitLegacyLink);
193
+ if (!Object.keys(links).length) return;
194
+ const hoistedStoreDir = _path().default.join(finalRootDir.toString(), 'node_modules', '.pnpm');
195
+ // same rule as syncCoreAspectLinksForEnvs: bridge the virtual store pnpm materialized, never
196
+ // fabricate one (a lockfile-only install leaves it missing on purpose)
197
+ if (!_fsExtra().default.pathExistsSync(hoistedStoreDir)) return;
198
+ try {
199
+ await (0, _dependenciesFs().createLinks)(hoistedStoreDir, links, {
200
+ skipIfSymlinkValid: true
201
+ });
202
+ } catch (err) {
203
+ // fail loudly: under the global virtual store these links are what lets every package in a
204
+ // store slot resolve the undeclared core aspects. A workspace missing them is broken in
205
+ // ways that only surface later as obscure "Cannot find module '@teambit/...'" failures far
206
+ // from the cause - unlike syncCoreAspectLinksForEnvs' bootstrap bridge, which the install
207
+ // flow genuinely tolerates losing.
208
+ throw new (_bitError().BitError)(`failed linking the core aspects into the hoisted store at ${hoistedStoreDir}, which packages ` + `in the global virtual store rely on to resolve them: ${err.message}`);
209
+ }
210
+ }
151
211
  linkDetailToLocalDepEntry(linkDetail) {
152
212
  return [linkDetail.packageName, linkDetail.from];
153
213
  }
@@ -510,16 +570,34 @@ class DependencyLinker {
510
570
  return idsInWorkspace.some(id => id === name || id === aspectId);
511
571
  });
512
572
  if (!authoredCoreAspects.length) return;
573
+
574
+ // The privately hoisted directory is where the non-authored core aspects go too (see
575
+ // `linkCoreAspectsToHoistedStore`). It stays project-local under the global virtual store, and
576
+ // is reached from a store slot via `NODE_PATH` rather than by walking up.
513
577
  const hoistedStoreDir = _path().default.join(rootDir, 'node_modules', '.pnpm');
514
- // the hoisted store only exists in a pnpm-managed workspace. anywhere else this directory is on
515
- // no resolution path, so there is nothing to bridge - and it must not be fabricated here.
578
+ const underGlobalVirtualStore = Boolean(await this.dependencyResolver.getGlobalVirtualStoreDir(rootDir));
579
+ // the hoisted store only exists in a pnpm-managed workspace whose node_modules was actually
580
+ // materialized - anywhere else (a non-pnpm workspace, a lockfile-only install) the directory
581
+ // is on no resolution path, so there is nothing to bridge and it must not be fabricated here.
582
+ // every real install materializes it under both layouts, and both call sites run after the
583
+ // package manager has finished.
516
584
  if (!_fsExtra().default.pathExistsSync(hoistedStoreDir)) return;
517
585
  const links = {};
518
586
  for (const aspectId of authoredCoreAspects) {
519
587
  const packageName = (0, _aspectLoader().getCoreAspectPackageName)(aspectId);
520
588
  const linkPath = _path().default.join(hoistedStoreDir, 'node_modules', packageName);
521
- if (this.hasCompiledMain(_path().default.join(rootDir, 'node_modules', packageName))) {
522
- await this.removeCoreAspectBootstrapLink(linkPath, rootDir);
589
+ const workspacePkgDir = _path().default.join(rootDir, 'node_modules', packageName);
590
+ if (this.hasCompiledMain(workspacePkgDir)) {
591
+ // Once the source component is compiled, the workspace's own copy is the one to use. Under
592
+ // the project-local layout the published packages reach it by walking up out of
593
+ // `node_modules/.pnpm`, so the bootstrap bridge is removed as soon as it is redundant.
594
+ // From the global virtual store there is no walking up into the workspace, so the bridge
595
+ // stays - repointed at the compiled workspace copy rather than at the raw source.
596
+ if (!underGlobalVirtualStore) {
597
+ await this.removeCoreAspectBootstrapLink(linkPath, rootDir);
598
+ continue;
599
+ }
600
+ links[packageName] = `link:${workspacePkgDir}`;
523
601
  continue;
524
602
  }
525
603
  const fromDir = this._getCoreAspectSourceDir(aspectId, packageName, rootDir);