DX: dual ESM/CJS, types, ergonomic API, and zero-advisory deps#4
Merged
jamoy merged 2 commits intoJun 22, 2026
Merged
Conversation
- 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
index.js(CommonJS) andindex.mjs(ESM) behind anexportsmap with per-conditiontypes, plus amodulefield.import Sfn from 'stepfunctions',import { StepFunction } from 'stepfunctions', andconst Sfn = require('stepfunctions')all work.test/smoke.mjsis wired into CI on every Node version.Types
index.d.mts(ESM) alongsideindex.d.ts(CJS); both type-check undernode16module resolution. Return/constructor types updated for the new ergonomics.Ergonomics + footgun fixes (backwards compatible)
startExecutionnow resolves to the final output —const 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.new Sfn({ StartAt, States })) in addition tonew Sfn({ StateMachine }).Vulnerability advisories → 0
npm auditnow reports 0 vulnerabilities (was 2 high + 17 moderate).overrides:underscore ^1.13.8(fixes thejsonpath → underscorehigh advisory that actually reaches consumers) andjs-yaml ^4.2.0(the dev-only istanbul advisory). Confirmed Jest coverage still works under the js-yaml bump.CI
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