isomorphic-undici
TypeScript icon, indicating that this package has built-in type declarations

1.0.9 • Public • Published

isomorphic-undici

Isomorphic exports of fetch, providing window.fetch in the browser and undici.fetch in node.js.

npm install isomorphic-undici

Usage

import fetch from 'isomorphic-undici';

Why

undici fetch reduces request processing time by ~ 50-60%

Requirements

Node 16+

To use with webpack, you need to add to your webpack config for node (target:node):

  • webpack >=v5.53 or add the external dependency "stream/web"
  • experiments asyncWebAssembly: true
  • add webassembly-loader (npm i webassembly-loader)

example

  externals: {
    'stream/web': 'commonjs stream/web', // for webpack lowest than v5.53
  },
  experiments: {
    asyncWebAssembly: true,
  },
  rules: [
    {
      test: /\.wasm$/,
      type: 'javascript/auto',
      use: [
        {
          loader: 'webassembly-loader',
          options: {
            export: 'buffer', // only buffer
          },
        },
      ],
    },
  ],

License

MIT

/isomorphic-undici/

    Package Sidebar

    Install

    npm i isomorphic-undici

    Weekly Downloads

    2

    Version

    1.0.9

    License

    MIT

    Unpacked Size

    607 kB

    Total Files

    87

    Last publish

    Collaborators

    • free3