From 896679fce1d6cd6fa6bda3b769acedfc7bc5a965 Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Wed, 11 Dec 2024 02:06:08 -0800 Subject: [PATCH] fix node-fetch --- gax/esm/src/fallbackServiceStub.ts | 7 ++++++- gax/package.json | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/gax/esm/src/fallbackServiceStub.ts b/gax/esm/src/fallbackServiceStub.ts index bec89b47b..c87271130 100644 --- a/gax/esm/src/fallbackServiceStub.ts +++ b/gax/esm/src/fallbackServiceStub.ts @@ -42,7 +42,12 @@ export interface FallbackServiceStub { export type FetchParametersMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'; async function getNodeFetch() { - return await import('node-fetch'); + const isEsm = true; + if (isEsm) { + return await import('node-fetch'); + } else { + return require('node-fetch'); + } } export interface FetchParameters { headers: {[key: string]: string}; diff --git a/gax/package.json b/gax/package.json index ba855af14..25619ea2a 100644 --- a/gax/package.json +++ b/gax/package.json @@ -2,9 +2,9 @@ "name": "google-gax", "version": "4.5.0", "description": "Google API Extensions", - "main": "./build/cjs/src/index.cjs", + "main": "./build/esm/src/index.js", "type": "module", - "types": "./build/cjs/src/index.d.ts", + "types": "./build/esm/src/index.d.ts", "files": [ "build/esm", "build/cjs",