Skip to content

testcontainers@12.0.2 (patch) pulls in ESM-only archiver@8, breaking CommonJS/Jest consumers #1365

Description

@dh-seanmurphy

Summary

The patch release 12.0.112.0.2 bumped the archiver dependency from ^7 to ^8.0.0. archiver@8.0.0 is an ESM-only major release ("type": "module", single "exports": "./index.js" with no require condition, CJS build dropped).

testcontainers is itself compiled to CommonJS and consumes archiver via require("archiver"). require()-ing an ESM-only package is not supported by Jest's CommonJS module runtime, so any consumer running testcontainers under Jest now fails to even load the module.

Introducing an ESM-only major of a dependency is a breaking change for CommonJS consumers and shouldn't ship in a patch release. Jest's runtime does not honor Node's require(esm) interop, so this breaks Jest test suites that use testcontainers — independent of Node version.

Reproduction

repro fails at module load time (require("testcontainers")require("archiver")), before any container is created.

package.json

{
  "name": "tc-esm-repro",
  "devDependencies": {
    "jest": "30.4.2",
    "testcontainers": "12.0.2"
  }
}

repro.test.js

// Fails to even load the module — no Docker required.
require("testcontainers");

test("testcontainers loads under Jest", () => {});

Run:

npm install
npx jest

Result:

SyntaxError: Cannot use import statement outside a module

  .../node_modules/archiver/index.js:1
  import Archiver from "./lib/core.js";
  ^^^^^^
  at .../testcontainers/build/generic-container/started-generic-container.js:7

Changing only "testcontainers": "12.0.2""12.0.1" and re-running npx jest makes the suite pass. The sole difference is archiver@8 (ESM-only) vs archiver@7 (CJS).

Environment

  • testcontainers: 12.0.2
  • archiver: 8.0.0 (ESM-only)
  • Jest: 30.4.2
  • node: 24.16.0

Suggested resolution

  • Revert to archiver@^7 in a 12.0.x patch and ship the archiver@8 upgrade as a minor or major instead

Extra information

Issue report generated with assistance from Claude.

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