Skip to content

Conversation

@davidfirst
Copy link
Member

@davidfirst davidfirst commented Oct 16, 2025

Problem

bit install --add-missing-deps doesn't detect dependencies imported in environment-specific files like .vue files when the detector is inherited from a base env. This happens because of a cascading cache issue:

  1. Components are first loaded by the linker without loadSeedersAsAspects, so env detectors aren't available
  2. This initial load caches the component data (without proper dependency detection) across multiple cache layers
  3. Later when we try to load with seeders for --add-missing-deps, the cached data is used instead
  4. Cache keys don't include the loadSeedersAsAspects parameter, so there's no way to invalidate the bad cache

Solution

Always load components with loadSeedersAsAspects: true in the getComponentsDirectory method. This ensures env detectors are available from the first load, so all cached data contains correct dependency information.

Testing

Added e2e test that:

  • Creates a custom detector for .custom files
  • Creates base-env with the detector
  • Creates extended-env that inherits from base-env
  • Exports envs as packages to npm registry
  • Creates new workspace with component using extended-env
  • Verifies dependency detection works with --add-missing-deps

The test validates this change doesn't cause regressions while fixing the Vue env issue.

…ecific files

When using 'bit install --add-missing-deps', dependencies in environment-specific
files (like .vue files) were not being detected because components were loaded
without their environments (loadSeedersAsAspects: false).

This caused a cascading cache issue:
1. Components loaded without env → cached everywhere (workspace, consumer, deps data, parsed files)
2. Env-specific detectors (Vue, etc.) not available → dependencies not detected
3. Later loads couldn't fix it due to multiple cache layers

Solution: Always load components with loadSeedersAsAspects: true in getComponentsDirectory.
This ensures env detectors are available from the first load, and all caches contain
correct dependency data.

Note: This changes the behavior for ALL component loading in getComponentsDirectory.
Tests will validate if this causes any regressions.
Add e2e test that reproduces and validates the fix for an issue where
dependencies in files with custom extensions aren't detected when the
detector is inherited from a base env that's installed as a package.

Test setup:
- Creates a custom detector for .custom files
- Creates base-env with the detector
- Creates extended-env that inherits from base-env
- Exports envs as packages to npm registry
- Creates new workspace with component using extended-env
- Verifies lodash import in .custom file is detected

The test validates:
1. Bug exists: bit status shows missing lodash dependency
2. Fix works: bit install --add-missing-deps resolves the issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants