Skip to content

extract --force does not invalidate the module-resolution cache — a tsconfig paths fix measures as a total no-op #3125

Closed

Description

@cbartens

Summary

graphify extract --force re-reads every source file but keeps the cached module-resolution results. After changing a tsconfig paths mapping, the rebuilt graph silently retains the old, unresolved edges — so a correct configuration fix measures as changing nothing at all.

Only deleting graphify-out/ picks the change up.

The docs describe --force as:

full re-scan and re-dispatch: skip the incremental manifest gate and semantic cache reads

which reads as covering exactly this case.

Impact

This cost me a wrong conclusion twice on the same repo, and nearly a reverted fix.

Working on a 22-workspace pnpm monorepo (see #462), I added a wildcard paths mapping so @app-gether-life/utils/* would resolve, then ran:

graphify extract . --code-only --force

apps/web → packages/utils import edges: 0. Identical to before the change. I concluded the mapping didn't work on this repo and was about to revert it.

Then, same config, no source edits:

rm -rf graphify-out
graphify extract . --code-only

apps/web → packages/utils: 98 edges, and graphify affected on a symbol in that package went from returning one file (its own sibling test) to naming its real consumers.

The only difference was the deleted cache.

The failure mode is the bad one: not an error, not a warning, just a plausible-looking graph built from stale resolutions. Anyone iterating on paths or on workspace layout to improve resolution will conclude their change had no effect.

Repro

# two-package workspace, consumer imports "@scope/pkg-a/helpers"
# start with NO paths mapping in apps/app-b/tsconfig.json
graphify extract . --code-only
graphify affected "sharedHelper()"        # no edge, as expected

# add the mapping:
#   "paths": { "@scope/pkg-a/*": ["../../packages/pkg-a/src/*"] }
graphify extract . --code-only --force
graphify affected "sharedHelper()"        # STILL no edge  <-- bug

rm -rf graphify-out
graphify extract . --code-only
graphify affected "sharedHelper()"        # edge appears

Expected

--force invalidates cached resolutions too, since a config change that alters resolution is precisely when someone reaches for --force.

Suggested fixes

Any of these would remove the trap:

  1. Have --force clear the resolution cache along with the manifest gate.
  2. Key the resolution cache on the resolved tsconfig (path + mtime, or a hash of the effective paths/baseUrl/moduleSuffixes), so it self-invalidates.
  3. Failing either, note it in --force's help text and suggest deleting graphify-out/ after config changes.

(2) seems best — it also covers extract without --force, which has the same staleness after a config edit.

Environment

  • graphify 0.9.50
  • Python 3.14.5, macOS arm64
  • TypeScript 6.0.3, pnpm workspace monorepo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions