Skip to content

feat(workspace): trackAllFiles flag to track package.json and other bit-generated files - #10702

Merged
davidfirst merged 1 commit into
feat/workspace-root-component-nestingfrom
feat/track-all-files-flag
Sep 11, 2026
Merged

davidfirst merged 1 commit into
feat/workspace-root-component-nestingfrom
feat/track-all-files-flag

Conversation

@davidfirst

Copy link
Copy Markdown
Member

Stacked on #10698.

Bit drops package.json, a root-level tsconfig.json and lint configs, and the npm/yarn lockfiles from every component because it generates them. A workspace adopted from an existing monorepo owns those files, and without them a workspace restored from its scope can be neither installed nor built.

"trackAllFiles": true under teambit.workspace/workspace keeps them: only the git-ignored files and the hard exclusions (node_modules, .env, .DS_Store, and the root component's .bit/.git) are left out. The flag rides the same path as ignoredFiles down to the bit-map layer, so both bit add and the per-load rescan honor it.

Import writes whatever files the model holds, so a component with a tracked package.json imported into a workspace without the flag shows as modified until the flag is set there too.

Covered by a unit test for the ignore logic and one e2e for adopt → export → restore onto an empty workspace.

…t-generated files

bit drops package.json, a root-level tsconfig.json and lint configs, and the npm/yarn
lockfiles from every component because it generates them. a workspace adopted from an
existing monorepo owns those files, and without them a workspace restored from the scope
can be neither installed nor built. with "trackAllFiles": true in teambit.workspace/workspace,
only the git-ignored files and the hard exclusions (node_modules, .env, ...) are left out.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Add trackAllFiles support for monorepo-owned generated files

✨ Enhancement 🧪 Tests ⚙️ Configuration changes 🕐 20-40 Minutes

Grey Divider

AI Description

• Adds a workspace flag to retain Bit-generated manifests, configs, and lockfiles.
• Applies the tracking policy consistently during component addition and workspace rescans.
• Verifies adopted workspaces preserve required files across export and restoration.
Diagram

graph TD
  workspace_config["Workspace config"] -->|projects flag| legacy_config["Legacy config"] --> bit_add["Bit add"] --> ignore_policy["Ignore policy"] --> file_selection["File selection"] --> component_model["Component model"]
  legacy_config --> component_load["Component load"] --> ignore_policy
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Centralized file-tracking policy object
  • ➕ Avoids threading another positional boolean through bitmap and scanner APIs
  • ➕ Provides one place to distinguish Git rules, user rules, and Bit defaults
  • ➕ Scales better if additional tracking modes are introduced
  • ➖ Requires a broader refactor across legacy and Harmony boundaries
  • ➖ Adds abstraction for a single optional behavior
2. Separate Bit defaults from user ignore rules
  • ➕ Allows lockfile defaults to be disabled without removing identical user-authored Git ignores
  • ➕ Makes the promised precedence between hard exclusions and user rules explicit
  • ➖ Requires changes to the ignore-file reader or an additional source-aware merge step
  • ➖ Touches shared ignore infrastructure beyond this feature

Recommendation: Keep the workspace-level opt-in and shared add/rescan behavior because they are backward-compatible and match existing ignoredFiles propagation. Before merging, prefer source-aware separation of Bit-owned defaults from Git and user patterns so enabling trackAllFiles cannot accidentally override an explicit lockfile ignore; a full policy-object refactor can wait until more tracking modes exist.

Files changed (12) +164 / -20

Enhancement (5) +58 / -18
bit-map.tsPropagate trackAllFiles through bitmap loading +11/-3

Propagate trackAllFiles through bitmap loading

• Stores the workspace tracking option on BitMap and passes it into ignore construction and component-directory rescans. This ensures bitmap reloads retain files normally classified as generated.

components/legacy/bit-map/bit-map.ts

component-map.tsMake component file selection honor trackAllFiles +33/-11

Make component file selection honor trackAllFiles

• Extends component scanning and ignore-list helpers with the tracking option. When enabled, root configuration files and npm/yarn lockfiles are no longer treated as Bit-owned generated files.

components/legacy/bit-map/component-map.ts

consumer-component.tsApply trackAllFiles during component reloads +2/-1

Apply trackAllFiles during component reloads

• Passes the workspace option into directory-change tracking when component files are loaded. Per-load rescans therefore use the same policy as initial tracking.

components/legacy/consumer-component/consumer-component.ts

consumer.tsConfigure bitmap scans with trackAllFiles +6/-1

Configure bitmap scans with trackAllFiles

• Forwards the workspace option when loading the bitmap, enabling its file rescan path to apply the configured tracking behavior.

components/legacy/consumer/consumer.ts

add-components.tsHonor trackAllFiles during bit add +6/-2

Honor trackAllFiles during bit add

• Passes the workspace setting into ignore-list generation for both standard and resolved multi-component add paths. Newly added components can therefore retain manifests, root configs, and lockfiles.

scopes/component/tracker/add-components.ts

Refactor (1) +6 / -2
constants.tsSeparate lockfile exclusions from hard ignore constants +6/-2

Separate lockfile exclusions from hard ignore constants

• Introduces LOCKFILES_IGNORE_LIST and composes it into the existing default ignore list. The separate constant allows trackAllFiles to selectively retain npm and Yarn lockfiles.

components/legacy/constants/constants.ts

Tests (2) +85 / -0
component-map.spec.tsTest trackAllFiles ignore behavior +44/-0

Test trackAllFiles ignore behavior

• Adds unit coverage proving default behavior still excludes generated files and lockfiles. It also verifies the opt-in retains those files while preserving Git, user, and hard exclusions.

components/legacy/bit-map/component-map.spec.ts

add-harmony.e2e.tsCover adopted-workspace tracking and restoration +41/-0

Cover adopted-workspace tracking and restoration

• Adds end-to-end coverage for tracking component and workspace-root manifests with the flag enabled. The scenario exports and reimports the components to verify manifests and TypeScript configuration are restored from scope data.

e2e/harmony/add-harmony.e2e.ts

Documentation (1) +8 / -0
types.tsDeclare the trackAllFiles workspace option +8/-0

Declare the trackAllFiles workspace option

• Adds the optional setting to WorkspaceExtConfig and documents its behavior for monorepo-owned manifests, root configuration files, and lockfiles.

scopes/workspace/workspace/types.ts

Other (3) +7 / -0
legacy-workspace-config-interface.tsExpose trackAllFiles in legacy workspace configuration +1/-0

Expose trackAllFiles in legacy workspace configuration

• Adds the optional flag to the legacy workspace configuration contract so legacy consumers can access the Harmony setting.

components/legacy/consumer-config/legacy-workspace-config-interface.ts

workspace-config.tsProject trackAllFiles into legacy configuration +1/-0

Project trackAllFiles into legacy configuration

• Reads trackAllFiles from the workspace extension and includes it in the legacy configuration adapter used by consumer and bitmap code.

scopes/harmony/config/workspace-config.ts

workspace-jsonc-schema.jsonAdd trackAllFiles to the workspace schema +5/-0

Add trackAllFiles to the workspace schema

• Defines the workspace JSONC option as a boolean defaulting to false and documents the adopted-monorepo use case.

workspace-jsonc-schema.json

@davidfirst
davidfirst merged commit d2b6186 into feat/workspace-root-component-nesting Sep 11, 2026
9 of 11 checks passed
@davidfirst
davidfirst deleted the feat/track-all-files-flag branch September 11, 2026 16:05
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Explicitly ignored lockfiles get tracked 🐞 Bug ≡ Correctness
Description
getIgnoreListHarmony() filters lockfile patterns from the combined user and built-in ignore list
without preserving their source. When .gitignore or .bitignore contains **/package-lock.json
or **/yarn.lock, enabling trackAllFiles removes that user rule and includes the lockfile during
add and subsequent rescans.
Code

components/legacy/bit-map/component-map.ts[R502-503]

+  const ignoreList = trackAllFiles
+    ? fromIgnoreFiles.filter((pattern) => !LOCKFILES_IGNORE_LIST.includes(pattern))
Evidence
retrieveIgnoreList() returns user patterns followed by IGNORE_LIST, while
LOCKFILES_IGNORE_LIST is spread into that built-in list. The new exact-value filter runs over the
combined array, so it cannot distinguish and preserve an identical user rule; the resulting matcher
is used by both component scanning and add flows.

scopes/git/modules/ignore-file-reader/ignore.ts[28-32]
components/legacy/constants/constants.ts[263-276]
components/legacy/bit-map/component-map.ts[500-504]
components/legacy/bit-map/component-map.ts[481-487]
scopes/component/tracker/add-components.ts[119-129]
scopes/component/tracker/add-components.ts[546-553]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`retrieveIgnoreList()` combines user patterns with Bit's built-in patterns, after which `trackAllFiles` removes every occurrence matching `LOCKFILES_IGNORE_LIST`. This also removes an identical pattern explicitly supplied through `.gitignore` or `.bitignore`.

## Fix Focus Areas
- components/legacy/bit-map/component-map.ts[500-504]
- scopes/git/modules/ignore-file-reader/ignore.ts[28-32]

## Recommended Fix
Keep user ignore-file patterns separate from Bit's built-in ignore list, and remove lockfile patterns only from the built-in portion when `trackAllFiles` is enabled. Combine the unchanged user patterns with the filtered built-in patterns before appending `additionalPatterns`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
Review mode: ⚖️ Balanced: This is a cross-cutting behavioral change affecting file tracking, workspace configuration, BitMap loading, add/rescan paths, and import/restore behavior, so it warrants a complete single-pass review.

Grey Divider

Tip of the day
💡 Did you know, you can switch off images and animations for a plain-text comment

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment on lines +502 to +503
const ignoreList = trackAllFiles
? fromIgnoreFiles.filter((pattern) => !LOCKFILES_IGNORE_LIST.includes(pattern))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

1. Explicitly ignored lockfiles get tracked 🐞 Bug ≡ Correctness

getIgnoreListHarmony() filters lockfile patterns from the combined user and built-in ignore list
without preserving their source. When .gitignore or .bitignore contains **/package-lock.json
or **/yarn.lock, enabling trackAllFiles removes that user rule and includes the lockfile during
add and subsequent rescans.
Agent Prompt
## Issue description
`retrieveIgnoreList()` combines user patterns with Bit's built-in patterns, after which `trackAllFiles` removes every occurrence matching `LOCKFILES_IGNORE_LIST`. This also removes an identical pattern explicitly supplied through `.gitignore` or `.bitignore`.

## Fix Focus Areas
- components/legacy/bit-map/component-map.ts[500-504]
- scopes/git/modules/ignore-file-reader/ignore.ts[28-32]

## Recommended Fix
Keep user ignore-file patterns separate from Bit's built-in ignore list, and remove lockfile patterns only from the built-in portion when `trackAllFiles` is enabled. Combine the unchanged user patterns with the filtered built-in patterns before appending `additionalPatterns`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

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.

1 participant