wrangler 3.29.0 → 3.30.1
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wrangler",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.30.1",
|
|
4
4
|
"description": "Command-line interface for all things Cloudflare Workers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wrangler",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"source-map": "0.6.1",
|
|
97
97
|
"xxhash-wasm": "^1.0.1",
|
|
98
98
|
"@cloudflare/kv-asset-handler": "0.3.1",
|
|
99
|
-
"miniflare": "3.
|
|
99
|
+
"miniflare": "3.20240223.0"
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|
|
102
102
|
"@cloudflare/ai": "^1.0.35",
|
|
@@ -187,8 +187,8 @@
|
|
|
187
187
|
"yargs": "^17.7.2",
|
|
188
188
|
"yoga-layout": "file:../../vendor/yoga-layout-2.0.0-beta.1.tgz",
|
|
189
189
|
"@cloudflare/cli": "1.1.1",
|
|
190
|
-
"@cloudflare/
|
|
191
|
-
"@cloudflare/
|
|
190
|
+
"@cloudflare/pages-shared": "^0.11.15",
|
|
191
|
+
"@cloudflare/workers-tsconfig": "0.0.0"
|
|
192
192
|
},
|
|
193
193
|
"optionalDependencies": {
|
|
194
194
|
"fsevents": "~2.3.2"
|
|
@@ -220,7 +220,7 @@
|
|
|
220
220
|
"test": "pnpm run assert-git-version && jest",
|
|
221
221
|
"test:ci": "pnpm run test --coverage",
|
|
222
222
|
"test:debug": "pnpm run test --silent=false --verbose=true",
|
|
223
|
-
"test:e2e": "vitest
|
|
223
|
+
"test:e2e": "vitest -c ./e2e/vitest.config.ts",
|
|
224
224
|
"test:watch": "pnpm run test --testTimeout=50000 --watch",
|
|
225
225
|
"type:tests": "tsc -p ./src/__tests__/tsconfig.json && tsc -p ./e2e/tsconfig.json"
|
|
226
226
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Middleware } from "./common";
|
|
2
|
+
|
|
3
|
+
const drainBody: Middleware = async (request, env, _ctx, middlewareCtx) => {
|
|
4
|
+
try {
|
|
5
|
+
return await middlewareCtx.next(request, env);
|
|
6
|
+
} finally {
|
|
7
|
+
try {
|
|
8
|
+
if (request.body !== null && !request.bodyUsed) {
|
|
9
|
+
const reader = request.body.getReader();
|
|
10
|
+
while (!(await reader.read()).done) {}
|
|
11
|
+
}
|
|
12
|
+
} catch (e) {
|
|
13
|
+
console.error("Failed to drain the unused request body.", e);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default drainBody;
|
package/wrangler-dist/cli.d.ts
CHANGED
|
@@ -1360,6 +1360,13 @@ declare interface EnvironmentInheritable {
|
|
|
1360
1360
|
* @inheritable
|
|
1361
1361
|
*/
|
|
1362
1362
|
find_additional_modules: boolean | undefined;
|
|
1363
|
+
/**
|
|
1364
|
+
* Determines whether Wrangler will preserve bundled file names.
|
|
1365
|
+
* Defaults to false.
|
|
1366
|
+
* If left unset, files will be named using the pattern ${fileHash}-${basename},
|
|
1367
|
+
* for example, `34de60b44167af5c5a709e62a4e20c4f18c9e3b6-favicon.ico`.
|
|
1368
|
+
*/
|
|
1369
|
+
preserve_file_names: boolean | undefined;
|
|
1363
1370
|
/**
|
|
1364
1371
|
* The directory in which module rules should be evaluated when including additional files into a worker deployment.
|
|
1365
1372
|
* This defaults to the directory containing the `main` entry point of the worker if not specified.
|
package/wrangler-dist/cli.js
CHANGED
|
@@ -118285,7 +118285,7 @@ __name(getEnvironmentVariableFactory, "getEnvironmentVariableFactory");
|
|
|
118285
118285
|
init_import_meta_url();
|
|
118286
118286
|
var getC3CommandFromEnv = getEnvironmentVariableFactory({
|
|
118287
118287
|
variableName: "WRANGLER_C3_COMMAND",
|
|
118288
|
-
defaultValue: () => "create cloudflare@2"
|
|
118288
|
+
defaultValue: () => "create cloudflare@2.5.0"
|
|
118289
118289
|
});
|
|
118290
118290
|
var getWranglerSendMetricsFromEnv = getEnvironmentVariableFactory({
|
|
118291
118291
|
variableName: "WRANGLER_SEND_METRICS"
|
|
@@ -119643,7 +119643,7 @@ var import_node_assert2 = __toESM(require("node:assert"));
|
|
|
119643
119643
|
var import_undici3 = __toESM(require_undici());
|
|
119644
119644
|
|
|
119645
119645
|
// package.json
|
|
119646
|
-
var version = "3.
|
|
119646
|
+
var version = "3.30.1";
|
|
119647
119647
|
var package_default = {
|
|
119648
119648
|
name: "wrangler",
|
|
119649
119649
|
version,
|
|
@@ -119709,7 +119709,7 @@ var package_default = {
|
|
|
119709
119709
|
test: "pnpm run assert-git-version && jest",
|
|
119710
119710
|
"test:ci": "pnpm run test --coverage",
|
|
119711
119711
|
"test:debug": "pnpm run test --silent=false --verbose=true",
|
|
119712
|
-
"test:e2e": "vitest
|
|
119712
|
+
"test:e2e": "vitest -c ./e2e/vitest.config.ts",
|
|
119713
119713
|
"test:watch": "pnpm run test --testTimeout=50000 --watch",
|
|
119714
119714
|
"type:tests": "tsc -p ./src/__tests__/tsconfig.json && tsc -p ./e2e/tsconfig.json"
|
|
119715
119715
|
},
|
|
@@ -122557,6 +122557,14 @@ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, envNam
|
|
|
122557
122557
|
isBoolean,
|
|
122558
122558
|
void 0
|
|
122559
122559
|
),
|
|
122560
|
+
preserve_file_names: inheritable(
|
|
122561
|
+
diagnostics,
|
|
122562
|
+
topLevelEnv,
|
|
122563
|
+
rawEnv,
|
|
122564
|
+
"preserve_file_names",
|
|
122565
|
+
isBoolean,
|
|
122566
|
+
void 0
|
|
122567
|
+
),
|
|
122560
122568
|
base_dir: normalizeAndValidateBaseDirField(
|
|
122561
122569
|
configPath,
|
|
122562
122570
|
inheritable(
|
|
@@ -124991,7 +124999,7 @@ function createModuleCollector(props) {
|
|
|
124991
124999
|
);
|
|
124992
125000
|
const fileContent = await (0, import_promises2.readFile)(filePath);
|
|
124993
125001
|
const fileHash = import_node_crypto3.default.createHash("sha1").update(fileContent).digest("hex");
|
|
124994
|
-
const fileName = `./${fileHash}-${import_node_path9.default.basename(args.path)}`;
|
|
125002
|
+
const fileName = props.preserveFileNames ? args.path : `./${fileHash}-${import_node_path9.default.basename(args.path)}`;
|
|
124995
125003
|
const { rule } = rulesMatchers.find(({ regex: regex2 }) => regex2.test(fileName)) || {};
|
|
124996
125004
|
if (rule) {
|
|
124997
125005
|
modules.push({
|
|
@@ -125072,7 +125080,7 @@ function createModuleCollector(props) {
|
|
|
125072
125080
|
}
|
|
125073
125081
|
const fileContent = await (0, import_promises2.readFile)(filePath);
|
|
125074
125082
|
const fileHash = import_node_crypto3.default.createHash("sha1").update(fileContent).digest("hex");
|
|
125075
|
-
const fileName = props.preserveFileNames ?
|
|
125083
|
+
const fileName = props.preserveFileNames ? args.path : `./${fileHash}-${import_node_path9.default.basename(args.path)}`;
|
|
125076
125084
|
modules.push({
|
|
125077
125085
|
name: fileName,
|
|
125078
125086
|
filePath,
|
|
@@ -125312,6 +125320,13 @@ async function bundleWorker(entry, destination, {
|
|
|
125312
125320
|
const tmpDir = getWranglerTmpDir(projectRoot, "bundle");
|
|
125313
125321
|
const entryFile = entry.file;
|
|
125314
125322
|
const middlewareToLoad = [];
|
|
125323
|
+
if (targetConsumer === "dev" && !process.env.WRANGLER_DISABLE_REQUEST_BODY_DRAINING) {
|
|
125324
|
+
middlewareToLoad.push({
|
|
125325
|
+
name: "ensure-req-body-drained",
|
|
125326
|
+
path: "templates/middleware/middleware-ensure-req-body-drained.ts",
|
|
125327
|
+
supports: ["modules", "service-worker"]
|
|
125328
|
+
});
|
|
125329
|
+
}
|
|
125315
125330
|
if (targetConsumer === "dev" && !!testScheduled) {
|
|
125316
125331
|
middlewareToLoad.push({
|
|
125317
125332
|
name: "scheduled",
|
|
@@ -161297,6 +161312,21 @@ function getHostFromUrl(urlLike) {
|
|
|
161297
161312
|
}
|
|
161298
161313
|
}
|
|
161299
161314
|
__name(getHostFromUrl, "getHostFromUrl");
|
|
161315
|
+
async function getZoneIdForPreview(host, routes) {
|
|
161316
|
+
let zoneId;
|
|
161317
|
+
if (host) {
|
|
161318
|
+
zoneId = await getZoneIdFromHost(host);
|
|
161319
|
+
}
|
|
161320
|
+
if (!zoneId && routes) {
|
|
161321
|
+
const firstRoute = routes[0];
|
|
161322
|
+
const zone = await getZoneForRoute(firstRoute);
|
|
161323
|
+
if (zone) {
|
|
161324
|
+
zoneId = zone.id;
|
|
161325
|
+
}
|
|
161326
|
+
}
|
|
161327
|
+
return zoneId;
|
|
161328
|
+
}
|
|
161329
|
+
__name(getZoneIdForPreview, "getZoneIdForPreview");
|
|
161300
161330
|
async function getZoneIdFromHost(host) {
|
|
161301
161331
|
const hostPieces = host.split(".");
|
|
161302
161332
|
while (hostPieces.length > 1) {
|
|
@@ -161310,7 +161340,10 @@ async function getZoneIdFromHost(host) {
|
|
|
161310
161340
|
}
|
|
161311
161341
|
hostPieces.shift();
|
|
161312
161342
|
}
|
|
161313
|
-
throw new UserError(
|
|
161343
|
+
throw new UserError(
|
|
161344
|
+
`Could not find zone for \`${host}\`. Make sure the domain is set up to be proxied by Cloudflare.
|
|
161345
|
+
For more details, refer to https://developers.cloudflare.com/workers/configuration/routing/routes/#set-up-a-route`
|
|
161346
|
+
);
|
|
161314
161347
|
}
|
|
161315
161348
|
__name(getZoneIdFromHost, "getZoneIdFromHost");
|
|
161316
161349
|
async function getRoutesForZone(zone) {
|
|
@@ -163542,8 +163575,6 @@ async function initHandler(args) {
|
|
|
163542
163575
|
...yesFlag && isNpm(packageManager) ? ["-y"] : [],
|
|
163543
163576
|
// --yes arg for npx
|
|
163544
163577
|
...isNpm(packageManager) ? ["--"] : [],
|
|
163545
|
-
"--type",
|
|
163546
|
-
"pre-existing",
|
|
163547
163578
|
"--existing-script",
|
|
163548
163579
|
fromDashWorkerName
|
|
163549
163580
|
];
|
|
@@ -164983,7 +165014,8 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
|
164983
165014
|
// `moduleCollector` doesn't get used when `props.noBundle` is set, so
|
|
164984
165015
|
// `findAdditionalModules` always defaults to `false`
|
|
164985
165016
|
findAdditionalModules: config.find_additional_modules ?? false,
|
|
164986
|
-
rules: props.rules
|
|
165017
|
+
rules: props.rules,
|
|
165018
|
+
preserveFileNames: config.preserve_file_names ?? false
|
|
164987
165019
|
});
|
|
164988
165020
|
const { modules, dependencies, resolvedEntryPointPath, bundleType } = props.noBundle ? await noBundleWorker2(props.entry, props.rules, props.outDir) : await bundleWorker(
|
|
164989
165021
|
props.entry,
|
|
@@ -165523,9 +165555,9 @@ function randomId() {
|
|
|
165523
165555
|
});
|
|
165524
165556
|
}
|
|
165525
165557
|
__name(randomId, "randomId");
|
|
165526
|
-
function switchHost(originalUrl, host) {
|
|
165558
|
+
function switchHost(originalUrl, host, zonePreview) {
|
|
165527
165559
|
const url4 = new import_node_url14.URL(originalUrl);
|
|
165528
|
-
url4.hostname = host ?? url4.hostname;
|
|
165560
|
+
url4.hostname = zonePreview ? host ?? url4.hostname : url4.hostname;
|
|
165529
165561
|
return url4;
|
|
165530
165562
|
}
|
|
165531
165563
|
__name(switchHost, "switchHost");
|
|
@@ -165538,7 +165570,11 @@ async function createPreviewSession(account, ctx, abortSignal) {
|
|
|
165538
165570
|
void 0,
|
|
165539
165571
|
abortSignal
|
|
165540
165572
|
);
|
|
165541
|
-
const switchedExchangeUrl = switchHost(
|
|
165573
|
+
const switchedExchangeUrl = switchHost(
|
|
165574
|
+
exchange_url,
|
|
165575
|
+
ctx.host,
|
|
165576
|
+
!!ctx.zone
|
|
165577
|
+
).toString();
|
|
165542
165578
|
logger.debugWithSanitization(
|
|
165543
165579
|
"-- START EXCHANGE API REQUEST:",
|
|
165544
165580
|
` GET ${switchedExchangeUrl}`
|
|
@@ -165556,16 +165592,26 @@ async function createPreviewSession(account, ctx, abortSignal) {
|
|
|
165556
165592
|
logger.debug("HEADERS:", JSON.stringify(exchangeResponse.headers, null, 2));
|
|
165557
165593
|
logger.debugWithSanitization("RESPONSE:", bodyText);
|
|
165558
165594
|
logger.debug("-- END EXCHANGE API RESPONSE");
|
|
165559
|
-
|
|
165560
|
-
|
|
165561
|
-
|
|
165562
|
-
|
|
165563
|
-
|
|
165564
|
-
|
|
165565
|
-
|
|
165566
|
-
|
|
165567
|
-
|
|
165568
|
-
|
|
165595
|
+
try {
|
|
165596
|
+
const { inspector_websocket, prewarm, token } = parseJSON(bodyText);
|
|
165597
|
+
const inspector = new import_node_url14.URL(inspector_websocket);
|
|
165598
|
+
inspector.searchParams.append("cf_workers_preview_token", token);
|
|
165599
|
+
return {
|
|
165600
|
+
id: randomId(),
|
|
165601
|
+
value: token,
|
|
165602
|
+
host: ctx.host ?? inspector.host,
|
|
165603
|
+
inspectorUrl: switchHost(inspector.href, ctx.host, !!ctx.zone),
|
|
165604
|
+
prewarmUrl: switchHost(prewarm, ctx.host, !!ctx.zone)
|
|
165605
|
+
};
|
|
165606
|
+
} catch (e3) {
|
|
165607
|
+
if (!(e3 instanceof ParseError)) {
|
|
165608
|
+
throw e3;
|
|
165609
|
+
} else {
|
|
165610
|
+
throw new UserError(
|
|
165611
|
+
`Could not create remote preview session on ${ctx.zone ? ` host \`${ctx.host}\` on zone \`${ctx.zone}\`` : `your account`}.`
|
|
165612
|
+
);
|
|
165613
|
+
}
|
|
165614
|
+
}
|
|
165569
165615
|
}
|
|
165570
165616
|
__name(createPreviewSession, "createPreviewSession");
|
|
165571
165617
|
async function createPreviewToken(account, worker, ctx, session, abortSignal) {
|
|
@@ -166054,7 +166100,6 @@ function Remote(props) {
|
|
|
166054
166100
|
usageModel: props.usageModel,
|
|
166055
166101
|
env: props.env,
|
|
166056
166102
|
legacyEnv: props.legacyEnv,
|
|
166057
|
-
zone: props.zone,
|
|
166058
166103
|
host: props.host,
|
|
166059
166104
|
routes: props.routes,
|
|
166060
166105
|
onReady: props.onReady,
|
|
@@ -166109,15 +166154,16 @@ function useWorker(props) {
|
|
|
166109
166154
|
if (props.accountId === void 0) {
|
|
166110
166155
|
return;
|
|
166111
166156
|
}
|
|
166112
|
-
const { workerAccount, workerContext } = getWorkerAccountAndContext(
|
|
166113
|
-
|
|
166114
|
-
|
|
166115
|
-
|
|
166116
|
-
|
|
166117
|
-
|
|
166118
|
-
|
|
166119
|
-
|
|
166120
|
-
|
|
166157
|
+
const { workerAccount, workerContext } = await getWorkerAccountAndContext(
|
|
166158
|
+
{
|
|
166159
|
+
accountId: props.accountId,
|
|
166160
|
+
env: props.env,
|
|
166161
|
+
legacyEnv: props.legacyEnv,
|
|
166162
|
+
host: props.host,
|
|
166163
|
+
routes: props.routes,
|
|
166164
|
+
sendMetrics: props.sendMetrics
|
|
166165
|
+
}
|
|
166166
|
+
);
|
|
166121
166167
|
setSession(
|
|
166122
166168
|
await createPreviewSession(
|
|
166123
166169
|
workerAccount,
|
|
@@ -166135,6 +166181,13 @@ function useWorker(props) {
|
|
|
166135
166181
|
logger.error(`${errorMessage}
|
|
166136
166182
|
${solutionMessage}
|
|
166137
166183
|
${onboardingLink}`);
|
|
166184
|
+
} else if (err.cause?.code === "ENOTFOUND") {
|
|
166185
|
+
logger.error(
|
|
166186
|
+
`Could not access \`${err.cause.hostname}\`. Make sure the domain is set up to be proxied by Cloudflare.
|
|
166187
|
+
For more details, refer to https://developers.cloudflare.com/workers/configuration/routing/routes/#set-up-a-route`
|
|
166188
|
+
);
|
|
166189
|
+
} else if (err instanceof UserError) {
|
|
166190
|
+
logger.error(err.message);
|
|
166138
166191
|
} else if (err.code !== "ABORT_ERR") {
|
|
166139
166192
|
logger.error("Error while creating remote dev session:", err);
|
|
166140
166193
|
}
|
|
@@ -166148,7 +166201,6 @@ ${onboardingLink}`);
|
|
|
166148
166201
|
props.host,
|
|
166149
166202
|
props.legacyEnv,
|
|
166150
166203
|
props.routes,
|
|
166151
|
-
props.zone,
|
|
166152
166204
|
props.sendMetrics,
|
|
166153
166205
|
restartCounter
|
|
166154
166206
|
]);
|
|
@@ -166184,15 +166236,16 @@ ${onboardingLink}`);
|
|
|
166184
166236
|
compatibilityFlags: props.compatibilityFlags,
|
|
166185
166237
|
usageModel: props.usageModel
|
|
166186
166238
|
});
|
|
166187
|
-
const { workerAccount, workerContext } = getWorkerAccountAndContext(
|
|
166188
|
-
|
|
166189
|
-
|
|
166190
|
-
|
|
166191
|
-
|
|
166192
|
-
|
|
166193
|
-
|
|
166194
|
-
|
|
166195
|
-
|
|
166239
|
+
const { workerAccount, workerContext } = await getWorkerAccountAndContext(
|
|
166240
|
+
{
|
|
166241
|
+
accountId: props.accountId,
|
|
166242
|
+
env: props.env,
|
|
166243
|
+
legacyEnv: props.legacyEnv,
|
|
166244
|
+
host: props.host,
|
|
166245
|
+
routes: props.routes,
|
|
166246
|
+
sendMetrics: props.sendMetrics
|
|
166247
|
+
}
|
|
166248
|
+
);
|
|
166196
166249
|
const workerPreviewToken = await createWorkerPreview(
|
|
166197
166250
|
init2,
|
|
166198
166251
|
workerAccount,
|
|
@@ -166215,7 +166268,7 @@ ${onboardingLink}`);
|
|
|
166215
166268
|
pathname: workerPreviewToken.inspectorUrl.pathname
|
|
166216
166269
|
},
|
|
166217
166270
|
userWorkerInnerUrlOverrides: {
|
|
166218
|
-
hostname: props.host,
|
|
166271
|
+
hostname: props.host ?? getInferredHost(props.routes),
|
|
166219
166272
|
port: props.port.toString()
|
|
166220
166273
|
},
|
|
166221
166274
|
headers: {
|
|
@@ -166226,7 +166279,11 @@ ${onboardingLink}`);
|
|
|
166226
166279
|
// liveReload currently disabled in remote-mode, but will be supported with startDevWorker
|
|
166227
166280
|
proxyLogsToController: true
|
|
166228
166281
|
};
|
|
166229
|
-
onReady?.(
|
|
166282
|
+
onReady?.(
|
|
166283
|
+
props.host ?? getInferredHost(props.routes) ?? "localhost",
|
|
166284
|
+
props.port,
|
|
166285
|
+
proxyData
|
|
166286
|
+
);
|
|
166230
166287
|
}
|
|
166231
166288
|
__name(start, "start");
|
|
166232
166289
|
start().catch((err) => {
|
|
@@ -166256,7 +166313,6 @@ ${onboardingLink}`);
|
|
|
166256
166313
|
props.modules,
|
|
166257
166314
|
props.env,
|
|
166258
166315
|
props.legacyEnv,
|
|
166259
|
-
props.zone,
|
|
166260
166316
|
props.host,
|
|
166261
166317
|
props.routes,
|
|
166262
166318
|
session,
|
|
@@ -166347,11 +166403,10 @@ async function getRemotePreviewToken(props) {
|
|
|
166347
166403
|
throw error2;
|
|
166348
166404
|
}
|
|
166349
166405
|
const abortController = new AbortController();
|
|
166350
|
-
const { workerAccount, workerContext } = getWorkerAccountAndContext({
|
|
166406
|
+
const { workerAccount, workerContext } = await getWorkerAccountAndContext({
|
|
166351
166407
|
accountId: props.accountId,
|
|
166352
166408
|
env: props.env,
|
|
166353
166409
|
legacyEnv: props.legacyEnv,
|
|
166354
|
-
zone: props.zone,
|
|
166355
166410
|
host: props.host,
|
|
166356
166411
|
routes: props.routes,
|
|
166357
166412
|
sendMetrics: props.sendMetrics
|
|
@@ -166472,16 +166527,17 @@ async function createRemoteWorkerInit(props) {
|
|
|
166472
166527
|
return init2;
|
|
166473
166528
|
}
|
|
166474
166529
|
__name(createRemoteWorkerInit, "createRemoteWorkerInit");
|
|
166475
|
-
function getWorkerAccountAndContext(props) {
|
|
166530
|
+
async function getWorkerAccountAndContext(props) {
|
|
166476
166531
|
const workerAccount = {
|
|
166477
166532
|
accountId: props.accountId,
|
|
166478
166533
|
apiToken: requireApiToken()
|
|
166479
166534
|
};
|
|
166535
|
+
const zoneId = await getZoneIdForPreview(props.host, props.routes);
|
|
166480
166536
|
const workerContext = {
|
|
166481
166537
|
env: props.env,
|
|
166482
166538
|
legacyEnv: props.legacyEnv,
|
|
166483
|
-
zone:
|
|
166484
|
-
host: props.host,
|
|
166539
|
+
zone: zoneId,
|
|
166540
|
+
host: props.host ?? getInferredHost(props.routes),
|
|
166485
166541
|
routes: props.routes,
|
|
166486
166542
|
sendMetrics: props.sendMetrics
|
|
166487
166543
|
};
|
|
@@ -167065,7 +167121,6 @@ function DevSession(props) {
|
|
|
167065
167121
|
usageModel: props.usageModel,
|
|
167066
167122
|
env: props.env,
|
|
167067
167123
|
legacyEnv: props.legacyEnv,
|
|
167068
|
-
zone: props.zone,
|
|
167069
167124
|
host: props.host,
|
|
167070
167125
|
routes: props.routes,
|
|
167071
167126
|
onReady: announceAndOnReady,
|
|
@@ -167437,7 +167492,6 @@ async function startDevServer(props) {
|
|
|
167437
167492
|
usageModel: props.usageModel,
|
|
167438
167493
|
env: props.env,
|
|
167439
167494
|
legacyEnv: props.legacyEnv,
|
|
167440
|
-
zone: props.zone,
|
|
167441
167495
|
host: props.host,
|
|
167442
167496
|
routes: props.routes,
|
|
167443
167497
|
onReady: async (ip2, port2, proxyData) => {
|
|
@@ -167876,7 +167930,6 @@ async function startDev(args) {
|
|
|
167876
167930
|
legacyNodeCompat,
|
|
167877
167931
|
nodejsCompat,
|
|
167878
167932
|
upstreamProtocol,
|
|
167879
|
-
zoneId,
|
|
167880
167933
|
host,
|
|
167881
167934
|
routes,
|
|
167882
167935
|
getLocalPort,
|
|
@@ -167908,7 +167961,6 @@ async function startDev(args) {
|
|
|
167908
167961
|
findAdditionalModules: configParam.find_additional_modules,
|
|
167909
167962
|
entry,
|
|
167910
167963
|
env: args.env,
|
|
167911
|
-
zone: zoneId,
|
|
167912
167964
|
host,
|
|
167913
167965
|
routes,
|
|
167914
167966
|
processEntrypoint,
|
|
@@ -167928,7 +167980,7 @@ async function startDev(args) {
|
|
|
167928
167980
|
localProtocol: args.localProtocol || configParam.dev.local_protocol,
|
|
167929
167981
|
httpsKeyPath: args.httpsKeyPath,
|
|
167930
167982
|
httpsCertPath: args.httpsCertPath,
|
|
167931
|
-
localUpstream: args.localUpstream ?? host,
|
|
167983
|
+
localUpstream: args.localUpstream ?? host ?? getInferredHost(routes),
|
|
167932
167984
|
localPersistencePath,
|
|
167933
167985
|
liveReload: args.liveReload || false,
|
|
167934
167986
|
accountId: args.accountId ?? configParam.account_id ?? getAccountFromCache()?.id,
|
|
@@ -167990,7 +168042,6 @@ async function startApiDev(args) {
|
|
|
167990
168042
|
legacyNodeCompat,
|
|
167991
168043
|
nodejsCompat,
|
|
167992
168044
|
upstreamProtocol,
|
|
167993
|
-
zoneId,
|
|
167994
168045
|
host,
|
|
167995
168046
|
routes,
|
|
167996
168047
|
getLocalPort,
|
|
@@ -168018,7 +168069,6 @@ async function startApiDev(args) {
|
|
|
168018
168069
|
findAdditionalModules: configParam.find_additional_modules,
|
|
168019
168070
|
entry,
|
|
168020
168071
|
env: args.env,
|
|
168021
|
-
zone: zoneId,
|
|
168022
168072
|
host,
|
|
168023
168073
|
routes,
|
|
168024
168074
|
processEntrypoint,
|
|
@@ -168038,7 +168088,7 @@ async function startApiDev(args) {
|
|
|
168038
168088
|
localProtocol: args.localProtocol ?? configParam.dev.local_protocol,
|
|
168039
168089
|
httpsKeyPath: args.httpsKeyPath,
|
|
168040
168090
|
httpsCertPath: args.httpsCertPath,
|
|
168041
|
-
localUpstream: args.localUpstream ?? host,
|
|
168091
|
+
localUpstream: args.localUpstream ?? host ?? getInferredHost(routes),
|
|
168042
168092
|
localPersistencePath,
|
|
168043
168093
|
liveReload: args.liveReload ?? false,
|
|
168044
168094
|
accountId: args.accountId ?? configParam.account_id ?? getAccountFromCache()?.id,
|
|
@@ -168105,31 +168155,21 @@ function maskVars(bindings, configParam) {
|
|
|
168105
168155
|
return maskedVars;
|
|
168106
168156
|
}
|
|
168107
168157
|
__name(maskVars, "maskVars");
|
|
168108
|
-
async function
|
|
168109
|
-
|
|
168110
|
-
let zoneId;
|
|
168158
|
+
async function getHostAndRoutes(args, config) {
|
|
168159
|
+
const host = args.host || config.dev.host;
|
|
168111
168160
|
const routes = args.routes || config.route && [config.route] || config.routes;
|
|
168112
|
-
|
|
168113
|
-
|
|
168114
|
-
|
|
168115
|
-
|
|
168116
|
-
|
|
168117
|
-
|
|
168118
|
-
|
|
168119
|
-
|
|
168120
|
-
|
|
168121
|
-
host
|
|
168122
|
-
|
|
168123
|
-
|
|
168124
|
-
} else if (!host) {
|
|
168125
|
-
if (routes) {
|
|
168126
|
-
const firstRoute = routes[0];
|
|
168127
|
-
host = getHostFromRoute(firstRoute);
|
|
168128
|
-
if (host === void 0) {
|
|
168129
|
-
throw new UserError(
|
|
168130
|
-
`Cannot infer host from first route: ${JSON.stringify(
|
|
168131
|
-
firstRoute
|
|
168132
|
-
)}.
|
|
168161
|
+
return { host, routes };
|
|
168162
|
+
}
|
|
168163
|
+
__name(getHostAndRoutes, "getHostAndRoutes");
|
|
168164
|
+
function getInferredHost(routes) {
|
|
168165
|
+
if (routes) {
|
|
168166
|
+
const firstRoute = routes[0];
|
|
168167
|
+
const host = getHostFromRoute(firstRoute);
|
|
168168
|
+
if (host === void 0) {
|
|
168169
|
+
throw new UserError(
|
|
168170
|
+
`Cannot infer host from first route: ${JSON.stringify(
|
|
168171
|
+
firstRoute
|
|
168172
|
+
)}.
|
|
168133
168173
|
You can explicitly set the \`dev.host\` configuration in your wrangler.toml file, for example:
|
|
168134
168174
|
|
|
168135
168175
|
\`\`\`
|
|
@@ -168137,20 +168177,21 @@ You can explicitly set the \`dev.host\` configuration in your wrangler.toml file
|
|
|
168137
168177
|
host = "example.com"
|
|
168138
168178
|
\`\`\`
|
|
168139
168179
|
`
|
|
168140
|
-
|
|
168141
|
-
}
|
|
168180
|
+
);
|
|
168142
168181
|
}
|
|
168182
|
+
return host;
|
|
168143
168183
|
}
|
|
168144
|
-
return { host, routes, zoneId };
|
|
168145
168184
|
}
|
|
168146
|
-
__name(
|
|
168185
|
+
__name(getInferredHost, "getInferredHost");
|
|
168147
168186
|
async function validateDevServerSettings(args, config) {
|
|
168148
168187
|
const entry = await getEntry(
|
|
168149
168188
|
{ assets: args.assets, script: args.script, moduleRoot: args.moduleRoot },
|
|
168150
168189
|
config,
|
|
168151
168190
|
"dev"
|
|
168152
168191
|
);
|
|
168153
|
-
const {
|
|
168192
|
+
const { host, routes } = await getHostAndRoutes(args, config);
|
|
168193
|
+
if (args.remote)
|
|
168194
|
+
await getZoneIdForPreview(host, routes);
|
|
168154
168195
|
const initialIp = args.ip || config.dev.ip;
|
|
168155
168196
|
const initialIpListenCheck = initialIp === "*" ? "0.0.0.0" : initialIp;
|
|
168156
168197
|
const getLocalPort = memoizeGetPort(DEFAULT_LOCAL_PORT, initialIpListenCheck);
|
|
@@ -168225,7 +168266,6 @@ use --persist-to=./wrangler-local-state to keep using the old path.`
|
|
|
168225
168266
|
getLocalPort,
|
|
168226
168267
|
getInspectorPort,
|
|
168227
168268
|
getRuntimeInspectorPort,
|
|
168228
|
-
zoneId,
|
|
168229
168269
|
host,
|
|
168230
168270
|
routes,
|
|
168231
168271
|
cliDefines,
|