@utoo/pack 1.3.2-alpha.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/commands/dev.js +1 -6
- package/config_schema.json +280 -225
- package/esm/commands/dev.js +1 -6
- package/package.json +9 -10
- package/cjs/core/proxy-hono.d.ts +0 -29
- package/cjs/core/proxy-hono.js +0 -96
- package/esm/core/proxy-hono.d.ts +0 -29
- package/esm/core/proxy-hono.js +0 -89
package/cjs/commands/dev.js
CHANGED
|
@@ -18,7 +18,6 @@ const https_1 = __importDefault(require("https"));
|
|
|
18
18
|
const path_1 = __importDefault(require("path"));
|
|
19
19
|
const webpackCompat_1 = require("../config/webpackCompat");
|
|
20
20
|
const hmr_1 = require("../core/hmr");
|
|
21
|
-
const proxy_hono_1 = require("../core/proxy-hono");
|
|
22
21
|
const common_1 = require("../utils/common");
|
|
23
22
|
const findRoot_1 = require("../utils/findRoot");
|
|
24
23
|
const mkcert_1 = require("../utils/mkcert");
|
|
@@ -139,7 +138,7 @@ function serve(options, projectPath, rootPath, serverOptions) {
|
|
|
139
138
|
}
|
|
140
139
|
const HMR_PATH = "/turbopack-hmr";
|
|
141
140
|
async function runDev(options, projectPath, rootPath, serverOptions) {
|
|
142
|
-
var _a, _b, _d, _e
|
|
141
|
+
var _a, _b, _d, _e;
|
|
143
142
|
(0, common_1.blockStdout)();
|
|
144
143
|
process.title = "utoopack-dev-server";
|
|
145
144
|
if (process.env.XCODE_PROFILE) {
|
|
@@ -191,10 +190,6 @@ async function runDev(options, projectPath, rootPath, serverOptions) {
|
|
|
191
190
|
console.error("HMR WebSocket error", err);
|
|
192
191
|
},
|
|
193
192
|
})));
|
|
194
|
-
const proxyRules = (_g = (_f = bundleOptions.config) === null || _f === void 0 ? void 0 : _f.devServer) === null || _g === void 0 ? void 0 : _g.proxy;
|
|
195
|
-
if (proxyRules && proxyRules.length > 0) {
|
|
196
|
-
app.use("*", (0, proxy_hono_1.createHttpProxyMiddleware)(proxyRules));
|
|
197
|
-
}
|
|
198
193
|
// GET handles HEAD automatically in Hono; serveStatic serves both
|
|
199
194
|
app.get("/*", (0, serve_static_1.serveStatic)({
|
|
200
195
|
root: distRoot,
|
package/config_schema.json
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"title": "
|
|
4
|
-
"description": "Top-level
|
|
3
|
+
"title": "CompleteConfig",
|
|
4
|
+
"description": "Top-level configuration for utoopack.json This represents the JSON config file structure, aligned with pack-core's `Config` struct.",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"properties": {
|
|
7
|
-
"buildId": {
|
|
8
|
-
"description": "The build id.",
|
|
9
|
-
"type": [
|
|
10
|
-
"string",
|
|
11
|
-
"null"
|
|
12
|
-
]
|
|
13
|
-
},
|
|
14
7
|
"cacheHandler": {
|
|
15
8
|
"description": "Cache handler configuration",
|
|
16
9
|
"type": [
|
|
@@ -26,24 +19,6 @@
|
|
|
26
19
|
],
|
|
27
20
|
"additionalProperties": true
|
|
28
21
|
},
|
|
29
|
-
"defineEnv": {
|
|
30
|
-
"description": "A map of environment variables which should get injected at compile time.",
|
|
31
|
-
"anyOf": [
|
|
32
|
-
{
|
|
33
|
-
"$ref": "#/definitions/SchemaDefineEnv"
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"type": "null"
|
|
37
|
-
}
|
|
38
|
-
]
|
|
39
|
-
},
|
|
40
|
-
"dev": {
|
|
41
|
-
"description": "Whether to run in development mode",
|
|
42
|
-
"type": [
|
|
43
|
-
"boolean",
|
|
44
|
-
"null"
|
|
45
|
-
]
|
|
46
|
-
},
|
|
47
22
|
"devServer": {
|
|
48
23
|
"description": "Development server configuration",
|
|
49
24
|
"anyOf": [
|
|
@@ -144,13 +119,6 @@
|
|
|
144
119
|
}
|
|
145
120
|
]
|
|
146
121
|
},
|
|
147
|
-
"packPath": {
|
|
148
|
-
"description": "Absolute path for @utoo/pack",
|
|
149
|
-
"type": [
|
|
150
|
-
"string",
|
|
151
|
-
"null"
|
|
152
|
-
]
|
|
153
|
-
},
|
|
154
122
|
"persistentCaching": {
|
|
155
123
|
"description": "Enable persistent caching",
|
|
156
124
|
"type": [
|
|
@@ -158,21 +126,25 @@
|
|
|
158
126
|
"null"
|
|
159
127
|
]
|
|
160
128
|
},
|
|
161
|
-
"
|
|
162
|
-
"description": "
|
|
129
|
+
"provider": {
|
|
130
|
+
"description": "Provider (ProvidePlugin) configuration",
|
|
163
131
|
"type": [
|
|
164
132
|
"object",
|
|
165
133
|
"null"
|
|
166
134
|
],
|
|
167
135
|
"additionalProperties": {
|
|
168
|
-
"
|
|
136
|
+
"$ref": "#/definitions/SchemaProviderConfigValue"
|
|
169
137
|
}
|
|
170
138
|
},
|
|
171
|
-
"
|
|
172
|
-
"description": "
|
|
173
|
-
"
|
|
174
|
-
|
|
175
|
-
|
|
139
|
+
"react": {
|
|
140
|
+
"description": "React configuration",
|
|
141
|
+
"anyOf": [
|
|
142
|
+
{
|
|
143
|
+
"$ref": "#/definitions/SchemaReactConfig"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"type": "null"
|
|
147
|
+
}
|
|
176
148
|
]
|
|
177
149
|
},
|
|
178
150
|
"resolve": {
|
|
@@ -186,13 +158,6 @@
|
|
|
186
158
|
}
|
|
187
159
|
]
|
|
188
160
|
},
|
|
189
|
-
"rootPath": {
|
|
190
|
-
"description": "A root path from which all files must be nested under.",
|
|
191
|
-
"type": [
|
|
192
|
-
"string",
|
|
193
|
-
"null"
|
|
194
|
-
]
|
|
195
|
-
},
|
|
196
161
|
"sourceMaps": {
|
|
197
162
|
"description": "Enable source maps",
|
|
198
163
|
"type": [
|
|
@@ -224,36 +189,152 @@
|
|
|
224
189
|
"string",
|
|
225
190
|
"null"
|
|
226
191
|
]
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
"definitions": {
|
|
195
|
+
"SchemaConfigConditionContentType": {
|
|
196
|
+
"description": "Configuration condition for content type",
|
|
197
|
+
"oneOf": [
|
|
231
198
|
{
|
|
232
|
-
"
|
|
199
|
+
"description": "Glob pattern for content type matching",
|
|
200
|
+
"type": "object",
|
|
201
|
+
"required": [
|
|
202
|
+
"type",
|
|
203
|
+
"value"
|
|
204
|
+
],
|
|
205
|
+
"properties": {
|
|
206
|
+
"type": {
|
|
207
|
+
"type": "string",
|
|
208
|
+
"enum": [
|
|
209
|
+
"glob"
|
|
210
|
+
]
|
|
211
|
+
},
|
|
212
|
+
"value": {
|
|
213
|
+
"type": "string"
|
|
214
|
+
}
|
|
215
|
+
}
|
|
233
216
|
},
|
|
234
217
|
{
|
|
235
|
-
"
|
|
218
|
+
"description": "Regex match for content type",
|
|
219
|
+
"type": "object",
|
|
220
|
+
"required": [
|
|
221
|
+
"type",
|
|
222
|
+
"value"
|
|
223
|
+
],
|
|
224
|
+
"properties": {
|
|
225
|
+
"type": {
|
|
226
|
+
"type": "string",
|
|
227
|
+
"enum": [
|
|
228
|
+
"regex"
|
|
229
|
+
]
|
|
230
|
+
},
|
|
231
|
+
"value": {
|
|
232
|
+
"$ref": "#/definitions/SchemaRegexComponents"
|
|
233
|
+
}
|
|
234
|
+
}
|
|
236
235
|
}
|
|
237
236
|
]
|
|
238
|
-
}
|
|
239
|
-
},
|
|
240
|
-
"definitions": {
|
|
237
|
+
},
|
|
241
238
|
"SchemaConfigConditionItem": {
|
|
242
|
-
"description": "Configuration condition item",
|
|
243
|
-
"
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
"
|
|
251
|
-
{
|
|
252
|
-
"
|
|
239
|
+
"description": "Configuration condition item — supports compound conditions (all/any/not) and base conditions with path, content, query, and contentType matchers.",
|
|
240
|
+
"anyOf": [
|
|
241
|
+
{
|
|
242
|
+
"description": "All conditions must match",
|
|
243
|
+
"type": "object",
|
|
244
|
+
"required": [
|
|
245
|
+
"all"
|
|
246
|
+
],
|
|
247
|
+
"properties": {
|
|
248
|
+
"all": {
|
|
249
|
+
"type": "array",
|
|
250
|
+
"items": {
|
|
251
|
+
"$ref": "#/definitions/SchemaConfigConditionItem"
|
|
252
|
+
}
|
|
253
253
|
}
|
|
254
|
-
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
"description": "Any condition must match",
|
|
258
|
+
"type": "object",
|
|
259
|
+
"required": [
|
|
260
|
+
"any"
|
|
261
|
+
],
|
|
262
|
+
"properties": {
|
|
263
|
+
"any": {
|
|
264
|
+
"type": "array",
|
|
265
|
+
"items": {
|
|
266
|
+
"$ref": "#/definitions/SchemaConfigConditionItem"
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
"description": "Negate a condition",
|
|
273
|
+
"type": "object",
|
|
274
|
+
"required": [
|
|
275
|
+
"not"
|
|
276
|
+
],
|
|
277
|
+
"properties": {
|
|
278
|
+
"not": {
|
|
279
|
+
"$ref": "#/definitions/SchemaConfigConditionItem"
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
"description": "Base condition with path/content/query/contentType matchers",
|
|
285
|
+
"type": "object",
|
|
286
|
+
"properties": {
|
|
287
|
+
"content": {
|
|
288
|
+
"description": "Content regex",
|
|
289
|
+
"anyOf": [
|
|
290
|
+
{
|
|
291
|
+
"$ref": "#/definitions/SchemaRegexComponents"
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
"type": "null"
|
|
295
|
+
}
|
|
296
|
+
]
|
|
297
|
+
},
|
|
298
|
+
"contentType": {
|
|
299
|
+
"description": "Content type condition",
|
|
300
|
+
"anyOf": [
|
|
301
|
+
{
|
|
302
|
+
"$ref": "#/definitions/SchemaConfigConditionContentType"
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
"type": "null"
|
|
306
|
+
}
|
|
307
|
+
]
|
|
308
|
+
},
|
|
309
|
+
"path": {
|
|
310
|
+
"description": "Path condition",
|
|
311
|
+
"anyOf": [
|
|
312
|
+
{
|
|
313
|
+
"$ref": "#/definitions/SchemaConfigConditionPath"
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
"type": "null"
|
|
317
|
+
}
|
|
318
|
+
]
|
|
319
|
+
},
|
|
320
|
+
"query": {
|
|
321
|
+
"description": "Query condition",
|
|
322
|
+
"anyOf": [
|
|
323
|
+
{
|
|
324
|
+
"$ref": "#/definitions/SchemaConfigConditionQuery"
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
"type": "null"
|
|
328
|
+
}
|
|
329
|
+
]
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
"description": "Built-in condition (e.g., \"server\", \"client\", \"edge\")",
|
|
335
|
+
"type": "string"
|
|
255
336
|
}
|
|
256
|
-
|
|
337
|
+
]
|
|
257
338
|
},
|
|
258
339
|
"SchemaConfigConditionPath": {
|
|
259
340
|
"description": "Configuration condition path",
|
|
@@ -298,6 +379,49 @@
|
|
|
298
379
|
}
|
|
299
380
|
]
|
|
300
381
|
},
|
|
382
|
+
"SchemaConfigConditionQuery": {
|
|
383
|
+
"description": "Configuration condition for query strings",
|
|
384
|
+
"oneOf": [
|
|
385
|
+
{
|
|
386
|
+
"description": "Constant string match for query",
|
|
387
|
+
"type": "object",
|
|
388
|
+
"required": [
|
|
389
|
+
"type",
|
|
390
|
+
"value"
|
|
391
|
+
],
|
|
392
|
+
"properties": {
|
|
393
|
+
"type": {
|
|
394
|
+
"type": "string",
|
|
395
|
+
"enum": [
|
|
396
|
+
"constant"
|
|
397
|
+
]
|
|
398
|
+
},
|
|
399
|
+
"value": {
|
|
400
|
+
"type": "string"
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
"description": "Regex match for query",
|
|
406
|
+
"type": "object",
|
|
407
|
+
"required": [
|
|
408
|
+
"type",
|
|
409
|
+
"value"
|
|
410
|
+
],
|
|
411
|
+
"properties": {
|
|
412
|
+
"type": {
|
|
413
|
+
"type": "string",
|
|
414
|
+
"enum": [
|
|
415
|
+
"regex"
|
|
416
|
+
]
|
|
417
|
+
},
|
|
418
|
+
"value": {
|
|
419
|
+
"$ref": "#/definitions/SchemaRegexComponents"
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
]
|
|
424
|
+
},
|
|
301
425
|
"SchemaCopyItem": {
|
|
302
426
|
"description": "Copy item configuration Can be either a string (source path) or an object with from and optional to",
|
|
303
427
|
"anyOf": [
|
|
@@ -327,42 +451,6 @@
|
|
|
327
451
|
}
|
|
328
452
|
]
|
|
329
453
|
},
|
|
330
|
-
"SchemaDefineEnv": {
|
|
331
|
-
"description": "Environment variables for build-time injection",
|
|
332
|
-
"type": "object",
|
|
333
|
-
"properties": {
|
|
334
|
-
"client": {
|
|
335
|
-
"description": "Client-side environment variables",
|
|
336
|
-
"type": [
|
|
337
|
-
"array",
|
|
338
|
-
"null"
|
|
339
|
-
],
|
|
340
|
-
"items": {
|
|
341
|
-
"$ref": "#/definitions/SchemaEnvVar"
|
|
342
|
-
}
|
|
343
|
-
},
|
|
344
|
-
"edge": {
|
|
345
|
-
"description": "Edge-side environment variables",
|
|
346
|
-
"type": [
|
|
347
|
-
"array",
|
|
348
|
-
"null"
|
|
349
|
-
],
|
|
350
|
-
"items": {
|
|
351
|
-
"$ref": "#/definitions/SchemaEnvVar"
|
|
352
|
-
}
|
|
353
|
-
},
|
|
354
|
-
"nodejs": {
|
|
355
|
-
"description": "Node.js environment variables",
|
|
356
|
-
"type": [
|
|
357
|
-
"array",
|
|
358
|
-
"null"
|
|
359
|
-
],
|
|
360
|
-
"items": {
|
|
361
|
-
"$ref": "#/definitions/SchemaEnvVar"
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
},
|
|
366
454
|
"SchemaDevServer": {
|
|
367
455
|
"description": "Development server configuration",
|
|
368
456
|
"type": "object",
|
|
@@ -418,88 +506,30 @@
|
|
|
418
506
|
}
|
|
419
507
|
}
|
|
420
508
|
},
|
|
421
|
-
"SchemaEnvVar": {
|
|
422
|
-
"description": "Environment variable pair",
|
|
423
|
-
"type": "object",
|
|
424
|
-
"required": [
|
|
425
|
-
"name",
|
|
426
|
-
"value"
|
|
427
|
-
],
|
|
428
|
-
"properties": {
|
|
429
|
-
"name": {
|
|
430
|
-
"description": "Variable name",
|
|
431
|
-
"type": "string"
|
|
432
|
-
},
|
|
433
|
-
"value": {
|
|
434
|
-
"description": "Variable value",
|
|
435
|
-
"type": "string"
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
},
|
|
439
509
|
"SchemaExperimentalConfig": {
|
|
440
510
|
"description": "Experimental features configuration",
|
|
441
511
|
"type": "object",
|
|
442
512
|
"properties": {
|
|
443
|
-
"cacheHandlers": {
|
|
444
|
-
"description": "Cache handlers",
|
|
445
|
-
"type": [
|
|
446
|
-
"object",
|
|
447
|
-
"null"
|
|
448
|
-
],
|
|
449
|
-
"additionalProperties": {
|
|
450
|
-
"type": "string"
|
|
451
|
-
}
|
|
452
|
-
},
|
|
453
|
-
"dynamicIO": {
|
|
454
|
-
"description": "Dynamic IO",
|
|
455
|
-
"type": [
|
|
456
|
-
"boolean",
|
|
457
|
-
"null"
|
|
458
|
-
]
|
|
459
|
-
},
|
|
460
|
-
"esmExternals": {
|
|
461
|
-
"description": "ESM externals"
|
|
462
|
-
},
|
|
463
|
-
"mdxRs": {
|
|
464
|
-
"description": "MDX-RS options"
|
|
465
|
-
},
|
|
466
|
-
"ppr": {
|
|
467
|
-
"description": "Partial prerendering"
|
|
468
|
-
},
|
|
469
513
|
"reactCompiler": {
|
|
470
514
|
"description": "React compiler"
|
|
471
515
|
},
|
|
472
|
-
"serverActions": {
|
|
473
|
-
"description": "Server actions"
|
|
474
|
-
},
|
|
475
516
|
"swcPlugins": {
|
|
476
|
-
"description": "SWC plugins",
|
|
517
|
+
"description": "SWC plugins as [path, options] tuples",
|
|
477
518
|
"type": [
|
|
478
519
|
"array",
|
|
479
520
|
"null"
|
|
480
521
|
],
|
|
481
|
-
"items":
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
"type": [
|
|
493
|
-
"boolean",
|
|
494
|
-
"null"
|
|
495
|
-
]
|
|
496
|
-
},
|
|
497
|
-
"viewTransition": {
|
|
498
|
-
"description": "View transition",
|
|
499
|
-
"type": [
|
|
500
|
-
"boolean",
|
|
501
|
-
"null"
|
|
502
|
-
]
|
|
522
|
+
"items": {
|
|
523
|
+
"type": "array",
|
|
524
|
+
"items": [
|
|
525
|
+
{
|
|
526
|
+
"type": "string"
|
|
527
|
+
},
|
|
528
|
+
true
|
|
529
|
+
],
|
|
530
|
+
"maxItems": 2,
|
|
531
|
+
"minItems": 2
|
|
532
|
+
}
|
|
503
533
|
}
|
|
504
534
|
}
|
|
505
535
|
},
|
|
@@ -549,7 +579,7 @@
|
|
|
549
579
|
"description": "External dependency configuration",
|
|
550
580
|
"anyOf": [
|
|
551
581
|
{
|
|
552
|
-
"description": "Simple string external (e.g.,
|
|
582
|
+
"description": "Simple string external (e.g., \"react\" -> \"React\")",
|
|
553
583
|
"type": "string"
|
|
554
584
|
},
|
|
555
585
|
{
|
|
@@ -815,16 +845,6 @@
|
|
|
815
845
|
"description": "Module configuration",
|
|
816
846
|
"type": "object",
|
|
817
847
|
"properties": {
|
|
818
|
-
"conditions": {
|
|
819
|
-
"description": "Module conditions configuration",
|
|
820
|
-
"type": [
|
|
821
|
-
"object",
|
|
822
|
-
"null"
|
|
823
|
-
],
|
|
824
|
-
"additionalProperties": {
|
|
825
|
-
"$ref": "#/definitions/SchemaConfigConditionItem"
|
|
826
|
-
}
|
|
827
|
-
},
|
|
828
848
|
"rules": {
|
|
829
849
|
"description": "Module rules configuration",
|
|
830
850
|
"type": [
|
|
@@ -961,14 +981,14 @@
|
|
|
961
981
|
]
|
|
962
982
|
},
|
|
963
983
|
"removeUnusedExports": {
|
|
964
|
-
"description": "Whether to remove unused exports",
|
|
984
|
+
"description": "Whether to remove unused exports. Defaults to false in development, true in production.",
|
|
965
985
|
"type": [
|
|
966
986
|
"boolean",
|
|
967
987
|
"null"
|
|
968
988
|
]
|
|
969
989
|
},
|
|
970
990
|
"removeUnusedImports": {
|
|
971
|
-
"description": "Whether to remove unused imports",
|
|
991
|
+
"description": "Whether to remove unused imports. Defaults to false in development, true in production.",
|
|
972
992
|
"type": [
|
|
973
993
|
"boolean",
|
|
974
994
|
"null"
|
|
@@ -1002,7 +1022,7 @@
|
|
|
1002
1022
|
]
|
|
1003
1023
|
},
|
|
1004
1024
|
"wasmAsAsset": {
|
|
1005
|
-
"description": "Whether to
|
|
1025
|
+
"description": "Whether to bundle WASM as asset. Defaults to false. When false, WASM files will be output as static assets.",
|
|
1006
1026
|
"type": [
|
|
1007
1027
|
"boolean",
|
|
1008
1028
|
"null"
|
|
@@ -1014,8 +1034,15 @@
|
|
|
1014
1034
|
"description": "Output configuration",
|
|
1015
1035
|
"type": "object",
|
|
1016
1036
|
"properties": {
|
|
1037
|
+
"assetModuleFilename": {
|
|
1038
|
+
"description": "Filename pattern for asset modules (images, fonts, etc.)",
|
|
1039
|
+
"type": [
|
|
1040
|
+
"string",
|
|
1041
|
+
"null"
|
|
1042
|
+
]
|
|
1043
|
+
},
|
|
1017
1044
|
"chunkFilename": {
|
|
1018
|
-
"description": "Filename pattern for chunk files",
|
|
1045
|
+
"description": "Filename pattern for JS chunk files",
|
|
1019
1046
|
"type": [
|
|
1020
1047
|
"string",
|
|
1021
1048
|
"null"
|
|
@@ -1045,6 +1072,20 @@
|
|
|
1045
1072
|
"$ref": "#/definitions/SchemaCopyItem"
|
|
1046
1073
|
}
|
|
1047
1074
|
},
|
|
1075
|
+
"cssChunkFilename": {
|
|
1076
|
+
"description": "Filename pattern for CSS chunk files",
|
|
1077
|
+
"type": [
|
|
1078
|
+
"string",
|
|
1079
|
+
"null"
|
|
1080
|
+
]
|
|
1081
|
+
},
|
|
1082
|
+
"cssFilename": {
|
|
1083
|
+
"description": "Filename pattern for main CSS files",
|
|
1084
|
+
"type": [
|
|
1085
|
+
"string",
|
|
1086
|
+
"null"
|
|
1087
|
+
]
|
|
1088
|
+
},
|
|
1048
1089
|
"entryRootExport": {
|
|
1049
1090
|
"description": "Expose entry module exports to global scope with the specified name. When set, all named exports from the entry module will be available on window/globalThis under the specified name. If set to empty string, will use package.json name. Default: None (no exposure)",
|
|
1050
1091
|
"type": [
|
|
@@ -1053,7 +1094,7 @@
|
|
|
1053
1094
|
]
|
|
1054
1095
|
},
|
|
1055
1096
|
"filename": {
|
|
1056
|
-
"description": "Filename pattern for main files",
|
|
1097
|
+
"description": "Filename pattern for main JS files",
|
|
1057
1098
|
"type": [
|
|
1058
1099
|
"string",
|
|
1059
1100
|
"null"
|
|
@@ -1066,6 +1107,13 @@
|
|
|
1066
1107
|
"null"
|
|
1067
1108
|
]
|
|
1068
1109
|
},
|
|
1110
|
+
"publicPath": {
|
|
1111
|
+
"description": "URL prefix prepended to all chunk and asset URLs. Use 'runtime' for runtime-resolved public path.",
|
|
1112
|
+
"type": [
|
|
1113
|
+
"string",
|
|
1114
|
+
"null"
|
|
1115
|
+
]
|
|
1116
|
+
},
|
|
1069
1117
|
"type": {
|
|
1070
1118
|
"description": "Output type",
|
|
1071
1119
|
"anyOf": [
|
|
@@ -1087,6 +1135,42 @@
|
|
|
1087
1135
|
"export"
|
|
1088
1136
|
]
|
|
1089
1137
|
},
|
|
1138
|
+
"SchemaProviderConfigValue": {
|
|
1139
|
+
"description": "Provider configuration value. Can be a simple module name string or a [module, export] tuple.",
|
|
1140
|
+
"anyOf": [
|
|
1141
|
+
{
|
|
1142
|
+
"description": "Simple module import, e.g. \"jquery\"",
|
|
1143
|
+
"type": "string"
|
|
1144
|
+
},
|
|
1145
|
+
{
|
|
1146
|
+
"description": "Named export import, e.g. [\"buffer\", \"Buffer\"]",
|
|
1147
|
+
"type": "array",
|
|
1148
|
+
"items": {
|
|
1149
|
+
"type": "string"
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
]
|
|
1153
|
+
},
|
|
1154
|
+
"SchemaReactConfig": {
|
|
1155
|
+
"description": "React configuration",
|
|
1156
|
+
"type": "object",
|
|
1157
|
+
"properties": {
|
|
1158
|
+
"importSource": {
|
|
1159
|
+
"description": "Custom JSX import source",
|
|
1160
|
+
"type": [
|
|
1161
|
+
"string",
|
|
1162
|
+
"null"
|
|
1163
|
+
]
|
|
1164
|
+
},
|
|
1165
|
+
"runtime": {
|
|
1166
|
+
"description": "JSX runtime to use (automatic or classic)",
|
|
1167
|
+
"type": [
|
|
1168
|
+
"string",
|
|
1169
|
+
"null"
|
|
1170
|
+
]
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
},
|
|
1090
1174
|
"SchemaRegexComponents": {
|
|
1091
1175
|
"description": "Regular expression components",
|
|
1092
1176
|
"type": "object",
|
|
@@ -1241,6 +1325,9 @@
|
|
|
1241
1325
|
"less": {
|
|
1242
1326
|
"description": "Less configuration"
|
|
1243
1327
|
},
|
|
1328
|
+
"postcss": {
|
|
1329
|
+
"description": "Inline PostCSS configuration"
|
|
1330
|
+
},
|
|
1244
1331
|
"sass": {
|
|
1245
1332
|
"description": "Sass configuration"
|
|
1246
1333
|
},
|
|
@@ -1274,38 +1361,6 @@
|
|
|
1274
1361
|
}
|
|
1275
1362
|
}
|
|
1276
1363
|
]
|
|
1277
|
-
},
|
|
1278
|
-
"SchemaWatchOptions": {
|
|
1279
|
-
"description": "Filesystem watcher options",
|
|
1280
|
-
"type": "object",
|
|
1281
|
-
"required": [
|
|
1282
|
-
"enable"
|
|
1283
|
-
],
|
|
1284
|
-
"properties": {
|
|
1285
|
-
"enable": {
|
|
1286
|
-
"description": "Whether to watch the filesystem for file changes.",
|
|
1287
|
-
"type": "boolean"
|
|
1288
|
-
},
|
|
1289
|
-
"ignored": {
|
|
1290
|
-
"description": "Paths to ignore when watching for file changes. By default, ignores: node_modules",
|
|
1291
|
-
"type": [
|
|
1292
|
-
"array",
|
|
1293
|
-
"null"
|
|
1294
|
-
],
|
|
1295
|
-
"items": {
|
|
1296
|
-
"type": "string"
|
|
1297
|
-
}
|
|
1298
|
-
},
|
|
1299
|
-
"pollInterval": {
|
|
1300
|
-
"description": "Enable polling at a certain interval if the native file watching doesn't work (e.g. docker).",
|
|
1301
|
-
"type": [
|
|
1302
|
-
"integer",
|
|
1303
|
-
"null"
|
|
1304
|
-
],
|
|
1305
|
-
"format": "uint64",
|
|
1306
|
-
"minimum": 0.0
|
|
1307
|
-
}
|
|
1308
|
-
}
|
|
1309
1364
|
}
|
|
1310
1365
|
}
|
|
1311
1366
|
}
|
package/esm/commands/dev.js
CHANGED
|
@@ -12,7 +12,6 @@ import https from "https";
|
|
|
12
12
|
import path from "path";
|
|
13
13
|
import { resolveBundleOptions, } from "../config/webpackCompat.js";
|
|
14
14
|
import { createHotReloader } from "../core/hmr.js";
|
|
15
|
-
import { createHttpProxyMiddleware } from "../core/proxy-hono.js";
|
|
16
15
|
import { blockStdout, getPackPath } from "../utils/common.js";
|
|
17
16
|
import { findRootDir } from "../utils/findRoot.js";
|
|
18
17
|
import { createSelfSignedCertificate } from "../utils/mkcert.js";
|
|
@@ -133,7 +132,7 @@ export function serve(options, projectPath, rootPath, serverOptions) {
|
|
|
133
132
|
}
|
|
134
133
|
const HMR_PATH = "/turbopack-hmr";
|
|
135
134
|
async function runDev(options, projectPath, rootPath, serverOptions) {
|
|
136
|
-
var _a, _b, _d, _e
|
|
135
|
+
var _a, _b, _d, _e;
|
|
137
136
|
blockStdout();
|
|
138
137
|
process.title = "utoopack-dev-server";
|
|
139
138
|
if (process.env.XCODE_PROFILE) {
|
|
@@ -185,10 +184,6 @@ async function runDev(options, projectPath, rootPath, serverOptions) {
|
|
|
185
184
|
console.error("HMR WebSocket error", err);
|
|
186
185
|
},
|
|
187
186
|
})));
|
|
188
|
-
const proxyRules = (_g = (_f = bundleOptions.config) === null || _f === void 0 ? void 0 : _f.devServer) === null || _g === void 0 ? void 0 : _g.proxy;
|
|
189
|
-
if (proxyRules && proxyRules.length > 0) {
|
|
190
|
-
app.use("*", createHttpProxyMiddleware(proxyRules));
|
|
191
|
-
}
|
|
192
187
|
// GET handles HEAD automatically in Hono; serveStatic serves both
|
|
193
188
|
app.get("/*", serveStatic({
|
|
194
189
|
root: distRoot,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@utoo/pack",
|
|
3
|
-
"version": "1.3.2
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"main": "cjs/index.js",
|
|
5
5
|
"module": "esm/index.js",
|
|
6
6
|
"types": "esm/index.d.ts",
|
|
@@ -41,8 +41,7 @@
|
|
|
41
41
|
"@hono/node-server": "^1.19.11",
|
|
42
42
|
"@hono/node-ws": "^1.3.0",
|
|
43
43
|
"@swc/helpers": "0.5.15",
|
|
44
|
-
"@utoo/pack-shared": "1.3.2
|
|
45
|
-
"@utoo/style-loader": "^1.0.0",
|
|
44
|
+
"@utoo/pack-shared": "1.3.2",
|
|
46
45
|
"domparser-rs": "^0.0.7",
|
|
47
46
|
"find-up": "4.1.0",
|
|
48
47
|
"get-port": "^7.1.0",
|
|
@@ -90,12 +89,12 @@
|
|
|
90
89
|
},
|
|
91
90
|
"repository": "git@github.com:utooland/utoo.git",
|
|
92
91
|
"optionalDependencies": {
|
|
93
|
-
"@utoo/pack-darwin-arm64": "1.3.2
|
|
94
|
-
"@utoo/pack-darwin-x64": "1.3.2
|
|
95
|
-
"@utoo/pack-linux-arm64-gnu": "1.3.2
|
|
96
|
-
"@utoo/pack-linux-arm64-musl": "1.3.2
|
|
97
|
-
"@utoo/pack-linux-x64-gnu": "1.3.2
|
|
98
|
-
"@utoo/pack-linux-x64-musl": "1.3.2
|
|
99
|
-
"@utoo/pack-win32-x64-msvc": "1.3.2
|
|
92
|
+
"@utoo/pack-darwin-arm64": "1.3.2",
|
|
93
|
+
"@utoo/pack-darwin-x64": "1.3.2",
|
|
94
|
+
"@utoo/pack-linux-arm64-gnu": "1.3.2",
|
|
95
|
+
"@utoo/pack-linux-arm64-musl": "1.3.2",
|
|
96
|
+
"@utoo/pack-linux-x64-gnu": "1.3.2",
|
|
97
|
+
"@utoo/pack-linux-x64-musl": "1.3.2",
|
|
98
|
+
"@utoo/pack-win32-x64-msvc": "1.3.2"
|
|
100
99
|
}
|
|
101
100
|
}
|
package/cjs/core/proxy-hono.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTTP proxy middleware for Hono dev server.
|
|
3
|
-
* Matches ProxyRule by path, applies pathRewrite, and forwards via Hono proxy().
|
|
4
|
-
* No generic WS proxying in this module.
|
|
5
|
-
*/
|
|
6
|
-
import type { DevServerProxy, PathRewrite, ProxyRule } from "@utoo/pack-shared";
|
|
7
|
-
import type { Context, Next } from "hono";
|
|
8
|
-
/** Path prefix or ^-prefixed regex match (regex tests full path). */
|
|
9
|
-
export declare function doesContextMatchUrl(context: string, pathOrUrl: string): boolean;
|
|
10
|
-
export declare function ruleMatchesUrl(rule: ProxyRule, pathOrUrl: string): boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Apply pathRewrite (http-proxy-middleware style).
|
|
13
|
-
* Object: first matching regex → replace, then stop. Function: (path) => new path.
|
|
14
|
-
*/
|
|
15
|
-
export declare function applyPathRewrite(path: string, pathRewrite?: PathRewrite): string;
|
|
16
|
-
export interface PreparedProxyRequest {
|
|
17
|
-
url: URL;
|
|
18
|
-
headers: Headers;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Build target URL and headers for the proxy request from current context and rule.
|
|
22
|
-
*/
|
|
23
|
-
export declare function prepareProxyRequest(c: Context, rule: ProxyRule): PreparedProxyRequest;
|
|
24
|
-
/**
|
|
25
|
-
* Hono middleware: on match, proxy to rule.target with pathRewrite and changeOrigin;
|
|
26
|
-
* on error return 502; otherwise next().
|
|
27
|
-
* Caller (e.g. dev.ts) must pass a non-empty array; empty array means no rule matches.
|
|
28
|
-
*/
|
|
29
|
-
export declare function createHttpProxyMiddleware(rules: DevServerProxy): (c: Context, next: Next) => Promise<void | Response>;
|
package/cjs/core/proxy-hono.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* HTTP proxy middleware for Hono dev server.
|
|
4
|
-
* Matches ProxyRule by path, applies pathRewrite, and forwards via Hono proxy().
|
|
5
|
-
* No generic WS proxying in this module.
|
|
6
|
-
*/
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.doesContextMatchUrl = doesContextMatchUrl;
|
|
9
|
-
exports.ruleMatchesUrl = ruleMatchesUrl;
|
|
10
|
-
exports.applyPathRewrite = applyPathRewrite;
|
|
11
|
-
exports.prepareProxyRequest = prepareProxyRequest;
|
|
12
|
-
exports.createHttpProxyMiddleware = createHttpProxyMiddleware;
|
|
13
|
-
const proxy_1 = require("hono/proxy");
|
|
14
|
-
/** Path prefix or ^-prefixed regex match (regex tests full path). */
|
|
15
|
-
function doesContextMatchUrl(context, pathOrUrl) {
|
|
16
|
-
if (context[0] === "^") {
|
|
17
|
-
try {
|
|
18
|
-
return new RegExp(context).test(pathOrUrl);
|
|
19
|
-
}
|
|
20
|
-
catch (_a) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return pathOrUrl === context || pathOrUrl.startsWith(context + "/");
|
|
25
|
-
}
|
|
26
|
-
function ruleMatchesUrl(rule, pathOrUrl) {
|
|
27
|
-
const contexts = Array.isArray(rule.context) ? rule.context : [rule.context];
|
|
28
|
-
return contexts.some((ctx) => doesContextMatchUrl(ctx, pathOrUrl));
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Apply pathRewrite (http-proxy-middleware style).
|
|
32
|
-
* Object: first matching regex → replace, then stop. Function: (path) => new path.
|
|
33
|
-
*/
|
|
34
|
-
function applyPathRewrite(path, pathRewrite) {
|
|
35
|
-
if (!pathRewrite)
|
|
36
|
-
return path;
|
|
37
|
-
if (typeof pathRewrite === "function") {
|
|
38
|
-
return pathRewrite(path);
|
|
39
|
-
}
|
|
40
|
-
for (const [pattern, value] of Object.entries(pathRewrite)) {
|
|
41
|
-
try {
|
|
42
|
-
const regex = new RegExp(pattern);
|
|
43
|
-
if (regex.test(path)) {
|
|
44
|
-
return path.replace(regex, value);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
catch (_a) {
|
|
48
|
-
// invalid regex, skip
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return path;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Build target URL and headers for the proxy request from current context and rule.
|
|
55
|
-
*/
|
|
56
|
-
function prepareProxyRequest(c, rule) {
|
|
57
|
-
const origUrl = new URL(c.req.url);
|
|
58
|
-
const targetUrl = new URL(rule.target);
|
|
59
|
-
const origPath = c.req.path;
|
|
60
|
-
const rewrittenPath = applyPathRewrite(origPath, rule.pathRewrite);
|
|
61
|
-
targetUrl.pathname = rewrittenPath;
|
|
62
|
-
targetUrl.search = origUrl.search;
|
|
63
|
-
const headers = new Headers(c.req.header());
|
|
64
|
-
if (rule.changeOrigin !== false) {
|
|
65
|
-
headers.set("host", targetUrl.host);
|
|
66
|
-
}
|
|
67
|
-
return { url: targetUrl, headers };
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Hono middleware: on match, proxy to rule.target with pathRewrite and changeOrigin;
|
|
71
|
-
* on error return 502; otherwise next().
|
|
72
|
-
* Caller (e.g. dev.ts) must pass a non-empty array; empty array means no rule matches.
|
|
73
|
-
*/
|
|
74
|
-
function createHttpProxyMiddleware(rules) {
|
|
75
|
-
return async (c, next) => {
|
|
76
|
-
const rule = rules.find((r) => ruleMatchesUrl(r, c.req.path));
|
|
77
|
-
if (!rule) {
|
|
78
|
-
return next();
|
|
79
|
-
}
|
|
80
|
-
try {
|
|
81
|
-
const prepared = prepareProxyRequest(c, rule);
|
|
82
|
-
const init = {
|
|
83
|
-
method: c.req.method,
|
|
84
|
-
headers: prepared.headers,
|
|
85
|
-
};
|
|
86
|
-
if (c.req.method !== "GET" && c.req.method !== "HEAD") {
|
|
87
|
-
init.body = c.req.raw.body;
|
|
88
|
-
}
|
|
89
|
-
return (0, proxy_1.proxy)(prepared.url.toString(), init);
|
|
90
|
-
}
|
|
91
|
-
catch (err) {
|
|
92
|
-
console.error("[dev proxy] error", c.req.method, c.req.url, err);
|
|
93
|
-
return c.text("Bad Gateway", 502);
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
}
|
package/esm/core/proxy-hono.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTTP proxy middleware for Hono dev server.
|
|
3
|
-
* Matches ProxyRule by path, applies pathRewrite, and forwards via Hono proxy().
|
|
4
|
-
* No generic WS proxying in this module.
|
|
5
|
-
*/
|
|
6
|
-
import type { DevServerProxy, PathRewrite, ProxyRule } from "@utoo/pack-shared";
|
|
7
|
-
import type { Context, Next } from "hono";
|
|
8
|
-
/** Path prefix or ^-prefixed regex match (regex tests full path). */
|
|
9
|
-
export declare function doesContextMatchUrl(context: string, pathOrUrl: string): boolean;
|
|
10
|
-
export declare function ruleMatchesUrl(rule: ProxyRule, pathOrUrl: string): boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Apply pathRewrite (http-proxy-middleware style).
|
|
13
|
-
* Object: first matching regex → replace, then stop. Function: (path) => new path.
|
|
14
|
-
*/
|
|
15
|
-
export declare function applyPathRewrite(path: string, pathRewrite?: PathRewrite): string;
|
|
16
|
-
export interface PreparedProxyRequest {
|
|
17
|
-
url: URL;
|
|
18
|
-
headers: Headers;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Build target URL and headers for the proxy request from current context and rule.
|
|
22
|
-
*/
|
|
23
|
-
export declare function prepareProxyRequest(c: Context, rule: ProxyRule): PreparedProxyRequest;
|
|
24
|
-
/**
|
|
25
|
-
* Hono middleware: on match, proxy to rule.target with pathRewrite and changeOrigin;
|
|
26
|
-
* on error return 502; otherwise next().
|
|
27
|
-
* Caller (e.g. dev.ts) must pass a non-empty array; empty array means no rule matches.
|
|
28
|
-
*/
|
|
29
|
-
export declare function createHttpProxyMiddleware(rules: DevServerProxy): (c: Context, next: Next) => Promise<void | Response>;
|
package/esm/core/proxy-hono.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTTP proxy middleware for Hono dev server.
|
|
3
|
-
* Matches ProxyRule by path, applies pathRewrite, and forwards via Hono proxy().
|
|
4
|
-
* No generic WS proxying in this module.
|
|
5
|
-
*/
|
|
6
|
-
import { proxy } from "hono/proxy";
|
|
7
|
-
/** Path prefix or ^-prefixed regex match (regex tests full path). */
|
|
8
|
-
export function doesContextMatchUrl(context, pathOrUrl) {
|
|
9
|
-
if (context[0] === "^") {
|
|
10
|
-
try {
|
|
11
|
-
return new RegExp(context).test(pathOrUrl);
|
|
12
|
-
}
|
|
13
|
-
catch (_a) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return pathOrUrl === context || pathOrUrl.startsWith(context + "/");
|
|
18
|
-
}
|
|
19
|
-
export function ruleMatchesUrl(rule, pathOrUrl) {
|
|
20
|
-
const contexts = Array.isArray(rule.context) ? rule.context : [rule.context];
|
|
21
|
-
return contexts.some((ctx) => doesContextMatchUrl(ctx, pathOrUrl));
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Apply pathRewrite (http-proxy-middleware style).
|
|
25
|
-
* Object: first matching regex → replace, then stop. Function: (path) => new path.
|
|
26
|
-
*/
|
|
27
|
-
export function applyPathRewrite(path, pathRewrite) {
|
|
28
|
-
if (!pathRewrite)
|
|
29
|
-
return path;
|
|
30
|
-
if (typeof pathRewrite === "function") {
|
|
31
|
-
return pathRewrite(path);
|
|
32
|
-
}
|
|
33
|
-
for (const [pattern, value] of Object.entries(pathRewrite)) {
|
|
34
|
-
try {
|
|
35
|
-
const regex = new RegExp(pattern);
|
|
36
|
-
if (regex.test(path)) {
|
|
37
|
-
return path.replace(regex, value);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
catch (_a) {
|
|
41
|
-
// invalid regex, skip
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return path;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Build target URL and headers for the proxy request from current context and rule.
|
|
48
|
-
*/
|
|
49
|
-
export function prepareProxyRequest(c, rule) {
|
|
50
|
-
const origUrl = new URL(c.req.url);
|
|
51
|
-
const targetUrl = new URL(rule.target);
|
|
52
|
-
const origPath = c.req.path;
|
|
53
|
-
const rewrittenPath = applyPathRewrite(origPath, rule.pathRewrite);
|
|
54
|
-
targetUrl.pathname = rewrittenPath;
|
|
55
|
-
targetUrl.search = origUrl.search;
|
|
56
|
-
const headers = new Headers(c.req.header());
|
|
57
|
-
if (rule.changeOrigin !== false) {
|
|
58
|
-
headers.set("host", targetUrl.host);
|
|
59
|
-
}
|
|
60
|
-
return { url: targetUrl, headers };
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Hono middleware: on match, proxy to rule.target with pathRewrite and changeOrigin;
|
|
64
|
-
* on error return 502; otherwise next().
|
|
65
|
-
* Caller (e.g. dev.ts) must pass a non-empty array; empty array means no rule matches.
|
|
66
|
-
*/
|
|
67
|
-
export function createHttpProxyMiddleware(rules) {
|
|
68
|
-
return async (c, next) => {
|
|
69
|
-
const rule = rules.find((r) => ruleMatchesUrl(r, c.req.path));
|
|
70
|
-
if (!rule) {
|
|
71
|
-
return next();
|
|
72
|
-
}
|
|
73
|
-
try {
|
|
74
|
-
const prepared = prepareProxyRequest(c, rule);
|
|
75
|
-
const init = {
|
|
76
|
-
method: c.req.method,
|
|
77
|
-
headers: prepared.headers,
|
|
78
|
-
};
|
|
79
|
-
if (c.req.method !== "GET" && c.req.method !== "HEAD") {
|
|
80
|
-
init.body = c.req.raw.body;
|
|
81
|
-
}
|
|
82
|
-
return proxy(prepared.url.toString(), init);
|
|
83
|
-
}
|
|
84
|
-
catch (err) {
|
|
85
|
-
console.error("[dev proxy] error", c.req.method, c.req.url, err);
|
|
86
|
-
return c.text("Bad Gateway", 502);
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
}
|