Skip to content

Serve require() from src/ and drop the cjs/ build #16

Open

Description

@okomarov

transpile.cjs regex-rewrites src/ and tests/ into cjs/, which the default export condition serves to require(). engines is node >= 24, where require() of an ES module works without a flag, and src/ has no top-level await. So require() can load src/ directly.

Proposal

  • Add export { Postgres as 'module.exports' } to src/index.js so require('@steadybrew/postgresjs') still returns the function, as cjs/ does today. require('@steadybrew/postgresjs/vercel') already yields { vercelPool } in both forms.
  • Point default (and main) at src/, then remove transpile.cjs, cjs/ and /cjs/* from files.

Check before switching

  • Jest in CommonJS mode, ts-node, tsx, and webpack/esbuild bundling a CommonJS app: which handle require() of an ES module.
  • TypeScript: types/index.d.ts uses export = postgres; confirm module: nodenext and commonjs consumers still type-check.
  • Whether this is a breaking change for semver, given the tooling above.

Tests

cjs/tests runs the whole suite under the transpiled code, and tests-startup loads cjs/src for --cjs. Replace both with require() smoke tests against src/ (default export, vercel subpath, instanceof across the two entry points).

Done when

require() resolves to src/, cjs/ and transpile.cjs are gone, CI covers the require() path, and the CHANGELOG states it.

Activity

  1. added
    enhancement
    area: project
    on Oct 9, 2026
  2. moved this to Later in Roadmapon Oct 16, 2026
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

    area: projectenhancement

    Type

    No type

    Projects

    • Status
      Later

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions