Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,20 @@ export default class NodeModuleLinker {
this.workspace.clearAllComponentsCache();
}

await linkPkgsToRootComponents(
{
rootComponentsPath: this.workspace.rootComponentsPath,
workspacePath,
},
this.components.map((comp) => componentIdToPackageName(comp.state._consumer))
);
// Only update `.bit_roots` when root components are actually in use. Otherwise
// we'd be hard-linking into a stale tree left over from a previous install where
// rootComponents was enabled — pnpm no longer manages that subtree, so its layout
// can be inconsistent and `mkdir` may throw ENOTDIR/ENOENT through a broken
// ancestor inside `.bit_roots/<env>/node_modules/...`.
if (this.workspace.hasRootComponents()) {
await linkPkgsToRootComponents(
{
rootComponentsPath: this.workspace.rootComponentsPath,
workspacePath,
},
this.components.map((comp) => componentIdToPackageName(comp.state._consumer))
);
}
Comment on lines +73 to +86
return linksResults;
}
async getLinks(): Promise<DataToPersist> {
Expand Down
9 changes: 9 additions & 0 deletions scopes/workspace/workspace/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,15 @@ export class Workspace implements ComponentFactory {
return path.join(baseDir, BIT_ROOTS_DIR);
}

/**
* Whether the workspace is configured to use root components — the per-env install
* layout written to `rootComponentsPath` (defaults to `node_modules/.bit_roots`,
* relocatable via `dependencyResolver.rootComponentsDirectory`).
*/
hasRootComponents(): boolean {
return this.dependencyResolver.hasRootComponents();
}

/** get the `node_modules` folder of this workspace */
private get modulesPath() {
return path.join(this.path, 'node_modules');
Expand Down