Skip to content

/dot subpath requires the optional dotparser peer, but that requirement isn't documented anywhere published to npm #49

Closed

Description

@thymikee

Version

Confirmed on @statelyai/graph 2.4.0 and the current latest, 2.5.1 (unchanged).

Summary

Importing @statelyai/graph/dot (for toDOT/fromDOT/dotConverter) requires the dotparser package at runtime, but dotparser is an optional peer dependency (peerDependenciesMeta.dotparser.optional: true). A consumer who installs @statelyai/graph without separately installing dotparser gets a raw ERR_MODULE_NOT_FOUND for dotparser on first import of the /dot subpath, with nothing in that failure indicating this is an expected, documented optional dependency rather than a broken install.

This requirement is documented — but only in src/formats/dot/README.md, which is not published to npm (package.json's files field is ["dist", "schemas"], and that README has no counterpart under dist/formats/dot/). The only README that ships to npm consumers is the top-level one, which says generically "Each adapter is an optional subpath import" with no per-format breakdown of which subpaths need which peer. The published .d.mts JSDoc for toDOT/fromDOT/dotConverter (the first thing an editor shows on hover) doesn't mention dotparser either — and its own @example additionally imports toDOT from the package root (import { createGraph, toDOT } from '@statelyai/graph'), which doesn't export toDOT at all; it only exists at @statelyai/graph/dot.

Minimal repro

Runtime failure (dotparser not installed):

// dotparser is not installed
const { toDOT } = await import('@statelyai/graph/dot');
Error: Cannot find package 'dotparser' imported from .../node_modules/@statelyai/graph/dist/formats/dot/index.mjs

The JSDoc example's own import is wrong:

import { createGraph, toDOT } from '@statelyai/graph';
console.log(typeof toDOT); // undefined — not exported from the root

Expected

  • The dotparser requirement is documented somewhere that ships to npm — either in the published top-level README (per-subpath, mirroring the unpublished src/formats/dot/README.md) or in the toDOT/fromDOT/dotConverter JSDoc itself.
  • The JSDoc @example imports toDOT from @statelyai/graph/dot, matching how it's actually exported, not from the package root.
  • Ideally, the /dot subpath catches the missing-peer MODULE_NOT_FOUND and re-throws with a message naming the optional peer and the install command, rather than surfacing Node's raw resolution error for a package the caller never required directly.

Actual

  • npm install @statelyai/graph ships only the top-level README; the per-format README documenting the dotparser requirement exists in the GitHub source tree but never reaches npm consumers.
  • The published JSDoc for toDOT/fromDOT/dotConverter has no mention of the peer requirement, and its own example imports toDOT from the wrong module.
  • The failure on a missing peer is a bare ERR_MODULE_NOT_FOUND for dotparser, a package name the caller never referenced.

Activity

  1. davidkpiano commented on Oct 9, 2026

    @davidkpiano
    Member

    Fixed by #50

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