File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ to `renderDataHook()` will result in a completely fresh cache state as well as m
38
38
39
39
:::
40
40
41
- ### Polyfill fetch in node
41
+ ### Polyfill fetch in node & lt ; 18
42
42
43
43
Node doesn't come with fetch out of the box, so we need to be sure to polyfill it.
44
44
Original file line number Diff line number Diff line change @@ -3,3 +3,24 @@ require('core-js/stable');
3
3
window . requestIdleCallback = jest . fn ( ) . mockImplementation ( cb => {
4
4
cb ( ) ;
5
5
} ) ;
6
+ if ( ! globalThis . TextEncoder || ! globalThis . TextDecoder ) {
7
+ const { TextDecoder, TextEncoder } = require ( 'node:util' ) ;
8
+ globalThis . TextEncoder = TextEncoder ;
9
+ globalThis . TextDecoder = TextDecoder ;
10
+ }
11
+
12
+ if ( ! globalThis . ReadableStream || ! globalThis . WritableStream ) {
13
+ const { ReadableStream, WritableStream } = require ( 'node:stream/web' ) ;
14
+ globalThis . ReadableStream = ReadableStream ;
15
+ globalThis . WritableStream = WritableStream ;
16
+ }
17
+
18
+ if ( ! globalThis . TextEncoderStream ) {
19
+ const { TextEncoderStream } = require ( 'node:stream/web' ) ;
20
+ globalThis . TextEncoderStream = TextEncoderStream ;
21
+ }
22
+
23
+ if ( ! globalThis . TransformStream ) {
24
+ const { TransformStream } = require ( 'node:stream/web' ) ;
25
+ globalThis . TransformStream = TransformStream ;
26
+ }
You can’t perform that action at this time.
0 commit comments