Skip to content

@metamask/snaps-utils imports deepmerge without declaring it in dependencies (and similar in snaps-rpc-methods, snaps-jest) #4181

Open

Description

@trackoor

Since #3802, packages/snaps-utils/src/manifest/manifest.ts imports deepmerge at runtime, while packages/snaps-utils/package.json lists deepmerge only in devDependencies, so @metamask/snaps-utils/node fails to load on a fresh install:

mkdir repro && cd repro
echo '{"type":"module","private":true}' > package.json
npm install @metamask/[email protected]
node -e "import('@metamask/snaps-utils/node')"

Actual:

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'deepmerge' imported from .../node_modules/@metamask/snaps-utils/dist/manifest/manifest.mjs

require('@metamask/snaps-utils/node') fails with Cannot find module 'deepmerge', and a plain npm install of @metamask/[email protected], @metamask/[email protected], or @metamask/[email protected] fails the same way because they import @metamask/snaps-utils/node and nothing in their dependency trees pulls in deepmerge.

Two other packages in the monorepo also import runtime dependencies listed only in devDependencies (resolved via hoisting under npm, failing with ERR_MODULE_NOT_FOUND under non-hoisted resolution such as Yarn PnP or pnpm with hoistPattern: []):

  • @metamask/[email protected]: src/permitted/middleware.ts imports @metamask/json-rpc-engine and src/permissions.ts imports @metamask/json-rpc-engine/v2, while @metamask/json-rpc-engine is only in devDependencies.
  • @metamask/[email protected]: src/helpers.ts, src/matchers.ts, and src/internals/server.ts import @metamask/snaps-utils and @metamask/snaps-utils/node, while @metamask/snaps-utils is only in devDependencies.

Expected: @metamask/snaps-utils, @metamask/snaps-rpc-methods, and @metamask/snaps-jest declare their runtime imports in dependencies so they load without relying on hoisting or extra installs.

Versions: @metamask/[email protected], @metamask/[email protected], @metamask/[email protected] (plus @metamask/[email protected], @metamask/[email protected]), and main (20c55c44); Node.js v26.13.0, npm 11.20.0, pnpm 12.18.0.

Credit: https://ucsbplse.github.io/

Activity

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