Skip to content

app: jest.config.js hardcodes a pnpm virtual-store hash for wouter; breaks on every React bump #523

Closed

Description

@bpowers

Problem

src/app/jest.config.js maps the ESM-only wouter package to its real source via moduleNameMapper, but does so by hardcoding a full pnpm virtual-store path that embeds the React peer-dependency version hash:

'^wouter$': '<rootDir>/../../node_modules/.pnpm/[email protected][email protected]/node_modules/wouter/src/index.js',
'^wouter/(.*)$': '<rootDir>/../../node_modules/.pnpm/[email protected][email protected]/node_modules/wouter/src/$1',

pnpm's virtual store directory name for wouter includes the resolved peer ([email protected]_react@<react-version>), so any bump to React rewrites that path. pnpm-lock.yaml was recently bumped so React resolves to 19.2.6, and the installed package now lives at node_modules/.pnpm/[email protected][email protected]/node_modules/wouter/.... The hardcoded [email protected] path no longer exists.

Impact

  • Every test in src/app/tests/app.test.tsx fails to load with a Jest createNoMappedModuleFoundError at import { memoryLocation } from 'wouter/memory-location';. Repro: pnpm --filter @simlin/app run test.
  • Any future suite in @simlin/app that imports wouter (or a wouter/* subpath) will hit the same failure.
  • The @simlin/app portion of the pnpm test run (pre-commit hook step 7 + CI) is red on the branch that bumped React.
  • Same fragility recurs on any React version change going forward -- it's a latent landmine, not a one-off.

Component(s) affected

  • src/app test config (src/app/jest.config.js)

Why it matters

Pinning a pnpm virtual-store path -- which by design encodes peer-dep version hashes -- is inherently fragile. The mapping exists for a legitimate reason (per the comment in jest.config.js: wouter is ESM-only / "type":"module", and CommonJS ts-jest can't resolve its package.json "exports" conditions), but the path should not be hash-pinned.

Possible approaches

  • Resolve wouter without the hash, e.g. require.resolve('wouter') and require.resolve('wouter/' + '$1')-style resolution in the config (Jest moduleNameMapper values can be computed in the JS config file).
  • Point the mapper at the workspace symlink instead: <rootDir>/../../node_modules/wouter/src/index.js and <rootDir>/../../node_modules/wouter/src/$1 (pnpm symlinks the top-level node_modules/wouter to the correct virtual-store entry, so it tracks the React version automatically).
  • Whichever approach, keep / update the existing explanatory comment about why the mapping is needed (ESM-only package under CJS ts-jest).

How discovered

Found incidentally while working on an unrelated src/diagram bug fix, after a pnpm-lock.yaml React bump (19.2.4 -> 19.2.6) landed in the working tree and pnpm --filter @simlin/app run test started failing to load app.test.tsx.

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