Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Remove undici, set minimum node version to 18.17 #5702

Merged
merged 1 commit into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 1 addition & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,6 @@
],
"pinVersion": "1.40.0"
}
],
"semverGroups": [
{
"label": "Undici should always be * until we remove it",
"range": "*",
"dependencies": [
"undici"
]
}
]
}
},
Expand Down Expand Up @@ -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",
Expand All @@ -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"
Expand Down
1 change: 0 additions & 1 deletion packages/docs/contributors.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
3 changes: 1 addition & 2 deletions packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion packages/docs/scripts/showcase.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-qwik/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
3 changes: 1 addition & 2 deletions packages/insights/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
".": {
Expand Down
4 changes: 0 additions & 4 deletions packages/qwik-city/buildtime/vite/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 = {
Expand Down
4 changes: 0 additions & 4 deletions packages/qwik-city/middleware/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,13 @@ 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';

// @builder.io/qwik-city/middleware/node

/** @public */
export function createQwikCity(opts: QwikCityNodeRequestOptions) {
// Patch Stream APIs
patchGlobalThis();

const qwikSerializer = {
_deserializeData,
_serializeData,
Expand Down
38 changes: 0 additions & 38 deletions packages/qwik-city/middleware/node/node-fetch.ts

This file was deleted.

3 changes: 1 addition & 2 deletions packages/qwik-city/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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": {
".": {
Expand Down
5 changes: 2 additions & 3 deletions packages/qwik-city/runtime/src/service-worker/utils.unit.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
}
3 changes: 0 additions & 3 deletions packages/qwik-city/static/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
3 changes: 0 additions & 3 deletions packages/qwik-city/static/node/node-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 1 addition & 2 deletions packages/qwik-labs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
".": {
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
".": {
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
".": {
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
".": {
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik/src/cli/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
19 changes: 3 additions & 16 deletions packages/qwik/src/optimizer/src/plugins/vite-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 0 additions & 15 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion scripts/create-qwik-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 0 additions & 3 deletions scripts/package-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
Loading
Loading