From 69ea7b94434e2a3746e6ad1477d122a8d4075c76 Mon Sep 17 00:00:00 2001 From: Ethan Arrowood Date: Wed, 11 Oct 2023 10:25:22 -0600 Subject: [PATCH 1/3] hopefully this fixes it for good (#2338) --- .github/workflows/publish-undici-types.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-undici-types.yml b/.github/workflows/publish-undici-types.yml index 95209964336..3579907a992 100644 --- a/.github/workflows/publish-undici-types.yml +++ b/.github/workflows/publish-undici-types.yml @@ -1,3 +1,5 @@ +name: Publish undici-types + on: push: tags: @@ -18,7 +20,7 @@ jobs: registry-url: 'https://registry.npmjs.org' - run: npm install - run: node scripts/generate-undici-types-package-json.js - - run: cd types - run: npm publish + working-directory: './types' env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} From 7bcb80c0a22509ceba1b786847faba5aded1bea0 Mon Sep 17 00:00:00 2001 From: Khafra Date: Wed, 11 Oct 2023 14:24:46 -0400 Subject: [PATCH 2/3] Fix node detection omfg (#2341) * fix node detection * remove comment * change name * fix regex for windows paths --- lib/fetch/index.js | 2 +- package.json | 3 ++- scripts/esbuild-build.mjs | 24 ++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 scripts/esbuild-build.mjs diff --git a/lib/fetch/index.js b/lib/fetch/index.js index 8c98a646a0e..c89c9b7ffcb 100644 --- a/lib/fetch/index.js +++ b/lib/fetch/index.js @@ -1344,7 +1344,7 @@ async function httpNetworkOrCacheFetch ( // user agents should append `User-Agent`/default `User-Agent` value to // httpRequest’s header list. if (!httpRequest.headersList.contains('user-agent')) { - httpRequest.headersList.append('user-agent', __filename.endsWith('index.js') ? 'undici' : 'node') + httpRequest.headersList.append('user-agent', typeof esbuildDetection === 'undefined' ? 'undici' : 'node') } // 15. If httpRequest’s cache mode is "default" and httpRequest’s header diff --git a/package.json b/package.json index a780bc10376..3436db5fe86 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "docs" ], "scripts": { - "build:node": "npx esbuild@0.14.38 index-fetch.js --bundle --platform=node --outfile=undici-fetch.js", + "build:node": "node scripts/esbuild-build.mjs", "prebuild:wasm": "node build/wasm.js --prebuild", "build:wasm": "node build/wasm.js --docker", "lint": "standard | snazzy", @@ -109,6 +109,7 @@ "delay": "^5.0.0", "dns-packet": "^5.4.0", "docsify-cli": "^4.4.3", + "esbuild": "^0.19.4", "form-data": "^4.0.0", "formdata-node": "^4.3.1", "https-pem": "^3.0.0", diff --git a/scripts/esbuild-build.mjs b/scripts/esbuild-build.mjs new file mode 100644 index 00000000000..ca5886c1a2b --- /dev/null +++ b/scripts/esbuild-build.mjs @@ -0,0 +1,24 @@ +import * as esbuild from 'esbuild' +import fs from 'node:fs' + +const bundle = { + name: 'bundle', + setup (build) { + build.onLoad({ filter: /lib(\/|\\)fetch(\/|\\)index.js/ }, async (args) => { + const text = await fs.promises.readFile(args.path, 'utf8') + + return { + contents: `var esbuildDetection = 1;${text}`, + loader: 'js' + } + }) + } +} + +await esbuild.build({ + entryPoints: ['index-fetch.js'], + bundle: true, + outfile: 'undici-fetch.js', + plugins: [bundle], + platform: 'node' +}) From c8c80b1115d668664d8cf3acec7535b0258c3079 Mon Sep 17 00:00:00 2001 From: Ethan Arrowood Date: Wed, 11 Oct 2023 12:25:50 -0600 Subject: [PATCH 3/3] 5.26.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3436db5fe86..b68fcfc58e3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "undici", - "version": "5.26.0", + "version": "5.26.1", "description": "An HTTP/1.1 client, written from scratch for Node.js", "homepage": "https://undici.nodejs.org", "bugs": {