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.

(exchange-persisted-fetch) - Make indirect eval call to optimize for minifiers (#1744)

* Make indirect eval call to optimize for minifiers

* Use Function constructor and remove ternary expression.

authored by

_nderscore and committed by
GitHub
00ad6421 616ac76c

+13 -2
+5
.changeset/silent-carpets-judge.md
··· 1 + --- 2 + '@urql/exchange-persisted-fetch': patch 3 + --- 4 + 5 + Optimize for minification by avoiding direct eval call.
+8 -2
exchanges/persisted-fetch/src/sha256.ts
··· 30 30 }); 31 31 }; 32 32 33 - const nodeCrypto = 34 - typeof window === 'undefined' ? eval("require('crypto')") : null; 33 + let nodeCrypto; 34 + if (typeof window === 'undefined') { 35 + try { 36 + // Indirect eval/require to guarantee no side-effects in module scope 37 + // (optimization for minifiers) 38 + nodeCrypto = new Function('require', 'return require("crypto")')(require); 39 + } catch (e) {} 40 + } 35 41 36 42 export const hash = async (query: string): Promise<string> => { 37 43 if (