JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q27558F
  • License MIT

isomorphic undici fetch

Package Exports

  • isomorphic-undici

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (isomorphic-undici) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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