Skip to content

Commit 1384703

Browse files
committed
work around invalid es6 code generated
ref rescript-lang/rescript#2456
1 parent a1c5a92 commit 1384703

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/bs_node_fetch.ml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[%%raw "import NodeFetch from 'node-fetch'"]
2+
13
type body
24
type bodyInit
35
type headers
@@ -364,7 +366,11 @@ module Response = struct
364366
end
365367

366368

367-
external fetch : string -> response Js.Promise.t = "node-fetch" [@@bs.module]
368-
external fetchWithInit : string -> requestInit -> response Js.Promise.t = "node-fetch" [@@bs.module]
369-
external fetchWithRequest : request -> response Js.Promise.t = "node-fetch" [@@bs.module]
370-
external fetchWithRequestInit : request -> requestInit -> response Js.Promise.t = "node-fetch" [@@bs.module]
369+
external fetch : string -> response Js.Promise.t = "NodeFetch" [@@bs.val]
370+
external fetchWithInit : string -> requestInit -> response Js.Promise.t = "NodeFetch" [@@bs.val]
371+
external fetchWithRequest : request -> response Js.Promise.t = "NodeFetch" [@@bs.val]
372+
external fetchWithRequestInit : request -> requestInit -> response Js.Promise.t = "NodeFetch" [@@bs.val]
373+
let fetch = fetch
374+
let fetchWithInit = fetchWithInit
375+
let fetchWithRequest = fetchWithRequest
376+
let fetchWithRequestInit = fetchWithRequestInit

src/bs_node_fetch.mli

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ module Response : sig
212212
external text : string Js.Promise.t = "" [@@bs.send.pipe: t]
213213
end
214214

215-
external fetch : string -> response Js.Promise.t = "node-fetch" [@@bs.module]
216-
external fetchWithInit : string -> requestInit -> response Js.Promise.t = "node-fetch" [@@bs.module]
217-
external fetchWithRequest : request -> response Js.Promise.t = "node-fetch" [@@bs.module]
218-
external fetchWithRequestInit : request -> requestInit -> response Js.Promise.t = "node-fetch" [@@bs.module]
215+
val fetch : string -> response Js.Promise.t
216+
val fetchWithInit : string -> requestInit -> response Js.Promise.t
217+
val fetchWithRequest : request -> response Js.Promise.t
218+
val fetchWithRequestInit : request -> requestInit -> response Js.Promise.t

0 commit comments

Comments
 (0)