Repository navigation
Description
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.tsxfails to load with a JestcreateNoMappedModuleFoundErroratimport { memoryLocation } from 'wouter/memory-location';. Repro:pnpm --filter @simlin/app run test. - Any future suite in
@simlin/appthat importswouter(or awouter/*subpath) will hit the same failure. - The
@simlin/appportion of thepnpm testrun (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/apptest 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
wouterwithout the hash, e.g.require.resolve('wouter')andrequire.resolve('wouter/' + '$1')-style resolution in the config (JestmoduleNameMappervalues can be computed in the JS config file). - Point the mapper at the workspace symlink instead:
<rootDir>/../../node_modules/wouter/src/index.jsand<rootDir>/../../node_modules/wouter/src/$1(pnpm symlinks the top-levelnode_modules/wouterto 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.
Activity
app: derive wouter jest moduleNameMapper from require.resolve