fix(harmony): load core aspects from bit's own install when workspace dist is missing#10479
Closed
davidfirst wants to merge 1 commit into
Closed
fix(harmony): load core aspects from bit's own install when workspace dist is missing#10479davidfirst wants to merge 1 commit into
davidfirst wants to merge 1 commit into
Conversation
Member
Author
|
Superseded by #10481, which fixes this in the install/resolution layer (link Bit's own compiled core aspects into bit-roots, mirroring what scope-aspects capsules already do) instead of adding a fallback to the shared require hook. The require-hook change shipped to every Bit user for a bit-dev-only bootstrap concern; the resolution-layer fix is a provable no-op for any workspace that doesn't author Bit's core aspects. |
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 can eagerlyrequire('@teambit/builder')(and@teambit/ui) at module-load time. In a workspace where the core aspects are source components — most notably the Bit repo itself — that require resolves to the workspace copy, whosedist/maindoesn't exist yet duringbit install(beforebit compile). Result:Cannot find module '.../@teambit/builder/dist/index.js'and the install crashes.This isn't specific to
core-aspect-env:node,node-babel-mocha,node-typescript-mocha, andbase-react-envall eagerly touch@teambit/builderthe same way.Fix
Add a last-resort fallback in
hook-require.ts: when a@teambit/*core-aspect package fails to load, re-resolve it from Bit's own installed context (which always ships compileddist) and load that. It only runs on the existing crash path, so the happy path — every normal user workspace where these are registry packages withdistpresent — is untouched.Why
Unblocks setting
resolveEnvsFromRoots: truein the Bit repo, which lets 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).