Skip to content

DX: dual ESM/CJS, types, ergonomic API, and zero-advisory deps#4

Merged
jamoy merged 2 commits into
claude/gifted-cannon-gfy802from
claude/gifted-cannon-gfy802-dx
Jun 22, 2026
Merged

DX: dual ESM/CJS, types, ergonomic API, and zero-advisory deps#4
jamoy merged 2 commits into
claude/gifted-cannon-gfy802from
claude/gifted-cannon-gfy802-dx

Conversation

@jamoy

@jamoy jamoy commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Stacked on #3 — please review/merge that first; this PR's diff is only the commits on top of it.

Modernizes the package's developer experience without breaking the existing API.

Dual ESM + CJS

  • Ships both index.js (CommonJS) and index.mjs (ESM) behind an exports map with per-condition types, plus a module field.
  • import Sfn from 'stepfunctions', import { StepFunction } from 'stepfunctions', and const Sfn = require('stepfunctions') all work.
  • Verified by packing the real tarball and loading it both ways, and a test/smoke.mjs is wired into CI on every Node version.

Types

  • Adds index.d.mts (ESM) alongside index.d.ts (CJS); both type-check under node16 module resolution. Return/constructor types updated for the new ergonomics.

Ergonomics + footgun fixes (backwards compatible)

  • startExecution now resolves to the final outputconst out = await sm.startExecution(input).
  • getExecutionResult() is non-mutating — it previously popped the steps array, so a second call returned a different value. Repeated calls now return the same result.
  • The constructor accepts a bare ASL definition (new Sfn({ StartAt, States })) in addition to new Sfn({ StateMachine }).
  • All additive: the previous usage still works.

Vulnerability advisories → 0

  • npm audit now reports 0 vulnerabilities (was 2 high + 17 moderate).
  • overrides: underscore ^1.13.8 (fixes the jsonpath → underscore high advisory that actually reaches consumers) and js-yaml ^4.2.0 (the dev-only istanbul advisory). Confirmed Jest coverage still works under the js-yaml bump.

CI

  • Runs on all pull requests (so PRs stacked on feature branches get CI), and adds the dual-loading smoke step.

Tests: 88 passing, 5 skipped. Lint (ESLint + Prettier) clean. 0 advisories.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QznGWnSQuwvNRAcYinsZiG


Generated by Claude Code

jamoy and others added 2 commits June 22, 2026 07:41
- startExecution now resolves to the final output, so callers can write
  `const out = await sm.startExecution(input)` without a separate call
- getExecutionResult is non-mutating (was popping the steps array, so a second
  call returned a different value); repeated calls now return the same result
- the constructor accepts a bare Amazon States Language definition
  (`new Sfn({ StartAt, States })`) in addition to `new Sfn({ StateMachine })`

All three are additive; the previous usage continues to work.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QznGWnSQuwvNRAcYinsZiG
- ship both entry points: index.js (CJS) and index.mjs (ESM) behind an
  `exports` map with per-condition `types`, plus a `module` field
- add index.d.mts (ESM types) alongside index.d.ts (CJS); both type-check
  under node16 module resolution; constructor/return types updated for the
  new ergonomics
- clear all npm audit advisories via overrides: underscore ^1.13.8 (fixes the
  jsonpath -> underscore high advisory that reaches consumers) and js-yaml
  ^4.2.0 (the dev-only istanbul advisory); `npm audit` now reports 0
- add a dual-loading smoke test (test/smoke.mjs) wired into CI on every Node
  version, and run CI on all pull requests (so PRs stacked on feature
  branches are covered)
- lint index.mjs (ESM) and document ESM/CJS usage in the README

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QznGWnSQuwvNRAcYinsZiG
@jamoy jamoy merged commit 04acb5a into claude/gifted-cannon-gfy802 Jun 22, 2026
3 checks passed
jamoy added a commit that referenced this pull request Jun 22, 2026
Reconcile master: bring DX (#4) and pnpm (#5) changes onto master
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