File tree Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -1344,7 +1344,7 @@ async function httpNetworkOrCacheFetch (
1344
1344
// user agents should append `User-Agent`/default `User-Agent` value to
1345
1345
// httpRequest’s header list.
1346
1346
if ( ! httpRequest . headersList . contains ( 'user-agent' ) ) {
1347
- httpRequest . headersList . append ( 'user-agent' , __filename . endsWith ( 'index.js' ) ? 'undici' : 'node' )
1347
+ httpRequest . headersList . append ( 'user-agent' , typeof esbuildDetection === 'undefined' ? 'undici' : 'node' )
1348
1348
}
1349
1349
1350
1350
// 15. If httpRequest’s cache mode is "default" and httpRequest’s header
Original file line number Diff line number Diff line change 70
70
" docs"
71
71
],
72
72
"scripts" : {
73
- "build:node" : " npx esbuild@0.14.38 index-fetch.js --bundle --platform=node --outfile=undici-fetch.js " ,
73
+ "build:node" : " node scripts/ esbuild-build.mjs " ,
74
74
"prebuild:wasm" : " node build/wasm.js --prebuild" ,
75
75
"build:wasm" : " node build/wasm.js --docker" ,
76
76
"lint" : " standard | snazzy" ,
109
109
"delay" : " ^5.0.0" ,
110
110
"dns-packet" : " ^5.4.0" ,
111
111
"docsify-cli" : " ^4.4.3" ,
112
+ "esbuild" : " ^0.19.4" ,
112
113
"form-data" : " ^4.0.0" ,
113
114
"formdata-node" : " ^4.3.1" ,
114
115
"https-pem" : " ^3.0.0" ,
Original file line number Diff line number Diff line change
1
+ import * as esbuild from 'esbuild'
2
+ import fs from 'node:fs'
3
+
4
+ const bundle = {
5
+ name : 'bundle' ,
6
+ setup ( build ) {
7
+ build . onLoad ( { filter : / l i b ( \/ | \\ ) f e t c h ( \/ | \\ ) i n d e x .j s / } , async ( args ) => {
8
+ const text = await fs . promises . readFile ( args . path , 'utf8' )
9
+
10
+ return {
11
+ contents : `var esbuildDetection = 1;${ text } ` ,
12
+ loader : 'js'
13
+ }
14
+ } )
15
+ }
16
+ }
17
+
18
+ await esbuild . build ( {
19
+ entryPoints : [ 'index-fetch.js' ] ,
20
+ bundle : true ,
21
+ outfile : 'undici-fetch.js' ,
22
+ plugins : [ bundle ] ,
23
+ platform : 'node'
24
+ } )
You can’t perform that action at this time.
0 commit comments