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
3838
3939:::
4040
41- ### Polyfill fetch in node
41+ ### Polyfill fetch in node & lt ; 18
4242
4343Node doesn't come with fetch out of the box, so we need to be sure to polyfill it.
4444
Original file line number Diff line number Diff line change @@ -3,3 +3,24 @@ require('core-js/stable');
33window . requestIdleCallback = jest . fn ( ) . mockImplementation ( cb => {
44 cb ( ) ;
55} ) ;
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