wrangler 3.67.1 → 3.69.0
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/wrangler-dist/cli.js
CHANGED
@@ -22039,10 +22039,10 @@ var require_lodash = __commonJS({
|
|
22039
22039
|
};
|
22040
22040
|
}
|
22041
22041
|
__name(negate, "negate");
|
22042
|
-
function
|
22042
|
+
function once2(func) {
|
22043
22043
|
return before(2, func);
|
22044
22044
|
}
|
22045
|
-
__name(
|
22045
|
+
__name(once2, "once");
|
22046
22046
|
var overArgs = castRest(function(func, transforms) {
|
22047
22047
|
transforms = transforms.length == 1 && isArray(transforms[0]) ? arrayMap(transforms[0], baseUnary(getIteratee())) : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
|
22048
22048
|
var funcsLength = transforms.length;
|
@@ -23291,7 +23291,7 @@ var require_lodash = __commonJS({
|
|
23291
23291
|
lodash.nthArg = nthArg;
|
23292
23292
|
lodash.omit = omit;
|
23293
23293
|
lodash.omitBy = omitBy;
|
23294
|
-
lodash.once =
|
23294
|
+
lodash.once = once2;
|
23295
23295
|
lodash.orderBy = orderBy;
|
23296
23296
|
lodash.over = over;
|
23297
23297
|
lodash.overArgs = overArgs;
|
@@ -80042,7 +80042,7 @@ var require_view = __commonJS({
|
|
80042
80042
|
var debug = require_src2()("express:view");
|
80043
80043
|
var path74 = require("path");
|
80044
80044
|
var fs26 = require("fs");
|
80045
|
-
var
|
80045
|
+
var dirname16 = path74.dirname;
|
80046
80046
|
var basename5 = path74.basename;
|
80047
80047
|
var extname5 = path74.extname;
|
80048
80048
|
var join17 = path74.join;
|
@@ -80082,7 +80082,7 @@ var require_view = __commonJS({
|
|
80082
80082
|
for (var i = 0; i < roots.length && !path75; i++) {
|
80083
80083
|
var root = roots[i];
|
80084
80084
|
var loc = resolve20(root, name);
|
80085
|
-
var dir =
|
80085
|
+
var dir = dirname16(loc);
|
80086
80086
|
var file = basename5(loc);
|
80087
80087
|
path75 = this.resolve(dir, file);
|
80088
80088
|
}
|
@@ -97442,9 +97442,9 @@ var require_command_exists = __commonJS({
|
|
97442
97442
|
cleanInput = /* @__PURE__ */ __name(function(s) {
|
97443
97443
|
var isPathName = /[\\]/.test(s);
|
97444
97444
|
if (isPathName) {
|
97445
|
-
var
|
97445
|
+
var dirname16 = '"' + path74.dirname(s) + '"';
|
97446
97446
|
var basename5 = '"' + path74.basename(s) + '"';
|
97447
|
-
return
|
97447
|
+
return dirname16 + ":" + basename5;
|
97448
97448
|
}
|
97449
97449
|
return '"' + s + '"';
|
97450
97450
|
}, "cleanInput");
|
@@ -125409,12 +125409,12 @@ var require_set_cookie = __commonJS({
|
|
125409
125409
|
map: false,
|
125410
125410
|
silent: false
|
125411
125411
|
};
|
125412
|
-
function
|
125412
|
+
function isNonEmptyString2(str) {
|
125413
125413
|
return typeof str === "string" && !!str.trim();
|
125414
125414
|
}
|
125415
|
-
__name(
|
125415
|
+
__name(isNonEmptyString2, "isNonEmptyString");
|
125416
125416
|
function parseString(setCookieValue, options21) {
|
125417
|
-
var parts = setCookieValue.split(";").filter(
|
125417
|
+
var parts = setCookieValue.split(";").filter(isNonEmptyString2);
|
125418
125418
|
var nameValuePairStr = parts.shift();
|
125419
125419
|
var parsed = parseNameValuePair(nameValuePairStr);
|
125420
125420
|
var name = parsed.name;
|
@@ -125497,12 +125497,12 @@ var require_set_cookie = __commonJS({
|
|
125497
125497
|
}
|
125498
125498
|
options21 = options21 ? Object.assign({}, defaultParseOptions, options21) : defaultParseOptions;
|
125499
125499
|
if (!options21.map) {
|
125500
|
-
return input.filter(
|
125500
|
+
return input.filter(isNonEmptyString2).map(function(str) {
|
125501
125501
|
return parseString(str, options21);
|
125502
125502
|
});
|
125503
125503
|
} else {
|
125504
125504
|
var cookies = {};
|
125505
|
-
return input.filter(
|
125505
|
+
return input.filter(isNonEmptyString2).reduce(function(cookies2, str) {
|
125506
125506
|
var cookie = parseString(str, options21);
|
125507
125507
|
cookies2[cookie.name] = cookie;
|
125508
125508
|
return cookies2;
|
@@ -135302,21 +135302,21 @@ Make sure "${service}" is mounted so Miniflare knows where to find it.`);
|
|
135302
135302
|
getEventListeners: () => getEventListeners,
|
135303
135303
|
listenerCount: () => listenerCount,
|
135304
135304
|
on: () => on,
|
135305
|
-
once: () =>
|
135305
|
+
once: () => once2,
|
135306
135306
|
setMaxListeners: () => setMaxListeners
|
135307
135307
|
});
|
135308
|
-
var
|
135309
|
-
var events_default =
|
135310
|
-
var EventEmitter5 =
|
135311
|
-
var EventEmitterAsyncResource =
|
135312
|
-
var captureRejectionSymbol =
|
135313
|
-
var defaultMaxListeners =
|
135314
|
-
var errorMonitor =
|
135315
|
-
var getEventListeners =
|
135316
|
-
var listenerCount =
|
135317
|
-
var on =
|
135318
|
-
var
|
135319
|
-
var setMaxListeners =
|
135308
|
+
var import_node_events7 = __toModule(require("node:events"));
|
135309
|
+
var events_default = import_node_events7.default;
|
135310
|
+
var EventEmitter5 = import_node_events7.default.EventEmitter;
|
135311
|
+
var EventEmitterAsyncResource = import_node_events7.default.EventEmitterAsyncResource;
|
135312
|
+
var captureRejectionSymbol = import_node_events7.default.captureRejectionSymbol;
|
135313
|
+
var defaultMaxListeners = import_node_events7.default.defaultMaxListeners;
|
135314
|
+
var errorMonitor = import_node_events7.default.errorMonitor;
|
135315
|
+
var getEventListeners = import_node_events7.default.getEventListeners;
|
135316
|
+
var listenerCount = import_node_events7.default.listenerCount;
|
135317
|
+
var on = import_node_events7.default.on;
|
135318
|
+
var once2 = import_node_events7.default.once;
|
135319
|
+
var setMaxListeners = import_node_events7.default.setMaxListeners;
|
135320
135320
|
var util_exports = {};
|
135321
135321
|
__export2(util_exports, {
|
135322
135322
|
_extend: () => import_node_util4._extend,
|
@@ -142444,17 +142444,17 @@ var require_eventemitter3 = __commonJS({
|
|
142444
142444
|
if (!new Events().__proto__)
|
142445
142445
|
prefix = false;
|
142446
142446
|
}
|
142447
|
-
function EE(fn2, context2,
|
142447
|
+
function EE(fn2, context2, once2) {
|
142448
142448
|
this.fn = fn2;
|
142449
142449
|
this.context = context2;
|
142450
|
-
this.once =
|
142450
|
+
this.once = once2 || false;
|
142451
142451
|
}
|
142452
142452
|
__name(EE, "EE");
|
142453
|
-
function addListener(emitter, event, fn2, context2,
|
142453
|
+
function addListener(emitter, event, fn2, context2, once2) {
|
142454
142454
|
if (typeof fn2 !== "function") {
|
142455
142455
|
throw new TypeError("The listener must be a function");
|
142456
142456
|
}
|
142457
|
-
var listener = new EE(fn2, context2 || emitter,
|
142457
|
+
var listener = new EE(fn2, context2 || emitter, once2), evt = prefix ? prefix + event : event;
|
142458
142458
|
if (!emitter._events[evt])
|
142459
142459
|
emitter._events[evt] = listener, emitter._eventsCount++;
|
142460
142460
|
else if (!emitter._events[evt].fn)
|
@@ -142566,10 +142566,10 @@ var require_eventemitter3 = __commonJS({
|
|
142566
142566
|
EventEmitter5.prototype.on = /* @__PURE__ */ __name(function on(event, fn2, context2) {
|
142567
142567
|
return addListener(this, event, fn2, context2, false);
|
142568
142568
|
}, "on");
|
142569
|
-
EventEmitter5.prototype.once = /* @__PURE__ */ __name(function
|
142569
|
+
EventEmitter5.prototype.once = /* @__PURE__ */ __name(function once2(event, fn2, context2) {
|
142570
142570
|
return addListener(this, event, fn2, context2, true);
|
142571
142571
|
}, "once");
|
142572
|
-
EventEmitter5.prototype.removeListener = /* @__PURE__ */ __name(function removeListener(event, fn2, context2,
|
142572
|
+
EventEmitter5.prototype.removeListener = /* @__PURE__ */ __name(function removeListener(event, fn2, context2, once2) {
|
142573
142573
|
var evt = prefix ? prefix + event : event;
|
142574
142574
|
if (!this._events[evt])
|
142575
142575
|
return this;
|
@@ -142579,12 +142579,12 @@ var require_eventemitter3 = __commonJS({
|
|
142579
142579
|
}
|
142580
142580
|
var listeners = this._events[evt];
|
142581
142581
|
if (listeners.fn) {
|
142582
|
-
if (listeners.fn === fn2 && (!
|
142582
|
+
if (listeners.fn === fn2 && (!once2 || listeners.once) && (!context2 || listeners.context === context2)) {
|
142583
142583
|
clearEvent(this, evt);
|
142584
142584
|
}
|
142585
142585
|
} else {
|
142586
142586
|
for (var i = 0, events4 = [], length = listeners.length; i < length; i++) {
|
142587
|
-
if (listeners[i].fn !== fn2 ||
|
142587
|
+
if (listeners[i].fn !== fn2 || once2 && !listeners[i].once || context2 && listeners[i].context !== context2) {
|
142588
142588
|
events4.push(listeners[i]);
|
142589
142589
|
}
|
142590
142590
|
}
|
@@ -151168,8 +151168,7 @@ var import_undici25 = __toESM(require_undici());
|
|
151168
151168
|
// src/dev.tsx
|
151169
151169
|
init_import_meta_url();
|
151170
151170
|
var import_node_assert21 = __toESM(require("node:assert"));
|
151171
|
-
var
|
151172
|
-
var import_node_fs35 = require("node:fs");
|
151171
|
+
var import_node_events3 = __toESM(require("node:events"));
|
151173
151172
|
var import_node_path63 = __toESM(require("node:path"));
|
151174
151173
|
var import_node_util3 = __toESM(require("node:util"));
|
151175
151174
|
var import_env2 = __toESM(require_dist());
|
@@ -151351,8 +151350,8 @@ function convertCfWorkerInitBindingstoBindings(inputBindings) {
|
|
151351
151350
|
break;
|
151352
151351
|
}
|
151353
151352
|
case "unsafe": {
|
151354
|
-
for (const { type: unsafeType, name } of info.bindings ?? []) {
|
151355
|
-
output[name] = { type: `unsafe_${unsafeType}
|
151353
|
+
for (const { type: unsafeType, name, ...data } of info.bindings ?? []) {
|
151354
|
+
output[name] = { type: `unsafe_${unsafeType}`, ...data };
|
151356
151355
|
}
|
151357
151356
|
break;
|
151358
151357
|
}
|
@@ -151464,9 +151463,11 @@ async function convertBindingsToCfWorkerInitBindings(inputBindings) {
|
|
151464
151463
|
metadata: void 0,
|
151465
151464
|
capnp: void 0
|
151466
151465
|
};
|
151466
|
+
const { type, ...data } = binding;
|
151467
151467
|
bindings.unsafe.bindings?.push({
|
151468
|
-
type:
|
151469
|
-
name
|
151468
|
+
type: type.slice("unsafe_".length),
|
151469
|
+
name,
|
151470
|
+
...data
|
151470
151471
|
});
|
151471
151472
|
}
|
151472
151473
|
}
|
@@ -152671,7 +152672,7 @@ init_import_meta_url();
|
|
152671
152672
|
init_import_meta_url();
|
152672
152673
|
|
152673
152674
|
// package.json
|
152674
|
-
var version = "3.
|
152675
|
+
var version = "3.69.0";
|
152675
152676
|
var package_default = {
|
152676
152677
|
name: "wrangler",
|
152677
152678
|
version,
|
@@ -152758,7 +152759,7 @@ var package_default = {
|
|
152758
152759
|
selfsigned: "^2.0.1",
|
152759
152760
|
"source-map": "^0.6.1",
|
152760
152761
|
unenv: "npm:unenv-nightly@1.10.0-1717606461.a117952",
|
152761
|
-
workerd: "1.
|
152762
|
+
workerd: "1.20240725.0",
|
152762
152763
|
"xxhash-wasm": "^1.0.1"
|
152763
152764
|
},
|
152764
152765
|
devDependencies: {
|
@@ -152766,8 +152767,9 @@ var package_default = {
|
|
152766
152767
|
"@cloudflare/eslint-config-worker": "workspace:*",
|
152767
152768
|
"@cloudflare/pages-shared": "workspace:^",
|
152768
152769
|
"@cloudflare/types": "^6.18.4",
|
152770
|
+
"@cloudflare/workers-shared": "workspace:*",
|
152769
152771
|
"@cloudflare/workers-tsconfig": "workspace:*",
|
152770
|
-
"@cloudflare/workers-types": "^4.
|
152772
|
+
"@cloudflare/workers-types": "^4.20240725.0",
|
152771
152773
|
"@cspotcode/source-map-support": "0.8.1",
|
152772
152774
|
"@iarna/toml": "^3.0.0",
|
152773
152775
|
"@microsoft/api-extractor": "^7.47.0",
|
@@ -152838,7 +152840,6 @@ var package_default = {
|
|
152838
152840
|
"strip-ansi": "^7.1.0",
|
152839
152841
|
"supports-color": "^9.2.2",
|
152840
152842
|
"timeago.js": "^4.0.2",
|
152841
|
-
"tree-kill": "^1.2.2",
|
152842
152843
|
"ts-dedent": "^2.2.0",
|
152843
152844
|
"ts-json-schema-generator": "^1.5.0",
|
152844
152845
|
undici: "^5.28.4",
|
@@ -152851,7 +152852,7 @@ var package_default = {
|
|
152851
152852
|
"yoga-layout": "file:../../vendor/yoga-layout-2.0.0-beta.1.tgz"
|
152852
152853
|
},
|
152853
152854
|
peerDependencies: {
|
152854
|
-
"@cloudflare/workers-types": "^4.
|
152855
|
+
"@cloudflare/workers-types": "^4.20240725.0"
|
152855
152856
|
},
|
152856
152857
|
peerDependenciesMeta: {
|
152857
152858
|
"@cloudflare/workers-types": {
|
@@ -154379,6 +154380,16 @@ var isString = /* @__PURE__ */ __name((diagnostics, field, value) => {
|
|
154379
154380
|
}
|
154380
154381
|
return true;
|
154381
154382
|
}, "isString");
|
154383
|
+
var isNonEmptyString = /* @__PURE__ */ __name((diagnostics, field, value, topLevelEnv) => {
|
154384
|
+
if (!isString(diagnostics, field, value, topLevelEnv)) {
|
154385
|
+
return false;
|
154386
|
+
}
|
154387
|
+
if (value?.trim() === "") {
|
154388
|
+
diagnostics.errors.push(`Expected "${field}" to be a non-empty string.`);
|
154389
|
+
return false;
|
154390
|
+
}
|
154391
|
+
return true;
|
154392
|
+
}, "isNonEmptyString");
|
154382
154393
|
var isValidName = /* @__PURE__ */ __name((diagnostics, field, value) => {
|
154383
154394
|
if (typeof value === "string" && /^$|^[a-z0-9_ ][a-z0-9-_ ]*$/.test(value) || value === void 0) {
|
154384
154395
|
return true;
|
@@ -156151,6 +156162,12 @@ var validateAssetsConfig = /* @__PURE__ */ __name((diagnostics, field, value) =>
|
|
156151
156162
|
value.directory,
|
156152
156163
|
"string"
|
156153
156164
|
) && isValid;
|
156165
|
+
isValid = isNonEmptyString(
|
156166
|
+
diagnostics,
|
156167
|
+
`${field}.directory`,
|
156168
|
+
value.directory,
|
156169
|
+
void 0
|
156170
|
+
) && isValid;
|
156154
156171
|
isValid = validateOptionalProperty(
|
156155
156172
|
diagnostics,
|
156156
156173
|
field,
|
@@ -158970,7 +158987,7 @@ async function bundleWorker(entry, destination, {
|
|
158970
158987
|
bundle,
|
158971
158988
|
moduleCollector = noopModuleCollector,
|
158972
158989
|
additionalModules = [],
|
158973
|
-
|
158990
|
+
serveLegacyAssetsFromWorker,
|
158974
158991
|
doBindings,
|
158975
158992
|
jsxFactory,
|
158976
158993
|
jsxFragment,
|
@@ -159021,7 +159038,7 @@ async function bundleWorker(entry, destination, {
|
|
159021
159038
|
supports: ["modules", "service-worker"]
|
159022
159039
|
});
|
159023
159040
|
}
|
159024
|
-
if (
|
159041
|
+
if (serveLegacyAssetsFromWorker) {
|
159025
159042
|
middlewareToLoad.push({
|
159026
159043
|
name: "serve-static-assets",
|
159027
159044
|
path: "templates/middleware/middleware-serve-static-assets.ts",
|
@@ -159374,8 +159391,10 @@ async function getEntry(args, config, command2) {
|
|
159374
159391
|
// site.entry-point could be a directory
|
159375
159392
|
import_node_path16.default.resolve(config.site?.["entry-point"], "index.js")
|
159376
159393
|
);
|
159377
|
-
} else if (args.legacyAssets || config.legacy_assets
|
159394
|
+
} else if (args.legacyAssets || config.legacy_assets) {
|
159378
159395
|
file = import_node_path16.default.resolve(getBasePath(), "templates/no-op-worker.js");
|
159396
|
+
} else if (args.experimentalAssets || config.experimental_assets) {
|
159397
|
+
file = import_node_path16.default.resolve(getBasePath(), "templates/no-op-assets-worker.ts");
|
159379
159398
|
} else {
|
159380
159399
|
throw new UserError(
|
159381
159400
|
`Missing entry-point: The entry-point should be specified via the command line (e.g. \`wrangler ${command2} path/to/script\`) or the \`main\` config field.`
|
@@ -162585,7 +162604,8 @@ function buildMiniflareBindingOptions(config) {
|
|
162585
162604
|
}
|
162586
162605
|
}
|
162587
162606
|
const serviceBindings = {
|
162588
|
-
...config.serviceBindings
|
162607
|
+
...config.serviceBindings,
|
162608
|
+
...config.experimentalAssets ? { ASSET_SERVER: "asset-server" } : {}
|
162589
162609
|
};
|
162590
162610
|
const notFoundServices = /* @__PURE__ */ new Set();
|
162591
162611
|
for (const service of config.services ?? []) {
|
@@ -162788,10 +162808,10 @@ function buildPersistOptions(localPersistencePath) {
|
|
162788
162808
|
}
|
162789
162809
|
__name(buildPersistOptions, "buildPersistOptions");
|
162790
162810
|
function buildSitesOptions({
|
162791
|
-
|
162811
|
+
legacyAssetPaths
|
162792
162812
|
}) {
|
162793
|
-
if (
|
162794
|
-
const { baseDirectory, assetDirectory, includePatterns, excludePatterns } =
|
162813
|
+
if (legacyAssetPaths !== void 0) {
|
162814
|
+
const { baseDirectory, assetDirectory, includePatterns, excludePatterns } = legacyAssetPaths;
|
162795
162815
|
return {
|
162796
162816
|
sitePath: import_node_path22.default.join(baseDirectory, assetDirectory),
|
162797
162817
|
siteInclude: includePatterns.length > 0 ? includePatterns : void 0,
|
@@ -162881,6 +162901,35 @@ async function buildMiniflareOptions(log2, config, proxyToUserWorkerAuthenticati
|
|
162881
162901
|
);
|
162882
162902
|
}
|
162883
162903
|
}
|
162904
|
+
const assetServerModulePath = require.resolve("@cloudflare/workers-shared/dist/asset-server-worker.mjs");
|
162905
|
+
const assetServerConfigPath = require.resolve("@cloudflare/workers-shared/asset-server-worker/wrangler.toml");
|
162906
|
+
let assetServerConfig;
|
162907
|
+
try {
|
162908
|
+
assetServerConfig = readConfig(assetServerConfigPath, {});
|
162909
|
+
} catch (err) {
|
162910
|
+
throw new UserError(
|
162911
|
+
`Failed to read the Asset Server Worker configuration file.
|
162912
|
+
${err}`
|
162913
|
+
);
|
162914
|
+
}
|
162915
|
+
const assetServerWorker = config.experimentalAssets ? {
|
162916
|
+
name: assetServerConfig?.name,
|
162917
|
+
compatibilityDate: assetServerConfig?.compatibility_date,
|
162918
|
+
compatibilityFlags: assetServerConfig?.compatibility_flags,
|
162919
|
+
modulesRoot: (0, import_node_path22.dirname)(assetServerModulePath),
|
162920
|
+
modules: [
|
162921
|
+
{
|
162922
|
+
type: "ESModule",
|
162923
|
+
path: assetServerModulePath
|
162924
|
+
}
|
162925
|
+
],
|
162926
|
+
unsafeDirectSockets: [
|
162927
|
+
{
|
162928
|
+
host: "127.0.0.1",
|
162929
|
+
port: 0
|
162930
|
+
}
|
162931
|
+
]
|
162932
|
+
} : void 0;
|
162884
162933
|
const upstream = typeof config.localUpstream === "string" ? `${config.upstreamProtocol}://${config.localUpstream}` : void 0;
|
162885
162934
|
const { sourceOptions, entrypointNames } = await buildSourceOptions(config);
|
162886
162935
|
const { bindingOptions, internalObjects, externalWorkers } = buildMiniflareBindingOptions(config);
|
@@ -162913,6 +162962,7 @@ async function buildMiniflareOptions(log2, config, proxyToUserWorkerAuthenticati
|
|
162913
162962
|
proxy: true
|
162914
162963
|
}))
|
162915
162964
|
},
|
162965
|
+
...config.experimentalAssets ? [assetServerWorker] : [],
|
162916
162966
|
...externalWorkers
|
162917
162967
|
]
|
162918
162968
|
};
|
@@ -163024,7 +163074,8 @@ async function localPropsToConfigBundle(props) {
|
|
163024
163074
|
inspectorPort: props.runtimeInspectorPort,
|
163025
163075
|
bindings: props.bindings,
|
163026
163076
|
workerDefinitions: props.workerDefinitions,
|
163027
|
-
|
163077
|
+
legacyAssetPaths: props.legacyAssetPaths,
|
163078
|
+
experimentalAssets: props.experimentalAssets,
|
163028
163079
|
initialPort: props.initialPort,
|
163029
163080
|
initialIp: props.initialIp,
|
163030
163081
|
rules: props.rules,
|
@@ -163381,11 +163432,6 @@ async function printBundleSize(main2, modules) {
|
|
163381
163432
|
const percentage = gzipSize / ALLOWED_INITIAL_MAX * 100;
|
163382
163433
|
const colorizedReport = percentage > 90 ? source_default.red(bundleReport) : percentage > 70 ? source_default.yellow(bundleReport) : source_default.green(bundleReport);
|
163383
163434
|
logger.log(`Total Upload: ${colorizedReport}`);
|
163384
|
-
if (gzipSize > ALLOWED_INITIAL_MAX && !process.env.NO_SCRIPT_SIZE_WARNING) {
|
163385
|
-
logger.warn(
|
163386
|
-
"We recommend keeping your script less than 1MiB (1024 KiB) after gzip. Exceeding this can affect cold start time. Consider using Wrangler's `--minify` option to reduce your bundle size."
|
163387
|
-
);
|
163388
|
-
}
|
163389
163435
|
}
|
163390
163436
|
__name(printBundleSize, "printBundleSize");
|
163391
163437
|
function printOffendingDependencies(dependencies) {
|
@@ -177879,16 +177925,39 @@ __name(checkAndConfirmForceDeleteIfNecessary, "checkAndConfirmForceDeleteIfNeces
|
|
177879
177925
|
|
177880
177926
|
// src/deploy/index.ts
|
177881
177927
|
init_import_meta_url();
|
177882
|
-
var import_node_fs20 = require("node:fs");
|
177883
177928
|
var import_node_path34 = __toESM(require("node:path"));
|
177884
177929
|
|
177885
177930
|
// src/experimental-assets.ts
|
177886
177931
|
init_import_meta_url();
|
177932
|
+
var import_node_fs20 = require("node:fs");
|
177887
177933
|
var import_node_path33 = __toESM(require("node:path"));
|
177888
|
-
function getExperimentalAssetsBasePath(config,
|
177889
|
-
return
|
177934
|
+
function getExperimentalAssetsBasePath(config, experimentalAssetsCommandLineArg) {
|
177935
|
+
return experimentalAssetsCommandLineArg ? process.cwd() : import_node_path33.default.resolve(import_node_path33.default.dirname(config.configPath ?? "wrangler.toml"));
|
177890
177936
|
}
|
177891
177937
|
__name(getExperimentalAssetsBasePath, "getExperimentalAssetsBasePath");
|
177938
|
+
function processExperimentalAssetsArg(args, config) {
|
177939
|
+
const experimentalAssets = args.experimentalAssets ? { directory: args.experimentalAssets } : config.experimental_assets;
|
177940
|
+
if (experimentalAssets) {
|
177941
|
+
const experimentalAssetsBasePath = getExperimentalAssetsBasePath(
|
177942
|
+
config,
|
177943
|
+
args.experimentalAssets
|
177944
|
+
);
|
177945
|
+
const resolvedExperimentalAssetsPath = import_node_path33.default.resolve(
|
177946
|
+
experimentalAssetsBasePath,
|
177947
|
+
experimentalAssets.directory
|
177948
|
+
);
|
177949
|
+
if (!(0, import_node_fs20.existsSync)(resolvedExperimentalAssetsPath)) {
|
177950
|
+
const sourceOfTruthMessage = args.experimentalAssets ? '"--experimental-assets" command line argument' : '"experimental_assets.directory" field in your configuration file';
|
177951
|
+
throw new UserError(
|
177952
|
+
`The directory specified by the ${sourceOfTruthMessage} does not exist:
|
177953
|
+
${resolvedExperimentalAssetsPath}`
|
177954
|
+
);
|
177955
|
+
}
|
177956
|
+
experimentalAssets.directory = resolvedExperimentalAssetsPath;
|
177957
|
+
}
|
177958
|
+
return experimentalAssets;
|
177959
|
+
}
|
177960
|
+
__name(processExperimentalAssetsArg, "processExperimentalAssetsArg");
|
177892
177961
|
|
177893
177962
|
// src/sites.ts
|
177894
177963
|
init_import_meta_url();
|
@@ -178228,7 +178297,7 @@ function urlSafe(filePath) {
|
|
178228
178297
|
return filePath.replace(/\\/g, "/");
|
178229
178298
|
}
|
178230
178299
|
__name(urlSafe, "urlSafe");
|
178231
|
-
function
|
178300
|
+
function getLegacyAssetPaths(config, assetDirectory) {
|
178232
178301
|
const baseDirectory = assetDirectory ? process.cwd() : path40.resolve(path40.dirname(config.configPath ?? "wrangler.toml"));
|
178233
178302
|
assetDirectory ??= typeof config.legacy_assets === "string" ? config.legacy_assets : config.legacy_assets !== void 0 ? config.legacy_assets.bucket : void 0;
|
178234
178303
|
const includePatterns = typeof config.legacy_assets !== "string" && config.legacy_assets?.include || [];
|
@@ -178240,7 +178309,7 @@ function getAssetPaths(config, assetDirectory) {
|
|
178240
178309
|
excludePatterns
|
178241
178310
|
} : void 0;
|
178242
178311
|
}
|
178243
|
-
__name(
|
178312
|
+
__name(getLegacyAssetPaths, "getLegacyAssetPaths");
|
178244
178313
|
function getSiteAssetPaths(config, assetDirectory, includePatterns = config.site?.include ?? [], excludePatterns = config.site?.exclude ?? []) {
|
178245
178314
|
const baseDirectory = assetDirectory ? process.cwd() : path40.resolve(path40.dirname(config.configPath ?? "wrangler.toml"));
|
178246
178315
|
assetDirectory ??= config.site?.bucket;
|
@@ -178482,30 +178551,12 @@ Please shift to the --legacy-assets command to preserve the current functionalit
|
|
178482
178551
|
"Cannot use Assets and Workers Sites in the same Worker."
|
178483
178552
|
);
|
178484
178553
|
}
|
178485
|
-
const experimentalAssets = args.experimentalAssets ? { directory: args.experimentalAssets } : config.experimental_assets;
|
178486
|
-
if (experimentalAssets) {
|
178487
|
-
const experimentalAssetsBasePath = getExperimentalAssetsBasePath(
|
178488
|
-
config,
|
178489
|
-
args.experimentalAssets
|
178490
|
-
);
|
178491
|
-
const resolvedExperimentalAssetsPath = import_node_path34.default.resolve(
|
178492
|
-
experimentalAssetsBasePath,
|
178493
|
-
experimentalAssets.directory
|
178494
|
-
);
|
178495
|
-
if (!(0, import_node_fs20.existsSync)(resolvedExperimentalAssetsPath)) {
|
178496
|
-
const sourceOfTruthMessage = args.experimentalAssets ? '"--experimental-assets" command line argument' : '"experimental_assets.directory" field in your configuration file';
|
178497
|
-
throw new UserError(
|
178498
|
-
`The directory specified by the ${sourceOfTruthMessage} does not exist:
|
178499
|
-
${resolvedExperimentalAssetsPath}`
|
178500
|
-
);
|
178501
|
-
}
|
178502
|
-
experimentalAssets.directory = resolvedExperimentalAssetsPath;
|
178503
|
-
}
|
178504
178554
|
if (args.assets) {
|
178505
178555
|
logger.warn(
|
178506
178556
|
"The --assets argument is experimental and may change or break at any time"
|
178507
178557
|
);
|
178508
178558
|
}
|
178559
|
+
const experimentalAssets = processExperimentalAssetsArg(args, config);
|
178509
178560
|
if (args.latest) {
|
178510
178561
|
logger.warn(
|
178511
178562
|
"Using the latest version of the Workers runtime. To silence this warning, please choose a specific version of the runtime with --compatibility-date, or add a compatibility_date to your wrangler.toml.\n"
|
@@ -178515,7 +178566,7 @@ ${resolvedExperimentalAssetsPath}`
|
|
178515
178566
|
const cliDefines = collectKeyValues(args.define);
|
178516
178567
|
const cliAlias = collectKeyValues(args.alias);
|
178517
178568
|
const accountId = args.dryRun ? void 0 : await requireAuth(config);
|
178518
|
-
const
|
178569
|
+
const legacyAssetPaths = args.legacyAssets || config.legacy_assets ? getLegacyAssetPaths(config, args.legacyAssets) : getSiteAssetPaths(
|
178519
178570
|
config,
|
178520
178571
|
args.site,
|
178521
178572
|
args.siteInclude,
|
@@ -178543,7 +178594,7 @@ ${resolvedExperimentalAssetsPath}`
|
|
178543
178594
|
tsconfig: args.tsconfig,
|
178544
178595
|
routes: args.routes,
|
178545
178596
|
experimentalAssets: experimentalAssets?.directory,
|
178546
|
-
|
178597
|
+
legacyAssetPaths,
|
178547
178598
|
legacyEnv: isLegacyEnv(config),
|
178548
178599
|
minify: args.minify,
|
178549
178600
|
nodeCompat: args.nodeCompat,
|
@@ -180720,7 +180771,7 @@ function buildWorkerFromFunctions({
|
|
180720
180771
|
}
|
180721
180772
|
],
|
180722
180773
|
isOutfile: !outdir,
|
180723
|
-
|
180774
|
+
serveLegacyAssetsFromWorker: false,
|
180724
180775
|
checkFetch: local,
|
180725
180776
|
targetConsumer: local ? "dev" : "deploy",
|
180726
180777
|
forPages: true,
|
@@ -180790,7 +180841,7 @@ function buildRawWorker({
|
|
180790
180841
|
] : []
|
180791
180842
|
],
|
180792
180843
|
isOutfile: !outdir,
|
180793
|
-
|
180844
|
+
serveLegacyAssetsFromWorker: false,
|
180794
180845
|
checkFetch: local,
|
180795
180846
|
targetConsumer: local ? "dev" : "deploy",
|
180796
180847
|
forPages: true,
|
@@ -181008,7 +181059,7 @@ function buildPluginFromFunctions({
|
|
181008
181059
|
}
|
181009
181060
|
}
|
181010
181061
|
],
|
181011
|
-
|
181062
|
+
serveLegacyAssetsFromWorker: false,
|
181012
181063
|
checkFetch: local,
|
181013
181064
|
targetConsumer: local ? "dev" : "deploy",
|
181014
181065
|
forPages: true,
|
@@ -184614,6 +184665,12 @@ function Options14(yargs) {
|
|
184614
184665
|
describe: "Show interactive dev session (defaults to true if the terminal supports interactivity)",
|
184615
184666
|
type: "boolean"
|
184616
184667
|
},
|
184668
|
+
"experimental-dev-env": {
|
184669
|
+
alias: ["x-dev-env"],
|
184670
|
+
type: "boolean",
|
184671
|
+
describe: "Use the experimental DevEnv instantiation (unified across wrangler dev and unstable_dev)",
|
184672
|
+
default: false
|
184673
|
+
},
|
184617
184674
|
"experimental-registry": {
|
184618
184675
|
alias: ["x-registry"],
|
184619
184676
|
type: "boolean",
|
@@ -185017,7 +185074,8 @@ ${JSON.stringify(defaultRoutesJSONSpec, null, 2)}`
|
|
185017
185074
|
showInteractiveDevSession: args.showInteractiveDevSession,
|
185018
185075
|
testMode: false,
|
185019
185076
|
watch: true,
|
185020
|
-
fileBasedRegistry: args.experimentalRegistry
|
185077
|
+
fileBasedRegistry: args.experimentalRegistry,
|
185078
|
+
devEnv: args.experimentalDevEnv
|
185021
185079
|
}
|
185022
185080
|
});
|
185023
185081
|
await sendMetricsEvent("run pages dev");
|
@@ -200627,7 +200685,7 @@ async function parseModules(accountId, scriptName, versionId) {
|
|
200627
200685
|
const formData = await contentRes.formData();
|
200628
200686
|
if (formData.get("__STATIC_CONTENT_MANIFEST") !== null) {
|
200629
200687
|
throw new UserError(
|
200630
|
-
"Workers Sites
|
200688
|
+
"Workers Sites and Legacy Assets do not support updating secrets through `wrangler versions secret put`. You must use `wrangler secret put` instead."
|
200631
200689
|
);
|
200632
200690
|
}
|
200633
200691
|
const entrypoint = contentRes.headers.get("cf-entrypoint");
|
@@ -200641,7 +200699,7 @@ async function parseModules(accountId, scriptName, versionId) {
|
|
200641
200699
|
const mainModule = {
|
200642
200700
|
name: entrypointPart.name,
|
200643
200701
|
filePath: "",
|
200644
|
-
content: await entrypointPart.
|
200702
|
+
content: Buffer.from(await entrypointPart.arrayBuffer()),
|
200645
200703
|
type: fromMimeType(entrypointPart.type)
|
200646
200704
|
};
|
200647
200705
|
const modules = await Promise.all(
|
@@ -200651,7 +200709,7 @@ async function parseModules(accountId, scriptName, versionId) {
|
|
200651
200709
|
async ([name, file]) => ({
|
200652
200710
|
name,
|
200653
200711
|
filePath: "",
|
200654
|
-
content: await file.
|
200712
|
+
content: Buffer.from(await file.arrayBuffer()),
|
200655
200713
|
type: fromMimeType(file.type)
|
200656
200714
|
})
|
200657
200715
|
)
|
@@ -200911,7 +200969,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
200911
200969
|
bundle: true,
|
200912
200970
|
additionalModules: [],
|
200913
200971
|
moduleCollector,
|
200914
|
-
|
200972
|
+
serveLegacyAssetsFromWorker: false,
|
200915
200973
|
doBindings: config.durable_objects.bindings,
|
200916
200974
|
jsxFactory,
|
200917
200975
|
jsxFragment,
|
@@ -201025,8 +201083,11 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
201025
201083
|
}
|
201026
201084
|
}
|
201027
201085
|
printBindings({ ...withoutStaticAssets, vars: maskedVars });
|
201028
|
-
if (
|
201086
|
+
if (props.dryRun) {
|
201087
|
+
printBindings({ ...withoutStaticAssets, vars: maskedVars });
|
201088
|
+
} else {
|
201029
201089
|
await ensureQueuesExistByConfig(config);
|
201090
|
+
let bindingsPrinted = false;
|
201030
201091
|
try {
|
201031
201092
|
const body = createWorkerUploadForm(worker);
|
201032
201093
|
const result = await fetchResult(
|
@@ -201043,8 +201104,14 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
201043
201104
|
excludeScript: "true"
|
201044
201105
|
})
|
201045
201106
|
);
|
201107
|
+
logger.log("Worker Startup Time:", result.startup_time_ms, "ms");
|
201108
|
+
bindingsPrinted = true;
|
201109
|
+
printBindings({ ...withoutStaticAssets, vars: maskedVars });
|
201046
201110
|
logger.log("Worker Version ID:", result.id);
|
201047
201111
|
} catch (err) {
|
201112
|
+
if (!bindingsPrinted) {
|
201113
|
+
printBindings({ ...withoutStaticAssets, vars: maskedVars });
|
201114
|
+
}
|
201048
201115
|
helpIfErrorIsSizeOrScriptStartup(err, dependencies);
|
201049
201116
|
if (err instanceof ParseError && "code" in err && err.code === 10021 && err.notes.length > 0) {
|
201050
201117
|
const maybeNameToFilePath = /* @__PURE__ */ __name((moduleName) => {
|
@@ -201356,20 +201423,39 @@ function versionsUploadOptions(yargs) {
|
|
201356
201423
|
describe: "Use the latest version of the worker runtime",
|
201357
201424
|
type: "boolean",
|
201358
201425
|
default: false
|
201426
|
+
}).option("legacy-assets", {
|
201427
|
+
describe: "(Experimental) Static assets to be served",
|
201428
|
+
type: "string",
|
201429
|
+
requiresArg: true,
|
201430
|
+
hidden: true
|
201431
|
+
}).option("assets", {
|
201432
|
+
describe: "(Experimental) Static assets to be served",
|
201433
|
+
type: "string",
|
201434
|
+
requiresArg: true,
|
201435
|
+
hidden: true
|
201436
|
+
}).option("experimental-assets", {
|
201437
|
+
describe: "Static assets to be served",
|
201438
|
+
type: "string",
|
201439
|
+
alias: "x-assets",
|
201440
|
+
requiresArg: true,
|
201441
|
+
hidden: true
|
201359
201442
|
}).option("site", {
|
201360
201443
|
describe: "Root folder of static assets for Workers Sites",
|
201361
201444
|
type: "string",
|
201362
|
-
requiresArg: true
|
201445
|
+
requiresArg: true,
|
201446
|
+
hidden: true
|
201363
201447
|
}).option("site-include", {
|
201364
201448
|
describe: "Array of .gitignore-style patterns that match file or directory names from the sites directory. Only matched items will be uploaded.",
|
201365
201449
|
type: "string",
|
201366
201450
|
requiresArg: true,
|
201367
|
-
array: true
|
201451
|
+
array: true,
|
201452
|
+
hidden: true
|
201368
201453
|
}).option("site-exclude", {
|
201369
201454
|
describe: "Array of .gitignore-style patterns that match file or directory names from the sites directory. Matched items will not be uploaded.",
|
201370
201455
|
type: "string",
|
201371
201456
|
requiresArg: true,
|
201372
|
-
array: true
|
201457
|
+
array: true,
|
201458
|
+
hidden: true
|
201373
201459
|
}).option("var", {
|
201374
201460
|
describe: "A key-value pair to be injected into the script as a variable",
|
201375
201461
|
type: "string",
|
@@ -201425,7 +201511,7 @@ async function versionsUploadHandler(args) {
|
|
201425
201511
|
const configPath = args.config || args.script && findWranglerToml(import_node_path57.default.dirname(args.script));
|
201426
201512
|
const projectRoot = configPath && import_node_path57.default.dirname(configPath);
|
201427
201513
|
const config = readConfig(configPath, args);
|
201428
|
-
const entry = await getEntry(args, config, "
|
201514
|
+
const entry = await getEntry(args, config, "versions upload");
|
201429
201515
|
await sendMetricsEvent(
|
201430
201516
|
"upload worker version",
|
201431
201517
|
{
|
@@ -201435,6 +201521,18 @@ async function versionsUploadHandler(args) {
|
|
201435
201521
|
sendMetrics: config.send_metrics
|
201436
201522
|
}
|
201437
201523
|
);
|
201524
|
+
args.legacyAssets = args.legacyAssets ?? args.assets;
|
201525
|
+
if (args.site || config.site) {
|
201526
|
+
throw new UserError(
|
201527
|
+
"Workers Sites does not support uploading versions through `wrangler versions upload`. You must use `wrangler deploy` instead."
|
201528
|
+
);
|
201529
|
+
}
|
201530
|
+
if (args.legacyAssets || config.legacy_assets) {
|
201531
|
+
throw new UserError(
|
201532
|
+
"Legacy Assets does not support uploading versions through `wrangler versions upload`. You must use `wrangler deploy` instead."
|
201533
|
+
);
|
201534
|
+
}
|
201535
|
+
const experimentalAssets = processExperimentalAssetsArg(args, config);
|
201438
201536
|
if (args.latest) {
|
201439
201537
|
logger.warn(
|
201440
201538
|
"Using the latest version of the Workers runtime. To silence this warning, please choose a specific version of the runtime with --compatibility-date, or add a compatibility_date to your wrangler.toml.\n"
|
@@ -201461,6 +201559,7 @@ async function versionsUploadHandler(args) {
|
|
201461
201559
|
jsxFactory: args.jsxFactory,
|
201462
201560
|
jsxFragment: args.jsxFragment,
|
201463
201561
|
tsconfig: args.tsconfig,
|
201562
|
+
experimentalAssets: experimentalAssets?.directory,
|
201464
201563
|
minify: args.minify,
|
201465
201564
|
uploadSourceMaps: args.uploadSourceMaps,
|
201466
201565
|
nodeCompat: args.nodeCompat,
|
@@ -204224,7 +204323,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
204224
204323
|
return {};
|
204225
204324
|
}
|
204226
204325
|
}
|
204227
|
-
if (!props.isWorkersSite && Boolean(props.
|
204326
|
+
if (!props.isWorkersSite && Boolean(props.legacyAssetPaths) && format10 === "service-worker") {
|
204228
204327
|
throw new UserError(
|
204229
204328
|
"You cannot use the service-worker format with an `assets` directory yet. For information on how to migrate to the module-worker format, see: https://developers.cloudflare.com/workers/learning/migrating-to-module-workers/"
|
204230
204329
|
);
|
@@ -204281,7 +204380,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
204281
204380
|
bundle: true,
|
204282
204381
|
additionalModules: [],
|
204283
204382
|
moduleCollector,
|
204284
|
-
|
204383
|
+
serveLegacyAssetsFromWorker: !props.isWorkersSite && Boolean(props.legacyAssetPaths),
|
204285
204384
|
doBindings: config.durable_objects.bindings,
|
204286
204385
|
jsxFactory,
|
204287
204386
|
jsxFragment,
|
@@ -204332,7 +204431,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
204332
204431
|
// include it in the kv namespace name regardless (since there's no
|
204333
204432
|
// concept of service environments for kv namespaces yet).
|
204334
204433
|
scriptName + (!props.legacyEnv && props.env ? `-${props.env}` : ""),
|
204335
|
-
props.
|
204434
|
+
props.legacyAssetPaths,
|
204336
204435
|
false,
|
204337
204436
|
props.dryRun,
|
204338
204437
|
props.oldAssetTtl
|
@@ -204425,9 +204524,11 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
204425
204524
|
maskedVars[key] = "(hidden)";
|
204426
204525
|
}
|
204427
204526
|
}
|
204428
|
-
|
204429
|
-
|
204527
|
+
if (props.dryRun) {
|
204528
|
+
printBindings({ ...withoutStaticAssets, vars: maskedVars });
|
204529
|
+
} else {
|
204430
204530
|
await ensureQueuesExistByConfig(config);
|
204531
|
+
let bindingsPrinted = false;
|
204431
204532
|
try {
|
204432
204533
|
const result = await fetchResult(
|
204433
204534
|
workerUrl,
|
@@ -204443,6 +204544,9 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
204443
204544
|
excludeScript: "true"
|
204444
204545
|
})
|
204445
204546
|
);
|
204547
|
+
logger.log("Worker Startup Time:", result.startup_time_ms, "ms");
|
204548
|
+
bindingsPrinted = true;
|
204549
|
+
printBindings({ ...withoutStaticAssets, vars: maskedVars });
|
204446
204550
|
deploymentId = addHyphens(result.deployment_id) ?? result.deployment_id;
|
204447
204551
|
if (config.first_party_worker) {
|
204448
204552
|
if (result.id) {
|
@@ -204462,6 +204566,9 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
204462
204566
|
}
|
204463
204567
|
}
|
204464
204568
|
} catch (err) {
|
204569
|
+
if (!bindingsPrinted) {
|
204570
|
+
printBindings({ ...withoutStaticAssets, vars: maskedVars });
|
204571
|
+
}
|
204465
204572
|
helpIfErrorIsSizeOrScriptStartup2(err, dependencies);
|
204466
204573
|
if (err instanceof APIError && "code" in err && err.code === 10021 && err.notes.length > 0) {
|
204467
204574
|
err.preventReport();
|
@@ -205475,7 +205582,7 @@ function Remote(props) {
|
|
205475
205582
|
modules: props.bundle ? props.bundle.modules : [],
|
205476
205583
|
accountId: props.accountId,
|
205477
205584
|
bindings: props.bindings,
|
205478
|
-
|
205585
|
+
legacyAssetPaths: props.legacyAssetPaths,
|
205479
205586
|
isWorkersSite: props.isWorkersSite,
|
205480
205587
|
compatibilityDate: props.compatibilityDate,
|
205481
205588
|
compatibilityFlags: props.compatibilityFlags,
|
@@ -205597,7 +205704,7 @@ function useWorker(props) {
|
|
205597
205704
|
legacyEnv: props.legacyEnv,
|
205598
205705
|
env: props.env,
|
205599
205706
|
isWorkersSite: props.isWorkersSite,
|
205600
|
-
|
205707
|
+
legacyAssetPaths: props.legacyAssetPaths,
|
205601
205708
|
format: props.format,
|
205602
205709
|
bindings: props.bindings,
|
205603
205710
|
compatibilityDate: props.compatibilityDate,
|
@@ -205672,7 +205779,7 @@ function useWorker(props) {
|
|
205672
205779
|
props.bundle,
|
205673
205780
|
props.format,
|
205674
205781
|
props.accountId,
|
205675
|
-
props.
|
205782
|
+
props.legacyAssetPaths,
|
205676
205783
|
props.isWorkersSite,
|
205677
205784
|
props.compatibilityDate,
|
205678
205785
|
props.compatibilityFlags,
|
@@ -205720,7 +205827,7 @@ async function startRemoteServer(props) {
|
|
205720
205827
|
}
|
205721
205828
|
const previewServer = await startPreviewServer({
|
205722
205829
|
previewToken,
|
205723
|
-
assetDirectory: props.isWorkersSite ? void 0 : props.
|
205830
|
+
assetDirectory: props.isWorkersSite ? void 0 : props.legacyAssetPaths?.assetDirectory,
|
205724
205831
|
localProtocol: props.localProtocol,
|
205725
205832
|
customHttpsKeyPath: props.httpsKeyPath,
|
205726
205833
|
customHttpsCertPath: props.httpsCertPath,
|
@@ -205801,7 +205908,7 @@ async function getRemotePreviewToken(props) {
|
|
205801
205908
|
legacyEnv: props.legacyEnv,
|
205802
205909
|
env: props.env,
|
205803
205910
|
isWorkersSite: props.isWorkersSite,
|
205804
|
-
|
205911
|
+
legacyAssetPaths: props.legacyAssetPaths,
|
205805
205912
|
format: props.format,
|
205806
205913
|
bindings: props.bindings,
|
205807
205914
|
compatibilityDate: props.compatibilityDate,
|
@@ -205849,7 +205956,7 @@ async function createRemoteWorkerInit(props) {
|
|
205849
205956
|
// include it in the kv namespace name regardless (since there's no
|
205850
205957
|
// concept of service environments for kv namespaces yet).
|
205851
205958
|
props.name + (!props.legacyEnv && props.env ? `-${props.env}` : ""),
|
205852
|
-
props.isWorkersSite ? props.
|
205959
|
+
props.isWorkersSite ? props.legacyAssetPaths : void 0,
|
205853
205960
|
true,
|
205854
205961
|
false,
|
205855
205962
|
void 0
|
@@ -205991,7 +206098,7 @@ function runBuild({
|
|
205991
206098
|
additionalModules,
|
205992
206099
|
rules,
|
205993
206100
|
legacyAssets,
|
205994
|
-
|
206101
|
+
serveLegacyAssetsFromWorker,
|
205995
206102
|
tsconfig,
|
205996
206103
|
minify,
|
205997
206104
|
nodejsCompatMode,
|
@@ -206081,7 +206188,7 @@ function runBuild({
|
|
206081
206188
|
bundle: !noBundle,
|
206082
206189
|
moduleCollector,
|
206083
206190
|
additionalModules: newAdditionalModules,
|
206084
|
-
|
206191
|
+
serveLegacyAssetsFromWorker,
|
206085
206192
|
jsxFactory,
|
206086
206193
|
jsxFragment,
|
206087
206194
|
watch: true,
|
@@ -206148,7 +206255,7 @@ function useEsbuild({
|
|
206148
206255
|
additionalModules,
|
206149
206256
|
rules,
|
206150
206257
|
legacyAssets,
|
206151
|
-
|
206258
|
+
serveLegacyAssetsFromWorker,
|
206152
206259
|
tsconfig,
|
206153
206260
|
minify,
|
206154
206261
|
nodejsCompatMode,
|
@@ -206178,7 +206285,7 @@ function useEsbuild({
|
|
206178
206285
|
additionalModules,
|
206179
206286
|
rules,
|
206180
206287
|
legacyAssets,
|
206181
|
-
|
206288
|
+
serveLegacyAssetsFromWorker,
|
206182
206289
|
tsconfig,
|
206183
206290
|
minify,
|
206184
206291
|
nodejsCompatMode,
|
@@ -206205,7 +206312,7 @@ function useEsbuild({
|
|
206205
206312
|
destination,
|
206206
206313
|
jsxFactory,
|
206207
206314
|
jsxFragment,
|
206208
|
-
|
206315
|
+
serveLegacyAssetsFromWorker,
|
206209
206316
|
processEntrypoint,
|
206210
206317
|
additionalModules,
|
206211
206318
|
rules,
|
@@ -206238,7 +206345,7 @@ __name(useEsbuild, "useEsbuild");
|
|
206238
206345
|
// src/dev/validate-dev-props.ts
|
206239
206346
|
init_import_meta_url();
|
206240
206347
|
function validateDevProps(props) {
|
206241
|
-
if (!props.isWorkersSite && props.
|
206348
|
+
if (!props.isWorkersSite && props.legacyAssetPaths && props.entry.format === "service-worker") {
|
206242
206349
|
throw new UserError(
|
206243
206350
|
"You cannot use the service-worker format with an `assets` directory yet. For information on how to migrate to the module-worker format, see: https://developers.cloudflare.com/workers/learning/migrating-to-module-workers/"
|
206244
206351
|
);
|
@@ -206540,20 +206647,23 @@ function DevSession(props) {
|
|
206540
206647
|
persist: ""
|
206541
206648
|
},
|
206542
206649
|
legacy: {
|
206543
|
-
site: props.isWorkersSite && props.
|
206650
|
+
site: props.isWorkersSite && props.legacyAssetPaths ? {
|
206544
206651
|
bucket: path66.join(
|
206545
|
-
props.
|
206546
|
-
props.
|
206652
|
+
props.legacyAssetPaths.baseDirectory,
|
206653
|
+
props.legacyAssetPaths?.assetDirectory
|
206547
206654
|
),
|
206548
|
-
include: props.
|
206549
|
-
exclude: props.
|
206655
|
+
include: props.legacyAssetPaths.includePatterns,
|
206656
|
+
exclude: props.legacyAssetPaths.excludePatterns
|
206550
206657
|
} : void 0,
|
206551
|
-
legacyAssets: props.
|
206658
|
+
legacyAssets: props.legacyAssetsConfig,
|
206552
206659
|
enableServiceEnvironments: !props.legacyEnv
|
206553
206660
|
},
|
206554
206661
|
unsafe: {
|
206555
206662
|
capnp: props.bindings.unsafe?.capnp,
|
206556
206663
|
metadata: props.bindings.unsafe?.metadata
|
206664
|
+
},
|
206665
|
+
experimental: {
|
206666
|
+
assets: props.experimentalAssets
|
206557
206667
|
}
|
206558
206668
|
};
|
206559
206669
|
}, [
|
@@ -206565,10 +206675,11 @@ function DevSession(props) {
|
|
206565
206675
|
props.compatibilityFlags,
|
206566
206676
|
props.bindings,
|
206567
206677
|
props.entry,
|
206568
|
-
props.
|
206678
|
+
props.legacyAssetPaths,
|
206569
206679
|
props.isWorkersSite,
|
206570
206680
|
props.local,
|
206571
|
-
props.
|
206681
|
+
props.legacyAssetsConfig,
|
206682
|
+
props.experimentalAssets,
|
206572
206683
|
props.processEntrypoint,
|
206573
206684
|
props.additionalModules,
|
206574
206685
|
props.env,
|
@@ -206646,8 +206757,8 @@ function DevSession(props) {
|
|
206646
206757
|
additionalModules: props.additionalModules,
|
206647
206758
|
rules: props.rules,
|
206648
206759
|
jsxFragment: props.jsxFragment,
|
206649
|
-
|
206650
|
-
props.
|
206760
|
+
serveLegacyAssetsFromWorker: Boolean(
|
206761
|
+
props.legacyAssetPaths && !props.isWorkersSite && props.local
|
206651
206762
|
),
|
206652
206763
|
tsconfig: props.tsconfig,
|
206653
206764
|
minify: props.minify,
|
@@ -206656,7 +206767,7 @@ function DevSession(props) {
|
|
206656
206767
|
alias: props.alias,
|
206657
206768
|
noBundle: props.noBundle,
|
206658
206769
|
findAdditionalModules: props.findAdditionalModules,
|
206659
|
-
legacyAssets: props.
|
206770
|
+
legacyAssets: props.legacyAssetsConfig,
|
206660
206771
|
durableObjects: props.bindings.durable_objects || { bindings: [] },
|
206661
206772
|
local: props.local,
|
206662
206773
|
// Enable the bundling to know whether we are using dev or deploy
|
@@ -206721,7 +206832,8 @@ function DevSession(props) {
|
|
206721
206832
|
usageModel: props.usageModel,
|
206722
206833
|
bindings: props.bindings,
|
206723
206834
|
workerDefinitions,
|
206724
|
-
|
206835
|
+
legacyAssetPaths: props.legacyAssetPaths,
|
206836
|
+
experimentalAssets: props.experimentalAssets,
|
206725
206837
|
initialPort: void 0,
|
206726
206838
|
initialIp: "127.0.0.1",
|
206727
206839
|
rules: props.rules,
|
@@ -206749,7 +206861,7 @@ function DevSession(props) {
|
|
206749
206861
|
bundle,
|
206750
206862
|
format: props.entry.format,
|
206751
206863
|
bindings: props.bindings,
|
206752
|
-
|
206864
|
+
legacyAssetPaths: props.legacyAssetPaths,
|
206753
206865
|
isWorkersSite: props.isWorkersSite,
|
206754
206866
|
port: props.initialPort,
|
206755
206867
|
ip: props.initialIp,
|
@@ -207132,6 +207244,7 @@ __name(registerDevHotKeys, "registerDevHotKeys");
|
|
207132
207244
|
|
207133
207245
|
// src/dev/start-server.ts
|
207134
207246
|
init_import_meta_url();
|
207247
|
+
var import_node_events2 = require("node:events");
|
207135
207248
|
var import_promises25 = require("node:fs/promises");
|
207136
207249
|
var path67 = __toESM(require("node:path"));
|
207137
207250
|
var util3 = __toESM(require("node:util"));
|
@@ -207172,7 +207285,15 @@ async function startDevServer(props) {
|
|
207172
207285
|
const devEnv = props.devEnv;
|
207173
207286
|
const startDevWorkerOptions = {
|
207174
207287
|
name: props.name ?? "worker",
|
207288
|
+
config: props.rawConfig.configPath,
|
207175
207289
|
entrypoint: props.entry.file,
|
207290
|
+
compatibilityDate: props.compatibilityDate,
|
207291
|
+
compatibilityFlags: props.compatibilityFlags,
|
207292
|
+
triggers: props.routes?.map((r3) => ({
|
207293
|
+
type: "route",
|
207294
|
+
...typeof r3 === "string" ? { pattern: r3 } : r3
|
207295
|
+
})),
|
207296
|
+
bindings: convertCfWorkerInitBindingstoBindings(props.bindings),
|
207176
207297
|
dev: {
|
207177
207298
|
server: {
|
207178
207299
|
hostname: props.initialIp,
|
@@ -207186,10 +207307,10 @@ async function startDevServer(props) {
|
|
207186
207307
|
},
|
207187
207308
|
origin: {
|
207188
207309
|
secure: props.upstreamProtocol === "https",
|
207189
|
-
hostname: props.localUpstream
|
207310
|
+
hostname: props.host ?? props.localUpstream
|
207190
207311
|
},
|
207191
207312
|
liveReload: props.liveReload,
|
207192
|
-
remote: !props.local,
|
207313
|
+
remote: !props.forceLocal && !props.local,
|
207193
207314
|
auth: async () => {
|
207194
207315
|
let accountId = props.accountId;
|
207195
207316
|
if (accountId === void 0) {
|
@@ -207207,24 +207328,71 @@ async function startDevServer(props) {
|
|
207207
207328
|
}
|
207208
207329
|
}
|
207209
207330
|
return { accountId, apiToken: requireApiToken() };
|
207210
|
-
}
|
207331
|
+
},
|
207332
|
+
persist: props.localPersistencePath ?? void 0,
|
207333
|
+
testScheduled: props.testScheduled,
|
207334
|
+
registry: workerDefinitions
|
207211
207335
|
},
|
207212
207336
|
build: {
|
207213
|
-
|
207337
|
+
bundle: !props.noBundle,
|
207338
|
+
define: props.define,
|
207339
|
+
jsxFactory: props.jsxFactory,
|
207340
|
+
jsxFragment: props.jsxFragment,
|
207341
|
+
tsconfig: props.tsconfig,
|
207342
|
+
minify: props.minify,
|
207343
|
+
processEntrypoint: props.processEntrypoint,
|
207344
|
+
additionalModules: props.additionalModules,
|
207214
207345
|
moduleRoot: props.entry.moduleRoot,
|
207215
|
-
|
207346
|
+
moduleRules: props.rules,
|
207347
|
+
nodejsCompatMode: props.nodejsCompatMode
|
207216
207348
|
}
|
207217
207349
|
};
|
207218
|
-
if (
|
207219
|
-
devEnv.
|
207220
|
-
|
207221
|
-
|
207222
|
-
|
207223
|
-
|
207224
|
-
|
207225
|
-
config: fakeResolvedInput(startDevWorkerOptions)
|
207350
|
+
if (props.experimentalDevEnv) {
|
207351
|
+
devEnv.runtimes.forEach((runtime) => {
|
207352
|
+
runtime.on("reloadComplete", async (ev) => {
|
207353
|
+
const { proxyWorker } = await devEnv.proxy.ready.promise;
|
207354
|
+
const url4 = await proxyWorker.ready;
|
207355
|
+
props.onReady?.(url4.hostname, parseInt(url4.port), ev.proxyData);
|
207356
|
+
});
|
207226
207357
|
});
|
207358
|
+
await devEnv.config.set(startDevWorkerOptions);
|
207359
|
+
const stop = /* @__PURE__ */ __name(async () => {
|
207360
|
+
await Promise.allSettled([stopWorkerRegistry(), devEnv.teardown()]);
|
207361
|
+
}, "stop");
|
207362
|
+
try {
|
207363
|
+
await Promise.all([
|
207364
|
+
// adhere to unstable_dev contract:
|
207365
|
+
// - only resolve when UserWorker is ready
|
207366
|
+
// - reject if UserWorker fails to start
|
207367
|
+
Promise.race(
|
207368
|
+
devEnv.runtimes.flatMap((runtime) => [
|
207369
|
+
(0, import_node_events2.once)(runtime, "reloadComplete"),
|
207370
|
+
(0, import_node_events2.once)(runtime, "error").then((err) => Promise.reject(err))
|
207371
|
+
])
|
207372
|
+
),
|
207373
|
+
// adhere to unstable_dev contract:
|
207374
|
+
// - only resolve when _perceived_ UserWorker is ready
|
207375
|
+
// - throw if _perceived_ UserWorker fails to start
|
207376
|
+
// to the eyeball, the ProxyWorker is the _perceived_ UserWorker
|
207377
|
+
Promise.race([
|
207378
|
+
devEnv.proxy.ready.promise,
|
207379
|
+
(0, import_node_events2.once)(devEnv.proxy, "error").then((err) => Promise.reject(err))
|
207380
|
+
])
|
207381
|
+
]);
|
207382
|
+
} catch (err) {
|
207383
|
+
await stop();
|
207384
|
+
throw err;
|
207385
|
+
}
|
207386
|
+
return { stop };
|
207227
207387
|
}
|
207388
|
+
devEnv.proxy.onConfigUpdate({
|
207389
|
+
type: "configUpdate",
|
207390
|
+
config: fakeResolvedInput(startDevWorkerOptions)
|
207391
|
+
});
|
207392
|
+
devEnv.proxy.onBundleStart({
|
207393
|
+
type: "bundleStart",
|
207394
|
+
config: fakeResolvedInput(startDevWorkerOptions)
|
207395
|
+
});
|
207228
207396
|
const bundle = await runEsbuild({
|
207229
207397
|
entry: props.entry,
|
207230
207398
|
destination: directory,
|
@@ -207233,8 +207401,8 @@ async function startDevServer(props) {
|
|
207233
207401
|
additionalModules: props.additionalModules,
|
207234
207402
|
rules: props.rules,
|
207235
207403
|
jsxFragment: props.jsxFragment,
|
207236
|
-
|
207237
|
-
props.
|
207404
|
+
serveLegacyAssetsFromWorker: Boolean(
|
207405
|
+
props.legacyAssetPaths && !props.isWorkersSite && props.local
|
207238
207406
|
),
|
207239
207407
|
tsconfig: props.tsconfig,
|
207240
207408
|
minify: props.minify,
|
@@ -207243,7 +207411,7 @@ async function startDevServer(props) {
|
|
207243
207411
|
noBundle: props.noBundle,
|
207244
207412
|
findAdditionalModules: props.findAdditionalModules,
|
207245
207413
|
alias: props.alias,
|
207246
|
-
legacyAssets: props.
|
207414
|
+
legacyAssets: props.legacyAssetsConfig,
|
207247
207415
|
testScheduled: props.testScheduled,
|
207248
207416
|
local: props.local,
|
207249
207417
|
doBindings: props.bindings.durable_objects?.bindings ?? [],
|
@@ -207253,15 +207421,6 @@ async function startDevServer(props) {
|
|
207253
207421
|
props.compatibilityFlags
|
207254
207422
|
)
|
207255
207423
|
});
|
207256
|
-
if (props.experimentalDevEnv) {
|
207257
|
-
devEnv.runtimes.forEach((runtime) => {
|
207258
|
-
runtime.on("reloadComplete", async (ev) => {
|
207259
|
-
const { proxyWorker } = await devEnv.proxy.ready.promise;
|
207260
|
-
const url4 = await proxyWorker.ready;
|
207261
|
-
props.onReady?.(url4.hostname, parseInt(url4.port), ev.proxyData);
|
207262
|
-
});
|
207263
|
-
});
|
207264
|
-
}
|
207265
207424
|
if (props.local) {
|
207266
207425
|
devEnv.proxy.onReloadStart({
|
207267
207426
|
type: "reloadStart",
|
@@ -207275,7 +207434,8 @@ async function startDevServer(props) {
|
|
207275
207434
|
compatibilityDate: props.compatibilityDate,
|
207276
207435
|
compatibilityFlags: props.compatibilityFlags,
|
207277
207436
|
bindings: props.bindings,
|
207278
|
-
|
207437
|
+
legacyAssetPaths: props.legacyAssetPaths,
|
207438
|
+
experimentalAssets: props.experimentalAssets,
|
207279
207439
|
initialPort: void 0,
|
207280
207440
|
// hard-code for userworker, DevEnv-ProxyWorker now uses this prop value
|
207281
207441
|
initialIp: "127.0.0.1",
|
@@ -207337,7 +207497,7 @@ async function startDevServer(props) {
|
|
207337
207497
|
format: props.entry.format,
|
207338
207498
|
accountId: props.accountId,
|
207339
207499
|
bindings: props.bindings,
|
207340
|
-
|
207500
|
+
legacyAssetPaths: props.legacyAssetPaths,
|
207341
207501
|
isWorkersSite: props.isWorkersSite,
|
207342
207502
|
port: props.initialPort,
|
207343
207503
|
ip: props.initialIp,
|
@@ -207408,7 +207568,7 @@ async function runEsbuild({
|
|
207408
207568
|
rules,
|
207409
207569
|
alias,
|
207410
207570
|
legacyAssets,
|
207411
|
-
|
207571
|
+
serveLegacyAssetsFromWorker,
|
207412
207572
|
tsconfig,
|
207413
207573
|
minify,
|
207414
207574
|
nodejsCompatMode,
|
@@ -207441,7 +207601,7 @@ async function runEsbuild({
|
|
207441
207601
|
bundle: !noBundle,
|
207442
207602
|
additionalModules,
|
207443
207603
|
moduleCollector,
|
207444
|
-
|
207604
|
+
serveLegacyAssetsFromWorker,
|
207445
207605
|
jsxFactory,
|
207446
207606
|
jsxFragment,
|
207447
207607
|
tsconfig,
|
@@ -207955,7 +208115,7 @@ Please shift to the --legacy-assets command to preserve the current functionalit
|
|
207955
208115
|
);
|
207956
208116
|
if (args.experimentalDevEnv) {
|
207957
208117
|
(0, import_node_assert21.default)(devInstance instanceof DevEnv);
|
207958
|
-
await
|
208118
|
+
await import_node_events3.default.once(devInstance, "teardown");
|
207959
208119
|
} else {
|
207960
208120
|
(0, import_node_assert21.default)(!(devInstance instanceof DevEnv));
|
207961
208121
|
watcher = devInstance.watcher;
|
@@ -207988,7 +208148,7 @@ async function updateDevEnvRegistry(devEnv, registry) {
|
|
207988
208148
|
boundWorkers = void 0;
|
207989
208149
|
}
|
207990
208150
|
if (!devEnv.config.latestConfig) {
|
207991
|
-
await
|
208151
|
+
await import_node_events3.default.once(devEnv, "configUpdate");
|
207992
208152
|
}
|
207993
208153
|
if (import_node_util3.default.isDeepStrictEqual(
|
207994
208154
|
boundWorkers,
|
@@ -208004,6 +208164,21 @@ async function updateDevEnvRegistry(devEnv, registry) {
|
|
208004
208164
|
});
|
208005
208165
|
}
|
208006
208166
|
__name(updateDevEnvRegistry, "updateDevEnvRegistry");
|
208167
|
+
async function getPagesAssetsFetcher(options21) {
|
208168
|
+
if (options21 !== void 0) {
|
208169
|
+
const generateASSETSBinding3 = (init_assets(), __toCommonJS(assets_exports)).default;
|
208170
|
+
return {
|
208171
|
+
ASSETS: {
|
208172
|
+
type: "fetcher",
|
208173
|
+
fetcher: await generateASSETSBinding3({
|
208174
|
+
log: logger,
|
208175
|
+
...options21
|
208176
|
+
})
|
208177
|
+
}
|
208178
|
+
};
|
208179
|
+
}
|
208180
|
+
}
|
208181
|
+
__name(getPagesAssetsFetcher, "getPagesAssetsFetcher");
|
208007
208182
|
async function startDev(args) {
|
208008
208183
|
let watcher;
|
208009
208184
|
let rerender;
|
@@ -208045,6 +208220,15 @@ Move any existing data to .wrangler/state and use --persist, or
|
|
208045
208220
|
use --persist-to=./wrangler-local-state to keep using the old path.`
|
208046
208221
|
);
|
208047
208222
|
}
|
208223
|
+
const experimentalAssets = processExperimentalAssetsArg(args, config);
|
208224
|
+
if (experimentalAssets) {
|
208225
|
+
args.forceLocal = true;
|
208226
|
+
}
|
208227
|
+
if ((args.legacyAssets || config.legacy_assets) && experimentalAssets) {
|
208228
|
+
throw new UserError(
|
208229
|
+
"Cannot use Legacy Assets and Experimental Assets in the same Worker."
|
208230
|
+
);
|
208231
|
+
}
|
208048
208232
|
const projectRoot = configPath && import_node_path63.default.dirname(configPath);
|
208049
208233
|
const devEnv = new DevEnv();
|
208050
208234
|
if (args.experimentalDevEnv) {
|
@@ -208118,6 +208302,9 @@ use --persist-to=./wrangler-local-state to keep using the old path.`
|
|
208118
208302
|
})
|
208119
208303
|
},
|
208120
208304
|
bindings: {
|
208305
|
+
...await getPagesAssetsFetcher(
|
208306
|
+
args.enablePagesAssetsServiceBinding
|
208307
|
+
),
|
208121
208308
|
...collectPlainTextVars(args.var),
|
208122
208309
|
...convertCfWorkerInitBindingstoBindings({
|
208123
208310
|
kv_namespaces: args.kv,
|
@@ -208179,18 +208366,24 @@ use --persist-to=./wrangler-local-state to keep using the old path.`
|
|
208179
208366
|
},
|
208180
208367
|
legacy: {
|
208181
208368
|
site: (configParam) => {
|
208182
|
-
const
|
208183
|
-
|
208369
|
+
const legacyAssetPaths = getResolvedLegacyAssetPaths(
|
208370
|
+
args,
|
208371
|
+
configParam
|
208372
|
+
);
|
208373
|
+
return Boolean(args.site || configParam.site) && legacyAssetPaths ? {
|
208184
208374
|
bucket: import_node_path63.default.join(
|
208185
|
-
|
208186
|
-
|
208375
|
+
legacyAssetPaths.baseDirectory,
|
208376
|
+
legacyAssetPaths?.assetDirectory
|
208187
208377
|
),
|
208188
|
-
include:
|
208189
|
-
exclude:
|
208378
|
+
include: legacyAssetPaths.includePatterns,
|
208379
|
+
exclude: legacyAssetPaths.excludePatterns
|
208190
208380
|
} : void 0;
|
208191
208381
|
},
|
208192
208382
|
legacyAssets: (configParam) => configParam.legacy_assets,
|
208193
208383
|
enableServiceEnvironments: !(args.legacyEnv ?? true)
|
208384
|
+
},
|
208385
|
+
experimental: {
|
208386
|
+
assets: experimentalAssets
|
208194
208387
|
}
|
208195
208388
|
});
|
208196
208389
|
void sendMetricsEvent(
|
@@ -208219,26 +208412,6 @@ use --persist-to=./wrangler-local-state to keep using the old path.`
|
|
208219
208412
|
}
|
208220
208413
|
});
|
208221
208414
|
}
|
208222
|
-
const experimentalAssets = args.experimentalAssets ? { directory: args.experimentalAssets } : config.experimental_assets;
|
208223
|
-
if (experimentalAssets) {
|
208224
|
-
const experimentalAssetsBasePath = getExperimentalAssetsBasePath(
|
208225
|
-
config,
|
208226
|
-
args.experimentalAssets
|
208227
|
-
);
|
208228
|
-
const resolvedExperimentalAssetsPath = import_node_path63.default.resolve(
|
208229
|
-
experimentalAssetsBasePath,
|
208230
|
-
experimentalAssets.directory
|
208231
|
-
);
|
208232
|
-
if (!(0, import_node_fs35.existsSync)(resolvedExperimentalAssetsPath)) {
|
208233
|
-
const sourceOfTruthMessage = args.experimentalAssets ? '"--experimental-assets" command line argument' : '"experimental_assets.directory" field in your configuration file';
|
208234
|
-
throw new UserError(
|
208235
|
-
`The directory specified by the ${sourceOfTruthMessage} does not exist:
|
208236
|
-
${resolvedExperimentalAssetsPath}`
|
208237
|
-
);
|
208238
|
-
}
|
208239
|
-
experimentalAssets.directory = resolvedExperimentalAssetsPath;
|
208240
|
-
args.forceLocal = true;
|
208241
|
-
}
|
208242
208415
|
const {
|
208243
208416
|
entry,
|
208244
208417
|
upstreamProtocol,
|
@@ -208267,7 +208440,7 @@ ${resolvedExperimentalAssetsPath}`
|
|
208267
208440
|
{ sendMetrics: config.send_metrics, offline: !args.remote }
|
208268
208441
|
);
|
208269
208442
|
async function getDevReactElement(configParam) {
|
208270
|
-
const {
|
208443
|
+
const { legacyAssetPaths, bindings } = getBindingsAndLegacyAssetPaths(
|
208271
208444
|
args,
|
208272
208445
|
configParam
|
208273
208446
|
);
|
@@ -208302,8 +208475,9 @@ ${resolvedExperimentalAssetsPath}`
|
|
208302
208475
|
localPersistencePath,
|
208303
208476
|
liveReload: args.liveReload || false,
|
208304
208477
|
accountId: args.accountId ?? configParam.account_id ?? getAccountFromCache()?.id,
|
208305
|
-
|
208306
|
-
|
208478
|
+
legacyAssetPaths,
|
208479
|
+
legacyAssetsConfig: configParam.legacy_assets,
|
208480
|
+
experimentalAssets,
|
208307
208481
|
initialPort: args.port ?? configParam.dev.port ?? await getLocalPort2(),
|
208308
208482
|
initialIp: args.ip || configParam.dev.ip,
|
208309
208483
|
inspectorPort: args.inspectorPort ?? configParam.dev.inspector_port ?? await getInspectorPort2(),
|
@@ -208406,7 +208580,7 @@ async function startApiDev(args) {
|
|
208406
208580
|
});
|
208407
208581
|
}
|
208408
208582
|
async function getDevServer(configParam) {
|
208409
|
-
const {
|
208583
|
+
const { legacyAssetPaths, bindings } = getBindingsAndLegacyAssetPaths(
|
208410
208584
|
args,
|
208411
208585
|
configParam
|
208412
208586
|
);
|
@@ -208441,8 +208615,9 @@ async function startApiDev(args) {
|
|
208441
208615
|
localPersistencePath,
|
208442
208616
|
liveReload: args.liveReload ?? false,
|
208443
208617
|
accountId: args.accountId ?? configParam.account_id ?? getAccountFromCache()?.id,
|
208444
|
-
|
208445
|
-
|
208618
|
+
legacyAssetPaths,
|
208619
|
+
legacyAssetsConfig: configParam.legacy_assets,
|
208620
|
+
experimentalAssets: void 0,
|
208446
208621
|
//port can be 0, which means to use a random port
|
208447
208622
|
initialPort: args.port ?? configParam.dev.port ?? await getLocalPort2(),
|
208448
208623
|
initialIp: args.ip ?? configParam.dev.ip,
|
@@ -208544,6 +208719,16 @@ You can explicitly set the \`dev.host\` configuration in your wrangler.toml file
|
|
208544
208719
|
}
|
208545
208720
|
__name(getInferredHost, "getInferredHost");
|
208546
208721
|
async function validateDevServerSettings(args, config) {
|
208722
|
+
if ((args.legacyAssets || config.legacy_assets) && (args.site || config.site)) {
|
208723
|
+
throw new UserError(
|
208724
|
+
"Cannot use Legacy Assets and Workers Sites in the same Worker."
|
208725
|
+
);
|
208726
|
+
}
|
208727
|
+
if ((args.experimentalAssets || config.experimental_assets) && (args.site || config.site)) {
|
208728
|
+
throw new UserError(
|
208729
|
+
"Cannot use Experimental Assets and Workers Sites in the same Worker."
|
208730
|
+
);
|
208731
|
+
}
|
208547
208732
|
const entry = await getEntry(
|
208548
208733
|
{
|
208549
208734
|
legacyAssets: args.legacyAssets,
|
@@ -208574,11 +208759,6 @@ async function validateDevServerSettings(args, config) {
|
|
208574
208759
|
).join(", ")}`
|
208575
208760
|
);
|
208576
208761
|
}
|
208577
|
-
if ((args.legacyAssets || config.legacy_assets || args.experimentalAssets || config.experimental_assets) && (args.site || config.site)) {
|
208578
|
-
throw new UserError(
|
208579
|
-
"Cannot use Assets and Workers Sites in the same Worker."
|
208580
|
-
);
|
208581
|
-
}
|
208582
208762
|
const upstreamProtocol = args.upstreamProtocol ?? config.dev.upstream_protocol;
|
208583
208763
|
if (upstreamProtocol === "http" && args.remote) {
|
208584
208764
|
logger.warn(
|
@@ -208627,23 +208807,23 @@ function getResolvedBindings(args, configParam) {
|
|
208627
208807
|
return bindings;
|
208628
208808
|
}
|
208629
208809
|
__name(getResolvedBindings, "getResolvedBindings");
|
208630
|
-
function
|
208631
|
-
const
|
208810
|
+
function getResolvedLegacyAssetPaths(args, configParam) {
|
208811
|
+
const legacyAssetPaths = args.legacyAssets || configParam.legacy_assets ? getLegacyAssetPaths(configParam, args.legacyAssets) : getSiteAssetPaths(
|
208632
208812
|
configParam,
|
208633
208813
|
args.site,
|
208634
208814
|
args.siteInclude,
|
208635
208815
|
args.siteExclude
|
208636
208816
|
);
|
208637
|
-
return
|
208817
|
+
return legacyAssetPaths;
|
208638
208818
|
}
|
208639
|
-
__name(
|
208640
|
-
function
|
208819
|
+
__name(getResolvedLegacyAssetPaths, "getResolvedLegacyAssetPaths");
|
208820
|
+
function getBindingsAndLegacyAssetPaths(args, configParam) {
|
208641
208821
|
return {
|
208642
208822
|
bindings: getResolvedBindings(args, configParam),
|
208643
|
-
|
208823
|
+
legacyAssetPaths: getResolvedLegacyAssetPaths(args, configParam)
|
208644
208824
|
};
|
208645
208825
|
}
|
208646
|
-
__name(
|
208826
|
+
__name(getBindingsAndLegacyAssetPaths, "getBindingsAndLegacyAssetPaths");
|
208647
208827
|
function getBindings(configParam, env7, local, args) {
|
208648
208828
|
const kvConfig = (configParam.kv_namespaces || []).map(
|
208649
208829
|
({ binding, preview_id, id }) => {
|
@@ -208845,7 +209025,7 @@ unstable_dev()'s behaviour will likely change in future releases`
|
|
208845
209025
|
localProtocol: options21?.localProtocol,
|
208846
209026
|
httpsKeyPath: options21?.httpsKeyPath,
|
208847
209027
|
httpsCertPath: options21?.httpsCertPath,
|
208848
|
-
experimentalAssets:
|
209028
|
+
experimentalAssets: void 0,
|
208849
209029
|
legacyAssets: options21?.legacyAssets,
|
208850
209030
|
site: options21?.site,
|
208851
209031
|
// Root folder of static assets for Workers Sites
|
@@ -208971,7 +209151,7 @@ init_import_meta_url();
|
|
208971
209151
|
// src/api/startDevWorker/DevEnv.ts
|
208972
209152
|
init_import_meta_url();
|
208973
209153
|
var import_node_assert24 = __toESM(require("node:assert"));
|
208974
|
-
var
|
209154
|
+
var import_node_events6 = require("node:events");
|
208975
209155
|
|
208976
209156
|
// src/api/startDevWorker/BundlerController.ts
|
208977
209157
|
init_import_meta_url();
|
@@ -208982,8 +209162,8 @@ var import_chokidar7 = require("chokidar");
|
|
208982
209162
|
|
208983
209163
|
// src/api/startDevWorker/BaseController.ts
|
208984
209164
|
init_import_meta_url();
|
208985
|
-
var
|
208986
|
-
var TypedEventEmitterImpl =
|
209165
|
+
var import_node_events4 = require("node:events");
|
209166
|
+
var TypedEventEmitterImpl = import_node_events4.EventEmitter;
|
208987
209167
|
var Controller = class extends TypedEventEmitterImpl {
|
208988
209168
|
emitErrorEvent(data) {
|
208989
209169
|
this.emit("error", data);
|
@@ -209068,7 +209248,7 @@ var BundlerController = class extends Controller {
|
|
209068
209248
|
bundle: true,
|
209069
209249
|
additionalModules: [],
|
209070
209250
|
moduleCollector,
|
209071
|
-
|
209251
|
+
serveLegacyAssetsFromWorker: Boolean(
|
209072
209252
|
config.legacy?.legacyAssets && !config.dev?.remote
|
209073
209253
|
),
|
209074
209254
|
doBindings: bindings?.durable_objects?.bindings ?? [],
|
@@ -209168,7 +209348,7 @@ var BundlerController = class extends Controller {
|
|
209168
209348
|
additionalModules: config.build?.additionalModules ?? [],
|
209169
209349
|
rules: config.build.moduleRules,
|
209170
209350
|
legacyAssets: config.legacy?.legacyAssets,
|
209171
|
-
|
209351
|
+
serveLegacyAssetsFromWorker: Boolean(
|
209172
209352
|
config.legacy?.legacyAssets && !config.dev?.remote
|
209173
209353
|
),
|
209174
209354
|
tsconfig: config.build?.tsconfig,
|
@@ -209370,7 +209550,11 @@ async function resolveConfig(config, input) {
|
|
209370
209550
|
{
|
209371
209551
|
legacyAssets: Boolean(legacyAssets),
|
209372
209552
|
script: input.entrypoint,
|
209373
|
-
moduleRoot: input.build?.moduleRoot
|
209553
|
+
moduleRoot: input.build?.moduleRoot,
|
209554
|
+
// getEntry only needs to know if experimental_assets was specified.
|
209555
|
+
// The actualy value is not relevant here, which is why not passing
|
209556
|
+
// the entire ExperimentalAssets object is fine.
|
209557
|
+
experimentalAssets: input?.experimental?.assets?.directory
|
209374
209558
|
},
|
209375
209559
|
config,
|
209376
209560
|
"dev"
|
@@ -209416,6 +209600,9 @@ async function resolveConfig(config, input) {
|
|
209416
209600
|
unsafe: {
|
209417
209601
|
capnp: input.unsafe?.capnp ?? unsafe?.capnp,
|
209418
209602
|
metadata: input.unsafe?.metadata ?? unsafe?.metadata
|
209603
|
+
},
|
209604
|
+
experimental: {
|
209605
|
+
assets: input?.experimental?.assets
|
209419
209606
|
}
|
209420
209607
|
};
|
209421
209608
|
if (resolved.legacy.legacyAssets && resolved.legacy.site) {
|
@@ -209594,12 +209781,13 @@ async function convertToConfigBundle(event) {
|
|
209594
209781
|
compatibilityFlags: event.config.compatibilityFlags,
|
209595
209782
|
bindings,
|
209596
209783
|
workerDefinitions: event.config.dev?.registry,
|
209597
|
-
|
209784
|
+
legacyAssetPaths: event.config.legacy?.site?.bucket ? {
|
209598
209785
|
baseDirectory: event.config.legacy?.site?.bucket,
|
209599
209786
|
assetDirectory: "",
|
209600
209787
|
excludePatterns: event.config.legacy?.site?.exclude ?? [],
|
209601
209788
|
includePatterns: event.config.legacy?.site?.include ?? []
|
209602
209789
|
} : void 0,
|
209790
|
+
experimentalAssets: event.config.experimental?.assets,
|
209603
209791
|
initialPort: void 0,
|
209604
209792
|
initialIp: "127.0.0.1",
|
209605
209793
|
rules: [],
|
@@ -209679,7 +209867,8 @@ var LocalRuntimeController = class extends RuntimeController {
|
|
209679
209867
|
},
|
209680
209868
|
userWorkerInnerUrlOverrides: {
|
209681
209869
|
protocol: data.config?.dev?.origin?.secure ? "https:" : "http:",
|
209682
|
-
hostname: data.config?.dev?.origin?.hostname
|
209870
|
+
hostname: data.config?.dev?.origin?.hostname,
|
209871
|
+
port: data.config?.dev?.origin?.hostname ? "" : void 0
|
209683
209872
|
},
|
209684
209873
|
headers: {
|
209685
209874
|
// Passing this signature from Proxy Worker allows the User Worker to trust the request.
|
@@ -209744,7 +209933,7 @@ __name(LocalRuntimeController, "LocalRuntimeController");
|
|
209744
209933
|
init_import_meta_url();
|
209745
209934
|
var import_node_assert23 = __toESM(require("node:assert"));
|
209746
209935
|
var import_node_crypto9 = require("node:crypto");
|
209747
|
-
var
|
209936
|
+
var import_node_events5 = __toESM(require("node:events"));
|
209748
209937
|
var import_node_path67 = __toESM(require("node:path"));
|
209749
209938
|
var import_miniflare20 = require("miniflare");
|
209750
209939
|
|
@@ -209927,7 +210116,7 @@ var ProxyController = class extends Controller {
|
|
209927
210116
|
}
|
209928
210117
|
void this.reconnectInspectorProxyWorker();
|
209929
210118
|
});
|
209930
|
-
await
|
210119
|
+
await import_node_events5.default.once(webSocket, "open");
|
209931
210120
|
this.inspectorProxyWorkerWebSocket?.resolve(webSocket);
|
209932
210121
|
return webSocket;
|
209933
210122
|
}
|
@@ -209938,12 +210127,12 @@ var ProxyController = class extends Controller {
|
|
209938
210127
|
}
|
209939
210128
|
try {
|
209940
210129
|
await this.runtimeMessageMutex.runWith(async () => {
|
209941
|
-
|
209942
|
-
const ready = await
|
210130
|
+
const { proxyWorker } = await this.ready.promise;
|
210131
|
+
const ready = await proxyWorker.ready.catch(() => void 0);
|
209943
210132
|
if (!ready) {
|
209944
210133
|
return;
|
209945
210134
|
}
|
209946
|
-
return
|
210135
|
+
return proxyWorker.dispatchFetch(
|
209947
210136
|
`http://dummy/cdn-cgi/ProxyWorker/${message.type}`,
|
209948
210137
|
{
|
209949
210138
|
headers: { Authorization: this.secret },
|
@@ -210221,7 +210410,7 @@ var RemoteRuntimeController = class extends RuntimeController {
|
|
210221
210410
|
legacyEnv: props.legacyEnv,
|
210222
210411
|
env: props.env,
|
210223
210412
|
isWorkersSite: props.isWorkersSite,
|
210224
|
-
|
210413
|
+
legacyAssetPaths: props.legacyAssetPaths,
|
210225
210414
|
format: props.format,
|
210226
210415
|
bindings: props.bindings,
|
210227
210416
|
compatibilityDate: props.compatibilityDate,
|
@@ -210299,7 +210488,7 @@ var RemoteRuntimeController = class extends RuntimeController {
|
|
210299
210488
|
legacyEnv: !config.legacy?.enableServiceEnvironments,
|
210300
210489
|
env: config.env,
|
210301
210490
|
isWorkersSite: config.legacy?.site !== void 0,
|
210302
|
-
|
210491
|
+
legacyAssetPaths: config.legacy?.site?.bucket ? {
|
210303
210492
|
baseDirectory: config.legacy?.site?.bucket,
|
210304
210493
|
assetDirectory: "",
|
210305
210494
|
excludePatterns: config.legacy?.site?.exclude ?? [],
|
@@ -210400,7 +210589,7 @@ var RemoteRuntimeController = class extends RuntimeController {
|
|
210400
210589
|
__name(RemoteRuntimeController, "RemoteRuntimeController");
|
210401
210590
|
|
210402
210591
|
// src/api/startDevWorker/DevEnv.ts
|
210403
|
-
var DevEnv = class extends
|
210592
|
+
var DevEnv = class extends import_node_events6.EventEmitter {
|
210404
210593
|
config;
|
210405
210594
|
bundler;
|
210406
210595
|
runtimes;
|
@@ -210841,8 +211030,8 @@ function unstable_getMiniflareWorkerOptions(configPath, env7) {
|
|
210841
211030
|
])
|
210842
211031
|
);
|
210843
211032
|
}
|
210844
|
-
const
|
210845
|
-
const sitesOptions = buildSitesOptions({
|
211033
|
+
const legacyAssetPaths = config.legacy_assets ? getLegacyAssetPaths(config, void 0) : getSiteAssetPaths(config);
|
211034
|
+
const sitesOptions = buildSitesOptions({ legacyAssetPaths });
|
210846
211035
|
const workerOptions = {
|
210847
211036
|
compatibilityDate: config.compatibility_date,
|
210848
211037
|
compatibilityFlags: config.compatibility_flags,
|