• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jeremydaly / lambda-api / #234
83%

Build:
DEFAULT BRANCH: main
Ran 22 Aug 2026 04:29PM UTC
Jobs 1
Files 17
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

22 Aug 2026 04:29PM UTC coverage: 82.528% (-0.3%) from 82.854%
#234

push

github

web-flow
fix: keep the CommonJS interop shim out of the ESM build (#346) (#347)

* fix: keep the CommonJS interop shim out of the ESM build (#346)

The dual CJS/ESM build (#326, shipped in 1.5.0) compiles a single `src/` tree
twice. Seven source files ended with an interop shim:

    if (typeof module !== 'undefined') {
      module.exports = createAPI;
      module.exports.default = createAPI;
    }

which restores the historical CommonJS shape — but it was emitted into
`dist/esm` as well. Bundlers that inline the ESM artifact into a generated
CommonJS wrapper (esbuild `--format=cjs`, AWS CDK `NodejsFunction`, SST,
Serverless Framework) leave exactly one `module` in scope: the consumer's. The
shim then replaced the consumer's `module.exports`, deleting their `handler`.

On Lambda this deployed cleanly and failed on every invocation with
`Runtime.HandlerNotFound: index.handler is undefined or not exported`, with
nothing in the error naming lambda-api.

`src/` is now pure ESM. The interop footers are appended to `dist/cjs` only, by
`scripts/cjs-interop.js`, which also loads each patched file back and fails the
build if the CommonJS shape is wrong. Footers are per-file on purpose: the
`.default` self-reference is correct on the package root but would make
`mimemap['default']` resolve to the whole MIME map.

`src/lib/s3-service.js` now exports its `service` object so the footer can
reach it; that object must stay the module value so `response.js` and the unit
suites (`sinon.stub`) share one set of mutable properties.

Nothing about `dist/cjs` changes: `require('lambda-api')` is still callable,
`.default` still self-references, and `require('lambda-api/lib/*')` still
returns the value itself.

Regression coverage:
- `module-compat` fails if any `dist/esm` file references `module.exports`,
  `typeof module`, or `exports.` — it named all 7 files before the fix.
- `module-compat` pins the `dist/cjs` interop shape the footers must preserve.
- New e2e Layer 1 fixture b... (continued)

813 of 994 branches covered (81.79%)

Branch coverage included in aggregate %.

20 of 36 new or added lines in 1 file covered. (55.56%)

26 existing lines in 1 file now uncovered.

793 of 952 relevant lines covered (83.3%)

120.11 hits per line

Uncovered Changes

Lines Coverage ∆ File
16
51.92
scripts/cjs-interop.js

Coverage Regressions

Lines Coverage ∆ File
26
13.46
-0.69% dist/cjs/lib/s3-service.js
Jobs
ID Job ID Ran Files Coverage
1 #234.1 22 Aug 2026 04:29PM UTC 17
82.53
Source Files on build #234
  • Tree
  • List 17
  • Changed 7
  • Source Changed 0
  • Coverage Changed 7
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • dbce417a on github
  • Prev Build on main
  • Next Build on main
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc