Skip to content

fix(google): lazy-load jose in CJS auth helpers#10407

Merged
Hunter Lovell (hntrl) merged 3 commits intolangchain-ai:mainfrom
fahe1em1:codex/langchainjs-10403-google-jose-cjs
Mar 17, 2026
Merged

fix(google): lazy-load jose in CJS auth helpers#10407
Hunter Lovell (hntrl) merged 3 commits intolangchain-ai:mainfrom
fahe1em1:codex/langchainjs-10403-google-jose-cjs

Conversation

@fahe1em1
Copy link
Contributor

Summary

  • lazy-load jose inside the GCP auth helpers so the CJS bundle no longer eagerly require() an ESM-only dependency
  • keep the ESM path unchanged while fixing CommonJS consumers of @langchain/google/node
  • add focused regression tests that prove the helper module loads without importing jose until a signing helper is actually used

Fixes #10403.

Why this is safe

This only changes when jose is loaded. The affected helpers were already async, so switching them to fetch jose lazily preserves behavior while avoiding the ERR_REQUIRE_ESM crash in CommonJS runtimes.

Validation

  • pnpm --filter @langchain/google test -- src/utils/tests/gcp-auth.test.ts
  • pnpm --filter @langchain/google build
  • pnpm --filter @langchain/google lint

@changeset-bot
Copy link

changeset-bot bot commented Mar 12, 2026

🦋 Changeset detected

Latest commit: ad6cafd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@langchain/google Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@afirstenberg
Copy link
Contributor

LGTM

@pawel-twardziak
Copy link
Contributor

great work fahe1em1 !

@hntrl Hunter Lovell (hntrl) merged commit c2960fe into langchain-ai:main Mar 17, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@langchain/google CJS entry points fail at runtime: require("jose") in gcp-auth.cjs breaks because jose v6 is ESM-only

4 participants