From a1c6880845a2a835bd2c5236ac4e11a5c2b23752 Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Fri, 10 Mar 2023 11:53:42 +1100 Subject: [PATCH] Revert "Merge pull request #21497 from storybookjs/tom/21432-replace-isomorphic-unfetch" This reverts commit 44284e4ccc579165f71703efa47a7385306a8f03, reversing changes made to 99bcb2ca3d1602e2841808cbfc8e9babea5840b9. --- code/lib/telemetry/package.json | 3 +-- code/lib/telemetry/src/telemetry.test.ts | 6 +++--- code/lib/telemetry/src/telemetry.ts | 4 ++-- code/yarn.lock | 3 +-- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/code/lib/telemetry/package.json b/code/lib/telemetry/package.json index d714be137a5c..b567560967c5 100644 --- a/code/lib/telemetry/package.json +++ b/code/lib/telemetry/package.json @@ -45,13 +45,12 @@ "dependencies": { "@storybook/client-logger": "7.0.0-rc.0", "@storybook/core-common": "7.0.0-rc.0", - "@types/node-fetch": "^2.5.7", "chalk": "^4.1.0", "detect-package-manager": "^2.0.1", "fetch-retry": "^5.0.2", "fs-extra": "^11.1.0", + "isomorphic-unfetch": "^3.1.0", "nanoid": "^3.3.1", - "node-fetch": "^2.6.7", "read-pkg-up": "^7.0.1" }, "devDependencies": { diff --git a/code/lib/telemetry/src/telemetry.test.ts b/code/lib/telemetry/src/telemetry.test.ts index eb867acd13b9..821848d1fc76 100644 --- a/code/lib/telemetry/src/telemetry.test.ts +++ b/code/lib/telemetry/src/telemetry.test.ts @@ -1,12 +1,12 @@ /// ; -import fetch from 'node-fetch'; +import fetch from 'isomorphic-unfetch'; import { sendTelemetry } from './telemetry'; -jest.mock('node-fetch'); +jest.mock('isomorphic-unfetch'); -const fetchMock = fetch as any as jest.Mock; +const fetchMock = fetch as jest.Mock; beforeEach(() => { fetchMock.mockResolvedValue({ status: 200 }); diff --git a/code/lib/telemetry/src/telemetry.ts b/code/lib/telemetry/src/telemetry.ts index f66c10ee8d4e..4ae1364a5836 100644 --- a/code/lib/telemetry/src/telemetry.ts +++ b/code/lib/telemetry/src/telemetry.ts @@ -1,4 +1,4 @@ -import originalFetch from 'node-fetch'; +import originalFetch from 'isomorphic-unfetch'; import retry from 'fetch-retry'; import { nanoid } from 'nanoid'; import type { Options, TelemetryData } from './types'; @@ -7,7 +7,7 @@ import { set as saveToCache } from './event-cache'; const URL = process.env.STORYBOOK_TELEMETRY_URL || 'https://storybook.js.org/event-log'; -const fetch = retry(originalFetch as any); +const fetch = retry(originalFetch); let tasks: Promise[] = []; diff --git a/code/yarn.lock b/code/yarn.lock index 739455295cef..82bd5285b16f 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -7106,13 +7106,12 @@ __metadata: dependencies: "@storybook/client-logger": 7.0.0-rc.0 "@storybook/core-common": 7.0.0-rc.0 - "@types/node-fetch": ^2.5.7 chalk: ^4.1.0 detect-package-manager: ^2.0.1 fetch-retry: ^5.0.2 fs-extra: ^11.1.0 + isomorphic-unfetch: ^3.1.0 nanoid: ^3.3.1 - node-fetch: ^2.6.7 read-pkg-up: ^7.0.1 typescript: ~4.9.3 languageName: unknown