fix(install): link bit's compiled core aspects into bit-roots instead of uncompiled source#10481
Draft
davidfirst wants to merge 1 commit into
Draft
fix(install): link bit's compiled core aspects into bit-roots instead of uncompiled source#10481davidfirst wants to merge 1 commit into
davidfirst wants to merge 1 commit into
Conversation
… of uncompiled source
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.