Skip to content

fix(install): link bit's compiled core aspects into bit-roots instead of uncompiled source#10481

Draft
davidfirst wants to merge 1 commit into
masterfrom
fix/link-core-aspects-in-bit-roots
Draft

fix(install): link bit's compiled core aspects into bit-roots instead of uncompiled source#10481
davidfirst wants to merge 1 commit into
masterfrom
fix/link-core-aspects-in-bit-roots

Conversation

@davidfirst

Copy link
Copy Markdown
Member

Problem

When a workspace loads envs from root node_modules (resolveEnvsFromRoots: true), an env's constructor eagerly requires Bit core aspects (@teambit/builder, @teambit/ui, @teambit/pkg, …). In a workspace that authors those core aspects — the Bit repo itself — the bit-roots install injects them as workspace:*, i.e. the uncompiled source component, which has no dist/ during bit install (before bit compile). Result: Cannot find module '.../@teambit/builder/dist/index.js' and the install crashes.

Scope-aspects capsules don't hit this: they link Bit's own compiled core aspects (IsolatorMain.relinkCoreAspectsInCapsuleDirdependency-linker.linkCoreAspect, which resolves from Bit's install). The bit-roots path never did — getWorkspaceDepsOfBitRoots maps every workspace component (including core aspects) to workspace:*, and filterOutCoreAspects only covers the root policy, not this path.

Fix

Make bit-roots mirror capsules, entirely in the install/resolution layer:

  1. _omitCoreAspects strips core-aspect packages from the workspace:* deps injected into bit-roots.
  2. Filter the same packages out of linkPkgsToRootComponents (no source hard-link).
  3. _linkCoreAspectsToBitRoots links Bit's own compiled core aspects into each bit-root, reusing the exact linker path capsules use.

Blast radius

All three key off coreAspectPackageNames ∩ workspaceComponents, which is empty for any workspace that doesn't author Bit's core aspects — i.e. every normal user workspace. So it's a provable no-op for users and only changes behavior in the Bit repo. No change to the shared require hook.

Why

Unblocks resolveEnvsFromRoots: true in the Bit repo (envs load from node_modules instead of stacking per-version scope-aspects capsules in the global cache). The flag flip is a follow-up, after this ships in a nightly — the crash occurs inside the released bbit during setup_harmony, so it must land here first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant