Whereas everything works fine locally while vercel dev, it throws an error when I try to deploy my function using vercel deploy:
Error: The Edge Function "api/pronunciation" is referencing unsupported modules:
- @fastify: node:stream
- undici: stream, net, http, tls, querystring, stream/web, util/types, worker_threads, zlib, perf_hooks, console, url, diagnostics_channel
I have found the following comments in this repository:
|
// When bundled via a bundler supporting the `browser` field, then |
|
// the `undici` module will be replaced with https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API |
|
// for browser contexts. See ./undici-browser.js and ./package.json |
|
import { fetch } from 'undici'; |
and
|
// this file gets copied to the dist folder |
|
// it makes undici work in the browser by reusing the global fetch |
|
// it's the simplest way I've found to make http requests work in Node.js, Serverles Functions, Edge Functions, and the browser |
|
// this should work as long as this module is used via Next.js/Webpack |
|
// moving forward we will have to solve this problem in a more robust way |
|
// reusing https://github.com/inrupt/universal-fetch |
|
// or seeing how/if cross-fetch solves https://github.com/lquixada/cross-fetch/issues/69 |
|
export const fetch = globalThis.fetch.bind(globalThis); |
Am I missing any config to make vercel deploy use the browser version file?
Whereas everything works fine locally while
vercel dev, it throws an error when I try to deploy my function usingvercel deploy:I have found the following comments in this repository:
storage/packages/blob/src/client.ts
Lines 4 to 7 in 8b1ff23
and
storage/packages/blob/src/undici-browser.js
Lines 1 to 8 in 8b1ff23
Am I missing any config to make
vercel deployuse the browser version file?