Skip to content

Commit

Permalink
Polyfill Blob for Node.js < 18 (#49156)
Browse files Browse the repository at this point in the history
Since `react-server-dom-webpack-server.node` uses `Blob`, we need to polyfill it for Node.js 16.
  • Loading branch information
shuding committed May 3, 2023
1 parent 467539c commit 2ebc724
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/next/src/server/node-polyfill-form.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
/**
* Polyfills `FormData` in the Node.js runtime.
* Polyfills `FormData` and `Blob` in the Node.js runtime.
*/

if (!(global as any).FormData) {
const { FormData } =
require('next/dist/compiled/@edge-runtime/primitives/fetch') as typeof import('next/dist/compiled/@edge-runtime/primitives/fetch')
;(global as any).FormData = FormData
}

if (!(global as any).Blob) {
const { Blob } =
require('next/dist/compiled/@edge-runtime/primitives/blob') as typeof import('next/dist/compiled/@edge-runtime/primitives/blob')
;(global as any).Blob = Blob
}

0 comments on commit 2ebc724

Please sign in to comment.