Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

(core) - Prevent Buffer from being auto-polyfilled (#2027)

authored by

Phil Pluckthun and committed by
GitHub
922d4a11 5e24ffdd

+10 -3
+5
.changeset/lucky-pens-end.md
··· 1 + --- 2 + '@urql/core': patch 3 + --- 4 + 5 + Prevent `Buffer` from being polyfilled by an automatic detection in Webpack. Instead of referencing the `Buffer` global we now simply check the constructor name.
+5 -3
packages/core/src/internal/fetchSource.ts
··· 10 10 11 11 type ChunkData = { done: false; value: Buffer | Uint8Array } | { done: true }; 12 12 13 + // NOTE: We're avoiding referencing the `Buffer` global here to prevent 14 + // auto-polyfilling in Webpack 13 15 const toString = (input: Buffer | ArrayBuffer): string => 14 - typeof Buffer !== 'undefined' && Buffer.isBuffer(input) 15 - ? input.toString() 16 - : decoder!.decode(input); 16 + input.constructor.name === 'Buffer' 17 + ? (input as Buffer).toString() 18 + : decoder!.decode(input as ArrayBuffer); 17 19 18 20 // DERIVATIVE: Copyright (c) 2021 Marais Rossouw <hi@marais.io> 19 21 // See: https://github.com/maraisr/meros/blob/219fe95/src/browser.ts