diff --git a/.github/ISSUE_TEMPLATE/bug.yaml b/.github/ISSUE_TEMPLATE/bug.yaml index 75678124cb4..cb2cefd937e 100644 --- a/.github/ISSUE_TEMPLATE/bug.yaml +++ b/.github/ISSUE_TEMPLATE/bug.yaml @@ -53,7 +53,7 @@ body: id: system-info attributes: label: System Info - description: Output of `npx envinfo --system --npmPackages '{vite,undici,typescript,@builder.io/*}' --binaries --browsers` + description: Output of `npx envinfo --system --npmPackages '{vite,typescript,@builder.io/*}' --binaries --browsers` render: shell placeholder: System, Binaries, Browsers validations: diff --git a/package.json b/package.json index 76398c6babb..60bc6479142 100644 --- a/package.json +++ b/package.json @@ -29,15 +29,6 @@ ], "pinVersion": "1.40.0" } - ], - "semverGroups": [ - { - "label": "Undici should always be * until we remove it", - "range": "*", - "dependencies": [ - "undici" - ] - } ] } }, @@ -123,7 +114,6 @@ "terser": "^5.31.0", "tsm": "^2.3.0", "typescript": "5.4.5", - "undici": "*", "vfile": "^6.0.1", "vite": "^5.2.11", "vite-imagetools": "^6.2.9", @@ -135,7 +125,7 @@ "zod": "^3.23.8" }, "engines": { - "node": ">=16.8.0 <18.0.0 || >=18.11", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", "npm": "please-use-pnpm", "yarn": "please-use-pnpm", "pnpm": ">=9.0.5" diff --git a/packages/docs/contributors.ts b/packages/docs/contributors.ts index 0550f4b40d7..22877e9bcfa 100644 --- a/packages/docs/contributors.ts +++ b/packages/docs/contributors.ts @@ -1,5 +1,4 @@ /* eslint-disable no-console */ -import { fetch } from 'undici'; import fs from 'node:fs'; import path from 'node:path'; import url from 'node:url'; diff --git a/packages/docs/package.json b/packages/docs/package.json index 7b97896fb02..fd750c2e5a2 100644 --- a/packages/docs/package.json +++ b/packages/docs/package.json @@ -43,14 +43,13 @@ "terser": "^5.31.0", "tsm": "^2.3.0", "typescript": "5.4.5", - "undici": "*", "valibot": "^0.29.0", "vite": "^5.2.11", "vite-plugin-inspect": "^0.8.4", "wrangler": "^3.53.1" }, "engines": { - "node": ">=18.11", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", "npm": "please-use-pnpm", "yarn": "please-use-pnpm", "pnpm": ">=8.6.12" diff --git a/packages/docs/scripts/showcase.js b/packages/docs/scripts/showcase.js index 74064e92901..9eaea2e4887 100644 --- a/packages/docs/scripts/showcase.js +++ b/packages/docs/scripts/showcase.js @@ -134,7 +134,6 @@ async function captureMultipleScreenshots() { } async function getPagespeedData(url) { - const { fetch } = await import('undici'); const requestURL = `https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=${encodeURIComponent( url )}&key=AIzaSyApBC9gblaCzWrtEBgHnZkd_B37OF49BfM&category=PERFORMANCE&strategy=MOBILE`; diff --git a/packages/eslint-plugin-qwik/package.json b/packages/eslint-plugin-qwik/package.json index 89eb597d917..5bb95f09d20 100644 --- a/packages/eslint-plugin-qwik/package.json +++ b/packages/eslint-plugin-qwik/package.json @@ -17,7 +17,7 @@ "redent": "^4.0.0" }, "engines": { - "node": ">=16.8.0 <18.0.0 || >=18.11" + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" }, "homepage": "https://github.com/QwikDev/qwik#readme", "keywords": [ diff --git a/packages/insights/package.json b/packages/insights/package.json index 8b0165dd359..95d51542c0c 100644 --- a/packages/insights/package.json +++ b/packages/insights/package.json @@ -35,13 +35,12 @@ "prettier-plugin-tailwindcss": "^0.5.14", "tailwindcss": "^3.4.3", "typescript": "5.4.5", - "undici": "*", "vite": "^5.2.11", "vite-tsconfig-paths": "^4.3.2", "vitest": "^1.6.0" }, "engines": { - "node": ">=16.8.0 <18.0.0 || >=18.11" + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" }, "private": true, "scripts": { diff --git a/packages/qwik-auth/package.json b/packages/qwik-auth/package.json index ae967b2b9cd..42c0cf06cfb 100644 --- a/packages/qwik-auth/package.json +++ b/packages/qwik-auth/package.json @@ -14,7 +14,7 @@ "set-cookie-parser": "^2.6.0" }, "engines": { - "node": ">=16.8.0 <18.0.0 || >=18.11" + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" }, "exports": { ".": { diff --git a/packages/qwik-city/buildtime/vite/plugin.ts b/packages/qwik-city/buildtime/vite/plugin.ts index 2dd8a9a5352..775ffd07190 100644 --- a/packages/qwik-city/buildtime/vite/plugin.ts +++ b/packages/qwik-city/buildtime/vite/plugin.ts @@ -13,7 +13,6 @@ import { build } from '../build'; import { ssrDevMiddleware, staticDistMiddleware } from './dev-server'; import { transformMenu } from '../markdown/menu'; import { generateQwikCityEntries } from '../runtime-generation/generate-entries'; -import { patchGlobalThis } from '../../middleware/node/node-fetch'; import type { QwikVitePlugin } from '@builder.io/qwik/optimizer'; import fs from 'node:fs'; import { @@ -42,9 +41,6 @@ function qwikCityPlugin(userOpts?: QwikCityVitePluginOptions): any { let ssrFormat: 'esm' | 'cjs' = 'esm'; let outDir: string | null = null; - // Patch Stream APIs - patchGlobalThis(); - globalThis.__qwikCityNew = true; const api: QwikCityPluginApi = { diff --git a/packages/qwik-city/middleware/node/index.ts b/packages/qwik-city/middleware/node/index.ts index 1e53e714d31..0461cf43ff9 100644 --- a/packages/qwik-city/middleware/node/index.ts +++ b/packages/qwik-city/middleware/node/index.ts @@ -12,7 +12,6 @@ import { extname, join, basename } from 'node:path'; import { fileURLToPath } from 'node:url'; import { computeOrigin, fromNodeHttp, getUrl } from './http'; import { MIME_TYPES } from '../request-handler/mime-types'; -import { patchGlobalThis } from './node-fetch'; import { _deserializeData, _serializeData, _verifySerializable } from '@builder.io/qwik'; import type { Http2ServerRequest } from 'node:http2'; @@ -20,9 +19,6 @@ import type { Http2ServerRequest } from 'node:http2'; /** @public */ export function createQwikCity(opts: QwikCityNodeRequestOptions) { - // Patch Stream APIs - patchGlobalThis(); - const qwikSerializer = { _deserializeData, _serializeData, diff --git a/packages/qwik-city/middleware/node/node-fetch.ts b/packages/qwik-city/middleware/node/node-fetch.ts deleted file mode 100644 index 328a1b6002e..00000000000 --- a/packages/qwik-city/middleware/node/node-fetch.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { - TextEncoderStream, - TextDecoderStream, - WritableStream, - ReadableStream, -} from 'node:stream/web'; -import { fetch, Headers, Request, Response, FormData } from 'undici'; - -import crypto from 'crypto'; - -// TODO: remove when undici is removed -export function patchGlobalThis() { - if ( - typeof global !== 'undefined' && - typeof globalThis.fetch !== 'function' && - typeof process !== 'undefined' && - process.versions.node - ) { - globalThis.fetch = fetch as any; - globalThis.Headers = Headers as any; - globalThis.Request = Request as any; - globalThis.Response = Response as any; - globalThis.FormData = FormData as any; - } - if (typeof globalThis.TextEncoderStream === 'undefined') { - // @ts-ignore - globalThis.TextEncoderStream = TextEncoderStream; - // @ts-ignore - globalThis.TextDecoderStream = TextDecoderStream; - } - if (typeof globalThis.WritableStream === 'undefined') { - globalThis.WritableStream = WritableStream as any; - globalThis.ReadableStream = ReadableStream as any; - } - if (typeof globalThis.crypto === 'undefined') { - globalThis.crypto = crypto.webcrypto as any; - } -} diff --git a/packages/qwik-city/package.json b/packages/qwik-city/package.json index 0b34fc73234..e0090dfd79c 100644 --- a/packages/qwik-city/package.json +++ b/packages/qwik-city/package.json @@ -8,7 +8,6 @@ "@types/mdx": "^2.0.13", "source-map": "0.7.4", "svgo": "^3.2.0", - "undici": "*", "vfile": "^6.0.1", "vite": "^5.2.11", "vite-imagetools": "^6.2.9", @@ -43,7 +42,7 @@ "yaml": "^2.4.2" }, "engines": { - "node": ">=16.8.0 <18.0.0 || >=18.11" + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" }, "exports": { ".": { diff --git a/packages/qwik-city/runtime/src/service-worker/utils.unit.ts b/packages/qwik-city/runtime/src/service-worker/utils.unit.ts index 5e2b14000ee..565cf9c0337 100644 --- a/packages/qwik-city/runtime/src/service-worker/utils.unit.ts +++ b/packages/qwik-city/runtime/src/service-worker/utils.unit.ts @@ -1,4 +1,3 @@ -import { Request as NodeRequest, Response as NodeResponse } from 'undici'; import type { AppBundle } from './types'; import { getCacheToDelete, isAppBundleRequest, useCache } from './utils'; import { assert, test } from 'vitest'; @@ -75,9 +74,9 @@ test('useCache', () => { export function mockRequest(url?: string): Request { url = url || 'https://qwik.dev/'; - return new NodeRequest(url) as any; + return new Request(url); } export function mockResponse(body?: any): Response { - return new NodeResponse(body) as any; + return new Response(body); } diff --git a/packages/qwik-city/static/node/index.ts b/packages/qwik-city/static/node/index.ts index 337cf468980..4f31e3ab603 100644 --- a/packages/qwik-city/static/node/index.ts +++ b/packages/qwik-city/static/node/index.ts @@ -3,7 +3,6 @@ import { createSystem } from './node-system'; import { isMainThread, workerData } from 'node:worker_threads'; import { mainThread } from '../main-thread'; import { workerThread } from '../worker-thread'; -import { patchGlobalThis } from 'packages/qwik-city/middleware/node/node-fetch'; export async function generate(opts: StaticGenerateOptions) { if (isMainThread) { @@ -17,8 +16,6 @@ export async function generate(opts: StaticGenerateOptions) { if (!isMainThread && workerData) { (async () => { - patchGlobalThis(); - // self initializing worker thread with workerData const sys = await createSystem(workerData); await workerThread(sys); diff --git a/packages/qwik-city/static/node/node-system.ts b/packages/qwik-city/static/node/node-system.ts index 14904b15f54..1a49d3b11c6 100644 --- a/packages/qwik-city/static/node/node-system.ts +++ b/packages/qwik-city/static/node/node-system.ts @@ -2,15 +2,12 @@ import type { StaticGenerateOptions, System } from '../types'; import fs from 'node:fs'; import { dirname, join } from 'node:path'; -import { patchGlobalThis } from '../../middleware/node/node-fetch'; import { createNodeMainProcess } from './node-main'; import { createNodeWorkerProcess } from './node-worker'; import { normalizePath } from '../../utils/fs'; /** @public */ export async function createSystem(opts: StaticGenerateOptions) { - patchGlobalThis(); - const createWriteStream = (filePath: string) => { return fs.createWriteStream(filePath, { flags: 'w', diff --git a/packages/qwik-labs/package.json b/packages/qwik-labs/package.json index 5978743698f..70dc3a71f55 100644 --- a/packages/qwik-labs/package.json +++ b/packages/qwik-labs/package.json @@ -13,11 +13,10 @@ "np": "^10.0.5", "prettier": "^3.2.5", "typescript": "5.4.5", - "undici": "*", "vite": "^5.2.11" }, "engines": { - "node": ">=16.8.0 <18.0.0 || >=18.11" + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" }, "exports": { ".": { diff --git a/packages/qwik-react/package.json b/packages/qwik-react/package.json index 977e36c29c3..0853b5f3164 100644 --- a/packages/qwik-react/package.json +++ b/packages/qwik-react/package.json @@ -13,7 +13,7 @@ "vite": "^5.2.10" }, "engines": { - "node": ">=16.8.0 <18.0.0 || >=18.11" + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" }, "exports": { ".": { diff --git a/packages/qwik-worker/package.json b/packages/qwik-worker/package.json index 0d8b0eef1a1..cbe6f502e96 100644 --- a/packages/qwik-worker/package.json +++ b/packages/qwik-worker/package.json @@ -9,7 +9,7 @@ "vite-plugin-static-copy": "^1.0.4" }, "engines": { - "node": ">=16.8.0 <18.0.0 || >=18.11" + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" }, "exports": { ".": { diff --git a/packages/qwik/package.json b/packages/qwik/package.json index 415f29a8655..fa0e177da2b 100644 --- a/packages/qwik/package.json +++ b/packages/qwik/package.json @@ -33,7 +33,7 @@ "kleur": "4.1.5" }, "engines": { - "node": ">=16.8.0 <18.0.0 || >=18.11" + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" }, "exports": { ".": { diff --git a/packages/qwik/src/cli/utils/utils.ts b/packages/qwik/src/cli/utils/utils.ts index 020c64840c7..8cd032a7a47 100644 --- a/packages/qwik/src/cli/utils/utils.ts +++ b/packages/qwik/src/cli/utils/utils.ts @@ -81,7 +81,7 @@ export function cleanPackageJson(srcPkg: IntegrationPackageJson) { types: srcPkg.types, exports: srcPkg.exports, files: srcPkg.files, - engines: { node: '^18.17.0 || ^20.3.0 || >=21.0.0' }, + engines: { node: srcPkg.engines?.node || '^18.17.0 || ^20.3.0 || >=21.0.0' }, }; Object.keys(cleanedPkg).forEach((prop) => { diff --git a/packages/qwik/src/optimizer/src/plugins/vite-server.ts b/packages/qwik/src/optimizer/src/plugins/vite-server.ts index 4849c913302..24589ce9498 100644 --- a/packages/qwik/src/optimizer/src/plugins/vite-server.ts +++ b/packages/qwik/src/optimizer/src/plugins/vite-server.ts @@ -35,22 +35,9 @@ export async function configureDevServer( isClientDevOnly: boolean, clientDevInput: string | undefined ) { - if (typeof fetch !== 'function' && sys.env === 'node') { - // polyfill fetch() when not available in Node.js - - try { - if (!globalThis.fetch) { - const undici = await sys.strictDynamicImport('undici'); - globalThis.fetch = undici.fetch; - globalThis.Headers = undici.Headers; - globalThis.Request = undici.Request; - globalThis.Response = undici.Response; - globalThis.FormData = undici.FormData; - } - } catch { - console.warn('Global fetch() was not installed'); - // Nothing - } + if (typeof fetch !== 'function') { + console.error('Global fetch() is missing'); + process.exit(1); } // qwik middleware injected BEFORE vite internal middlewares diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f1a51d38aa7..3fe3de97d97 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -206,9 +206,6 @@ importers: typescript: specifier: 5.4.5 version: 5.4.5 - undici: - specifier: '*' - version: 6.18.2 vfile: specifier: ^6.0.1 version: 6.0.1 @@ -368,9 +365,6 @@ importers: typescript: specifier: 5.4.5 version: 5.4.5 - undici: - specifier: '*' - version: 6.18.2 valibot: specifier: ^0.29.0 version: 0.29.0 @@ -505,9 +499,6 @@ importers: typescript: specifier: 5.4.5 version: 5.4.5 - undici: - specifier: '*' - version: 6.18.2 vite: specifier: ^5.2.11 version: 5.2.12(@types/node@20.14.1)(terser@5.31.0) @@ -573,9 +564,6 @@ importers: svgo: specifier: ^3.2.0 version: 3.3.2 - undici: - specifier: '*' - version: 6.18.2 vfile: specifier: ^6.0.1 version: 6.0.1 @@ -702,9 +690,6 @@ importers: typescript: specifier: 5.4.5 version: 5.4.5 - undici: - specifier: '*' - version: 6.18.2 vite: specifier: ^5.2.11 version: 5.2.12(@types/node@20.14.1)(terser@5.31.0) diff --git a/scripts/create-qwik-cli.ts b/scripts/create-qwik-cli.ts index 4d5d09e7e23..b2cd1ccb5b3 100644 --- a/scripts/create-qwik-cli.ts +++ b/scripts/create-qwik-cli.ts @@ -217,7 +217,6 @@ async function updatePackageJson(config: BuildConfig, destDir: string) { setVersionFromRoot('prettier'); setVersionFromRoot('typescript'); setVersionFromRoot('node-fetch'); - setVersionFromRoot('undici'); setVersionFromRoot('vite'); await writePackageJson(destDir, pkgJson); diff --git a/scripts/package-json.ts b/scripts/package-json.ts index eb32aebc586..50c4a0e20b3 100644 --- a/scripts/package-json.ts +++ b/scripts/package-json.ts @@ -21,9 +21,6 @@ export async function generatePackageJson(config: BuildConfig) { qwik: './qwik-cli.cjs', }, type: 'module', - peerDependencies: { - undici: '*', - }, dependencies: rootPkg.dependencies, exports: recursiveChangePrefix(rootPkg.exports!, './dist/', './'), files: Array.from(new Set(rootPkg.files)).sort((a, b) => { diff --git a/starters/adapters/firebase/functions/package.json b/starters/adapters/firebase/functions/package.json index 030d2f83728..d2d34508ec5 100755 --- a/starters/adapters/firebase/functions/package.json +++ b/starters/adapters/firebase/functions/package.json @@ -9,15 +9,14 @@ "logs": "firebase functions:log" }, "engines": { - "node": "18" + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" }, "type": "module", "main": "index.js", "dependencies": { "@google-cloud/functions-framework": "^3.3.0", "firebase-admin": "^11.8.0", - "firebase-functions": "^4.3.1", - "undici": "*" + "firebase-functions": "^4.3.1" }, "devDependencies": { "firebase-functions-test": "^3.1.0" diff --git a/starters/apps/base/package.json b/starters/apps/base/package.json index b6cab10066c..d19f861f2dc 100644 --- a/starters/apps/base/package.json +++ b/starters/apps/base/package.json @@ -26,7 +26,6 @@ "eslint-plugin-qwik": "latest", "prettier": "latest", "typescript": "latest", - "undici": "latest", "vite": "^4.5.2", "vite-tsconfig-paths": "^4.2.1" }, diff --git a/starters/apps/library/package.json b/starters/apps/library/package.json index 1fec5dc0978..0c388d2a471 100644 --- a/starters/apps/library/package.json +++ b/starters/apps/library/package.json @@ -43,7 +43,6 @@ "np": "^8.0.4", "prettier": "latest", "typescript": "latest", - "undici": "latest", "vite": "^4.5.2", "vite-tsconfig-paths": "^4.2.1" }, diff --git a/starters/dev-server.ts b/starters/dev-server.ts index 379da438f88..b94a64b94eb 100644 --- a/starters/dev-server.ts +++ b/starters/dev-server.ts @@ -332,8 +332,6 @@ function favicon(_: Request, res: Response) { } async function main() { - await patchGlobalFetch(); - const partytownPath = resolve( startersDir, "..", @@ -371,23 +369,3 @@ async function main() { } main(); - -async function patchGlobalFetch() { - if ( - typeof global !== "undefined" && - typeof globalThis.fetch !== "function" && - typeof process !== "undefined" && - process.versions.node - ) { - if (!globalThis.fetch) { - const { fetch, Headers, Request, Response, FormData } = await import( - "undici" - ); - globalThis.fetch = fetch as any; - globalThis.Headers = Headers as any; - globalThis.Request = Request as any; - globalThis.Response = Response as any; - globalThis.FormData = FormData as any; - } - } -} diff --git a/tsm.cjs b/tsm.cjs index f4eedc6d7cb..b5aff3a5154 100644 --- a/tsm.cjs +++ b/tsm.cjs @@ -16,21 +16,6 @@ globalThis.qDev = true; globalThis.qInspector = false; import * as qwikJsx from "${corePath}";`; -if ( - typeof global !== 'undefined' && - typeof globalThis.fetch !== 'function' && - typeof process !== 'undefined' && - process.versions.node -) { - if (!globalThis.fetch) { - const { fetch, Headers, Request, Response, FormData } = require('undici'); - globalThis.fetch = fetch; - globalThis.Headers = Headers; - globalThis.Request = Request; - globalThis.Response = Response; - globalThis.FormData = FormData; - } -} module.exports = { common: { minifyWhitespace: true,