Skip to content

Commit 6da64ba

Browse files
committed
Conditionally load cross-fetch from the polyfill root
1 parent 7950449 commit 6da64ba

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/errors/meilisearch-communication-error.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'cross-fetch/polyfill'
21
import { FetchError } from '../types'
32

43
class MeiliSearchCommunicationError extends Error {

src/http-requests.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import 'cross-fetch/polyfill'
2-
31
import { Config, EnqueuedTaskObject } from './types'
42
import { PACKAGE_VERSION } from './package-version'
53

@@ -120,6 +118,10 @@ class HttpRequests {
120118
body?: any
121119
config?: Record<string, any>
122120
}) {
121+
if (typeof fetch === 'undefined') {
122+
require('cross-fetch/polyfill')
123+
}
124+
123125
const constructURL = new URL(url, this.url)
124126
if (params) {
125127
const queryParams = new URLSearchParams()

0 commit comments

Comments
 (0)