Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 8 additions & 0 deletions scopes/workspace/workspace/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,14 @@ export class Workspace implements ComponentFactory {
return path.join(baseDir, BIT_ROOTS_DIR);
}

/**
* Whether the workspace is configured to use root components (the `.bit_roots`
* per-env install layout under `node_modules`).
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — updated the JSDoc to mention the configurable location (745f572).

*/
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