fix(install): link bit's compiled core aspects into bit-roots instead of uncompiled source#10481
fix(install): link bit's compiled core aspects into bit-roots instead of uncompiled source#10481davidfirst wants to merge 2 commits into
Conversation
… of uncompiled source
|
Closing: empirically proven not to work. Tested by patching bvm's Root cause of the failure: Node resolves the env's symlink to its realpath in This is also why scope-aspects capsules work: the env's realpath is inside the capsule, so the walk-up finds the capsule's linked compiled core aspects. Superseded by the require-hook approach (#10479), which is location-independent and is verified to work: full install + compile of 313 components on the same reproduced fresh state. |
Problem
When a workspace loads envs from root node_modules (
resolveEnvsFromRoots: true), an env's constructor eagerlyrequires 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 asworkspace:*, i.e. the uncompiled source component, which has nodist/duringbit install(beforebit 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.relinkCoreAspectsInCapsuleDir→dependency-linker.linkCoreAspect, which resolves from Bit's install). The bit-roots path never did —getWorkspaceDepsOfBitRootsmaps every workspace component (including core aspects) toworkspace:*, andfilterOutCoreAspectsonly covers the root policy, not this path.Fix
Make bit-roots mirror capsules, entirely in the install/resolution layer:
_omitCoreAspectsstrips core-aspect packages from theworkspace:*deps injected into bit-roots.linkPkgsToRootComponents(no source hard-link)._linkCoreAspectsToBitRootslinks 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: truein 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 releasedbbitduringsetup_harmony, so it must land here first.