Skip to content

fix(deps): move tinyspy from devDependencies to dependencies#320

Draft
arturosdg wants to merge 1 commit into
masterfrom
claude/tinyspy-to-deps
Draft

fix(deps): move tinyspy from devDependencies to dependencies#320
arturosdg wants to merge 1 commit into
masterfrom
claude/tinyspy-to-deps

Conversation

@arturosdg

Copy link
Copy Markdown
Contributor

Summary

Fix a latent phantom dependency: tinyspy is imported from src/utils/tinyspyWrapper.ts and the published dist/ calls require("tinyspy") at runtime, but the package is declared as a devDependency. Today it only works in consumers because vitest (which every wrapito consumer installs) brings tinyspy transitively and npm hoists it.

Why this matters

  • Breaks on stricter resolvers. pnpm with default settings and Yarn PnP don't flatten node_modules, so wrapito fails to resolve tinyspy in those projects.
  • Silent version drift. Consumers receive whatever tinyspy version their vitest happens to bring. If that version becomes incompatible with the internal APIs we use (getInternalState, internalSpyOn), wrapito breaks without any change on its side.
  • Invisible decoupling from vitest's internals. If a future vitest stops depending on tinyspy or replaces it, every wrapito consumer breaks.

Changes

package.json: move tinyspy from devDependencies to dependencies.

No code changes. dist/ keeps the same require("tinyspy") it already had.

Risk

Very low. npm and Yarn classic will dedupe the new declared dependency against the existing transitive one (same range), so consumers see no extra install and no version change.

Test plan

  • npm test — 82/82 passing
  • npm run builddist/index.js still externalizes tinyspy via require("tinyspy")
  • Install resulting tarball in a real consumer repo to verify resolution under both npm and pnpm

🤖 Generated with Claude Code

`tinyspy` is imported from `src/utils/tinyspyWrapper.ts` (uses `getInternalState`
and `internalSpyOn`) and the published bundle calls `require("tinyspy")` at
runtime. Until now it was declared as a devDependency, so consumers were
resolving it transitively via `vitest` (a phantom dependency):

  consumer/node_modules/vitest depends on tinyspy → hoisted to top-level
  → wrapito/dist resolves it by node_modules traversal

This works on npm and Yarn classic thanks to flat hoisting, but is fragile:
- breaks under pnpm with default settings and Yarn PnP
- silently picks whatever tinyspy version the consumer's vitest brings,
  which can drift away from the version wrapito was tested against
- breaks if vitest ever drops tinyspy

Declaring it as a real dependency fixes the latent bug. npm will dedupe
against the consumer's existing tinyspy when ranges overlap, so there is
no extra disk/install cost for the common case.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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