Skip to content

Conversation

@GiladShoham
Copy link
Member

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.

Copilot AI review requested due to automatic review settings December 14, 2025 09:51
Copy link
Contributor

Copilot AI left a 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.

…in.runtime.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings December 14, 2025 10:18
Copy link
Contributor

Copilot AI left a 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)) {
Copy link

Copilot AI Dec 14, 2025

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.

Copilot uses AI. Check for mistakes.
Comment on lines +577 to +581
const rootComponentDirWithVersion = getRootComponentDir(rootComponentsRelativePath ?? '', envId);
const rootComponentDirWithoutVersion = getRootComponentDir(rootComponentsRelativePath ?? '', envIdWithoutVersion);
if (fs.pathExistsSync(rootComponentDirWithoutVersion)) {
return rootComponentDirWithoutVersion;
}
Copy link

Copilot AI Dec 14, 2025

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.

Suggested change
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);
Copilot uses AI. Check for mistakes.
@GiladShoham GiladShoham merged commit 90ef3cd into master Dec 14, 2025
18 checks passed
@GiladShoham GiladShoham deleted the fix/root-component-dir-version-fallback branch December 14, 2025 11:28
davidfirst added a commit that referenced this pull request Dec 23, 2025
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.
davidfirst added a commit that referenced this pull request Dec 24, 2025
…#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants