-
Notifications
You must be signed in to change notification settings - Fork 946
fix(deps): fallback to unversioned env path for root component dir #10125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds fallback logic to handle environment component directories that may exist without a version suffix. When resolving the root component directory for an environment, the code now checks if an unversioned path exists first before falling back to the versioned path.
Key Changes
- Adds version removal logic to extract the environment ID without version
- Creates both versioned and unversioned root component directory paths
- Checks for the existence of the unversioned path first, using it as a fallback
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
scopes/dependencies/dependency-resolver/dependency-resolver.main.runtime.ts
Outdated
Show resolved
Hide resolved
…in.runtime.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return getRootComponentDir(rootComponentsRelativePath ?? '', envId); | ||
| const rootComponentDirWithVersion = getRootComponentDir(rootComponentsRelativePath ?? '', envId); | ||
| const rootComponentDirWithoutVersion = getRootComponentDir(rootComponentsRelativePath ?? '', envIdWithoutVersion); | ||
| if (fs.pathExistsSync(rootComponentDirWithoutVersion)) { |
Copilot
AI
Dec 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The synchronous filesystem check fs.pathExistsSync could impact performance when called frequently, especially during dependency graph calculation where getComponentDirInBitRoots is called for multiple components. Consider caching the result or using the async version fs.pathExists if this method can be made async, similar to how getRootComponentDirByRootId in install.main.runtime.ts avoids redundant checks by determining the correct path upfront based on workspace membership.
| const rootComponentDirWithVersion = getRootComponentDir(rootComponentsRelativePath ?? '', envId); | ||
| const rootComponentDirWithoutVersion = getRootComponentDir(rootComponentsRelativePath ?? '', envIdWithoutVersion); | ||
| if (fs.pathExistsSync(rootComponentDirWithoutVersion)) { | ||
| return rootComponentDirWithoutVersion; | ||
| } |
Copilot
AI
Dec 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fallback logic always computes both paths regardless of whether the first check succeeds. Computing rootComponentDirWithVersion on line 577 before checking if the unversioned path exists is wasteful when the unversioned path is present. Consider computing rootComponentDirWithVersion only when needed (i.e., when the unversioned path doesn't exist) to avoid unnecessary computation.
| const rootComponentDirWithVersion = getRootComponentDir(rootComponentsRelativePath ?? '', envId); | |
| const rootComponentDirWithoutVersion = getRootComponentDir(rootComponentsRelativePath ?? '', envIdWithoutVersion); | |
| if (fs.pathExistsSync(rootComponentDirWithoutVersion)) { | |
| return rootComponentDirWithoutVersion; | |
| } | |
| const rootComponentDirWithoutVersion = getRootComponentDir(rootComponentsRelativePath ?? '', envIdWithoutVersion); | |
| if (fs.pathExistsSync(rootComponentDirWithoutVersion)) { | |
| return rootComponentDirWithoutVersion; | |
| } | |
| const rootComponentDirWithVersion = getRootComponentDir(rootComponentsRelativePath ?? '', envId); |
Compilers using transpileComponent write directly to the filesystem with a single outputDir. After PR #10125 fixed the outputDir to use bit_roots for correct peer resolution, the compiled files were no longer available in node_modules/<pkg>. This fix copies all compiled files from the outputDir to all other dist directories (injected dirs) after transpileComponent completes, ensuring bundlers like esbuild have their output available in all required locations.
…#10136) Compilers using `transpileComponent` write directly to the filesystem with a single `outputDir`. After PR #10125 fixed the `outputDir` to use `bit_roots` for correct peer resolution, the compiled files were no longer available in `node_modules/<pkg>`. This fix copies all compiled files from the `outputDir` to all other dist directories (injected dirs) after `transpileComponent` completes, ensuring bundlers like esbuild have their output available in all required locations.
Add fallback logic to check for env's root component directory without version suffix. If the unversioned path exists, use it instead of the versioned path.