• Phil Pluckthun's avatar
    (persisted-fetch) - Fix Crypto API support for Web Workers and Node ESM mode (#2123) · 477fa168
    Phil Pluckthun authored
    * Remove require passthrough from eval require
    
    The `require` statement is in the entire module scope,
    which `new Function` does have access to, so we don't
    need to pass it in and can avoid an indirect require
    warning from Webpack.
    
    * Add support for web-workers and Node ESM
    
    In Web Workers we have to check for `self`. We avoid checking
    `globalThis` and `globals`, since Node's `crypto` global is colliding
    with Web Crypto and auto-polyfilling may get the wrong idea.
    
    The Node Crypto support has been expanded to try `require` first and
    then fall back to a dynamic import instead for Node ESM.
    
    * Add changeset
    
    * Switch back to require in module scope and eval dynamic import
    477fa168