Skip to content

[v8] fix: bundle ESM-only deps for CJS compatibility#1423

Merged
nicknisi merged 1 commit intoversion-8from
nicknisi/bundle-esm-deps
Dec 22, 2025
Merged

[v8] fix: bundle ESM-only deps for CJS compatibility#1423
nicknisi merged 1 commit intoversion-8from
nicknisi/bundle-esm-deps

Conversation

@nicknisi
Copy link
Member

Bundle iron-webcrypto and uint8array-extras into the build output using noExternal.

These packages are ESM-only and cause ERR_REQUIRE_ESM errors for CJS consumers without special Jest/bundler configuration.

iron-webcrypto and uint8array-extras are ESM-only packages.
Without bundling, CJS consumers get ERR_REQUIRE_ESM errors
and need special Jest/bundler configuration.
@nicknisi nicknisi requested a review from a team as a code owner December 22, 2025 20:51
@nicknisi nicknisi requested review from mattgd and removed request for a team December 22, 2025 20:51
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 22, 2025

Greptile Summary

This PR adds noExternal configuration to bundle iron-webcrypto and uint8array-extras into the build output. These packages are ESM-only and cause ERR_REQUIRE_ESM errors when CJS consumers try to import them.

Changes:

  • Added noExternal: ['iron-webcrypto', 'uint8array-extras'] to tsdown.config.ts
  • Ensures ESM-only dependencies are bundled for CJS compatibility while keeping other deps external via unbundle: true

Context:
The iron-webcrypto v2.0.0 dependency was recently introduced in #1416 to replace iron-session, and it has a transitive dependency on uint8array-extras, both of which only publish ESM. This change is essential for CJS consumers who would otherwise encounter import errors.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The change is a straightforward build configuration fix that addresses a real compatibility issue. The solution is correct: using noExternal to bundle ESM-only dependencies while maintaining unbundle: true for other deps. Both packages are MIT licensed, small in size, and already direct/transitive dependencies.
  • No files require special attention

Important Files Changed

Filename Overview
tsdown.config.ts Added noExternal configuration to bundle ESM-only dependencies (iron-webcrypto and uint8array-extras) for CJS compatibility

Sequence Diagram

sequenceDiagram
    participant CJS as CJS Consumer
    participant PKG as @workos-inc/node (CJS)
    participant IRON as iron-webcrypto (bundled)
    participant U8A as uint8array-extras (bundled)
    
    Note over CJS,U8A: Build Process (tsdown)
    Note over PKG: unbundle: true<br/>(deps stay external by default)
    Note over IRON,U8A: noExternal: ['iron-webcrypto', 'uint8array-extras']<br/>(bundle these ESM-only deps)
    
    Note over CJS,U8A: Runtime Usage
    CJS->>PKG: require('@workos-inc/node')
    Note over PKG: CJS build (lib/index.cjs)
    PKG->>IRON: uses bundled iron-webcrypto
    Note over IRON: No ERR_REQUIRE_ESM!<br/>(bundled as CJS)
    IRON->>U8A: uses bundled uint8array-extras
    Note over U8A: No ERR_REQUIRE_ESM!<br/>(bundled as CJS)
    U8A-->>IRON: returns
    IRON-->>PKG: seal/unseal functions
    PKG-->>CJS: WorkOS SDK methods
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@nicknisi nicknisi merged commit 6c9580e into version-8 Dec 22, 2025
8 checks passed
@nicknisi nicknisi deleted the nicknisi/bundle-esm-deps branch December 22, 2025 21:07
nicknisi added a commit that referenced this pull request Jan 8, 2026
Bundle `iron-webcrypto` and `uint8array-extras` into the build output
using `noExternal`.

These packages are ESM-only and cause `ERR_REQUIRE_ESM` errors for CJS
consumers without special Jest/bundler configuration.
nicknisi added a commit that referenced this pull request Jan 9, 2026
Bundle `iron-webcrypto` and `uint8array-extras` into the build output
using `noExternal`.

These packages are ESM-only and cause `ERR_REQUIRE_ESM` errors for CJS
consumers without special Jest/bundler configuration.
nicknisi added a commit that referenced this pull request Jan 12, 2026
Bundle `iron-webcrypto` and `uint8array-extras` into the build output
using `noExternal`.

These packages are ESM-only and cause `ERR_REQUIRE_ESM` errors for CJS
consumers without special Jest/bundler configuration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants