wrangler 3.68.0 → 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/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "wrangler",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.69.0",
|
4
4
|
"description": "Command-line interface for all things Cloudflare Workers",
|
5
5
|
"keywords": [
|
6
6
|
"wrangler",
|
@@ -154,6 +154,7 @@
|
|
154
154
|
"@cloudflare/cli": "1.1.1",
|
155
155
|
"@cloudflare/eslint-config-worker": "1.1.0",
|
156
156
|
"@cloudflare/pages-shared": "^0.11.50",
|
157
|
+
"@cloudflare/workers-shared": "0.1.0",
|
157
158
|
"@cloudflare/workers-tsconfig": "0.0.0"
|
158
159
|
},
|
159
160
|
"peerDependencies": {
|
@@ -0,0 +1,33 @@
|
|
1
|
+
/**
|
2
|
+
* This Worker is used as a default entry-point for Assets-only
|
3
|
+
* Workers. It proxies the request directly on to the Asset Sever
|
4
|
+
* Worker service binding.
|
5
|
+
*
|
6
|
+
* In an Assets-only Workers world, we want to enable users
|
7
|
+
* to deploy a Worker with Assets without ever having to provide
|
8
|
+
* a User Worker.
|
9
|
+
*
|
10
|
+
* ```bash
|
11
|
+
* wrangler dev --experimental-assets dist
|
12
|
+
* wrangler deploy --experimental-assets dist
|
13
|
+
* ```
|
14
|
+
*
|
15
|
+
* ```toml
|
16
|
+
* name = "assets-only-worker"
|
17
|
+
* compatibility_date = "2024-01-01"
|
18
|
+
* ```
|
19
|
+
*
|
20
|
+
* Without a user-defined Worker, which usually serves as the entry
|
21
|
+
* point in the bundling process, wrangler needs to default to some
|
22
|
+
* other entry-point Worker for all intents and purposes. This is what
|
23
|
+
* this Worker is.
|
24
|
+
*/
|
25
|
+
type Env = {
|
26
|
+
ASSET_SERVER: Fetcher;
|
27
|
+
};
|
28
|
+
|
29
|
+
export default {
|
30
|
+
async fetch(request: Request, env: Env) {
|
31
|
+
return env.ASSET_SERVER.fetch(request);
|
32
|
+
},
|
33
|
+
};
|
package/wrangler-dist/cli.d.ts
CHANGED
@@ -151,6 +151,8 @@ declare type Binding = {
|
|
151
151
|
type: "logfwdr";
|
152
152
|
} & Omit<CfLogfwdrBinding, "name">) | {
|
153
153
|
type: `unsafe_${string}`;
|
154
|
+
} | {
|
155
|
+
type: "assets";
|
154
156
|
};
|
155
157
|
|
156
158
|
declare type BindingOmit<T> = Omit<T, "binding" | "name">;
|
@@ -25923,6 +25925,9 @@ declare interface StartDevWorkerInput {
|
|
25923
25925
|
enableServiceEnvironments?: boolean;
|
25924
25926
|
};
|
25925
25927
|
unsafe?: Omit<CfUnsafe, "bindings">;
|
25928
|
+
experimental?: {
|
25929
|
+
assets?: Omit<ExperimentalAssets, "bindings">;
|
25930
|
+
};
|
25926
25931
|
}
|
25927
25932
|
|
25928
25933
|
declare type StartDevWorkerOptions = StartDevWorkerInput & {
|
package/wrangler-dist/cli.js
CHANGED
@@ -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");
|
@@ -152672,7 +152672,7 @@ init_import_meta_url();
|
|
152672
152672
|
init_import_meta_url();
|
152673
152673
|
|
152674
152674
|
// package.json
|
152675
|
-
var version = "3.
|
152675
|
+
var version = "3.69.0";
|
152676
152676
|
var package_default = {
|
152677
152677
|
name: "wrangler",
|
152678
152678
|
version,
|
@@ -152767,6 +152767,7 @@ var package_default = {
|
|
152767
152767
|
"@cloudflare/eslint-config-worker": "workspace:*",
|
152768
152768
|
"@cloudflare/pages-shared": "workspace:^",
|
152769
152769
|
"@cloudflare/types": "^6.18.4",
|
152770
|
+
"@cloudflare/workers-shared": "workspace:*",
|
152770
152771
|
"@cloudflare/workers-tsconfig": "workspace:*",
|
152771
152772
|
"@cloudflare/workers-types": "^4.20240725.0",
|
152772
152773
|
"@cspotcode/source-map-support": "0.8.1",
|
@@ -159390,8 +159391,10 @@ async function getEntry(args, config, command2) {
|
|
159390
159391
|
// site.entry-point could be a directory
|
159391
159392
|
import_node_path16.default.resolve(config.site?.["entry-point"], "index.js")
|
159392
159393
|
);
|
159393
|
-
} else if (args.legacyAssets || config.legacy_assets
|
159394
|
+
} else if (args.legacyAssets || config.legacy_assets) {
|
159394
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");
|
159395
159398
|
} else {
|
159396
159399
|
throw new UserError(
|
159397
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.`
|
@@ -162601,7 +162604,8 @@ function buildMiniflareBindingOptions(config) {
|
|
162601
162604
|
}
|
162602
162605
|
}
|
162603
162606
|
const serviceBindings = {
|
162604
|
-
...config.serviceBindings
|
162607
|
+
...config.serviceBindings,
|
162608
|
+
...config.experimentalAssets ? { ASSET_SERVER: "asset-server" } : {}
|
162605
162609
|
};
|
162606
162610
|
const notFoundServices = /* @__PURE__ */ new Set();
|
162607
162611
|
for (const service of config.services ?? []) {
|
@@ -162897,6 +162901,35 @@ async function buildMiniflareOptions(log2, config, proxyToUserWorkerAuthenticati
|
|
162897
162901
|
);
|
162898
162902
|
}
|
162899
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;
|
162900
162933
|
const upstream = typeof config.localUpstream === "string" ? `${config.upstreamProtocol}://${config.localUpstream}` : void 0;
|
162901
162934
|
const { sourceOptions, entrypointNames } = await buildSourceOptions(config);
|
162902
162935
|
const { bindingOptions, internalObjects, externalWorkers } = buildMiniflareBindingOptions(config);
|
@@ -162929,6 +162962,7 @@ async function buildMiniflareOptions(log2, config, proxyToUserWorkerAuthenticati
|
|
162929
162962
|
proxy: true
|
162930
162963
|
}))
|
162931
162964
|
},
|
162965
|
+
...config.experimentalAssets ? [assetServerWorker] : [],
|
162932
162966
|
...externalWorkers
|
162933
162967
|
]
|
162934
162968
|
};
|
@@ -163041,6 +163075,7 @@ async function localPropsToConfigBundle(props) {
|
|
163041
163075
|
bindings: props.bindings,
|
163042
163076
|
workerDefinitions: props.workerDefinitions,
|
163043
163077
|
legacyAssetPaths: props.legacyAssetPaths,
|
163078
|
+
experimentalAssets: props.experimentalAssets,
|
163044
163079
|
initialPort: props.initialPort,
|
163045
163080
|
initialIp: props.initialIp,
|
163046
163081
|
rules: props.rules,
|
@@ -163397,11 +163432,6 @@ async function printBundleSize(main2, modules) {
|
|
163397
163432
|
const percentage = gzipSize / ALLOWED_INITIAL_MAX * 100;
|
163398
163433
|
const colorizedReport = percentage > 90 ? source_default.red(bundleReport) : percentage > 70 ? source_default.yellow(bundleReport) : source_default.green(bundleReport);
|
163399
163434
|
logger.log(`Total Upload: ${colorizedReport}`);
|
163400
|
-
if (gzipSize > ALLOWED_INITIAL_MAX && !process.env.NO_SCRIPT_SIZE_WARNING) {
|
163401
|
-
logger.warn(
|
163402
|
-
"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."
|
163403
|
-
);
|
163404
|
-
}
|
163405
163435
|
}
|
163406
163436
|
__name(printBundleSize, "printBundleSize");
|
163407
163437
|
function printOffendingDependencies(dependencies) {
|
@@ -201053,8 +201083,11 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
201053
201083
|
}
|
201054
201084
|
}
|
201055
201085
|
printBindings({ ...withoutStaticAssets, vars: maskedVars });
|
201056
|
-
if (
|
201086
|
+
if (props.dryRun) {
|
201087
|
+
printBindings({ ...withoutStaticAssets, vars: maskedVars });
|
201088
|
+
} else {
|
201057
201089
|
await ensureQueuesExistByConfig(config);
|
201090
|
+
let bindingsPrinted = false;
|
201058
201091
|
try {
|
201059
201092
|
const body = createWorkerUploadForm(worker);
|
201060
201093
|
const result = await fetchResult(
|
@@ -201071,8 +201104,14 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
201071
201104
|
excludeScript: "true"
|
201072
201105
|
})
|
201073
201106
|
);
|
201107
|
+
logger.log("Worker Startup Time:", result.startup_time_ms, "ms");
|
201108
|
+
bindingsPrinted = true;
|
201109
|
+
printBindings({ ...withoutStaticAssets, vars: maskedVars });
|
201074
201110
|
logger.log("Worker Version ID:", result.id);
|
201075
201111
|
} catch (err) {
|
201112
|
+
if (!bindingsPrinted) {
|
201113
|
+
printBindings({ ...withoutStaticAssets, vars: maskedVars });
|
201114
|
+
}
|
201076
201115
|
helpIfErrorIsSizeOrScriptStartup(err, dependencies);
|
201077
201116
|
if (err instanceof ParseError && "code" in err && err.code === 10021 && err.notes.length > 0) {
|
201078
201117
|
const maybeNameToFilePath = /* @__PURE__ */ __name((moduleName) => {
|
@@ -206622,6 +206661,9 @@ function DevSession(props) {
|
|
206622
206661
|
unsafe: {
|
206623
206662
|
capnp: props.bindings.unsafe?.capnp,
|
206624
206663
|
metadata: props.bindings.unsafe?.metadata
|
206664
|
+
},
|
206665
|
+
experimental: {
|
206666
|
+
assets: props.experimentalAssets
|
206625
206667
|
}
|
206626
206668
|
};
|
206627
206669
|
}, [
|
@@ -206637,6 +206679,7 @@ function DevSession(props) {
|
|
206637
206679
|
props.isWorkersSite,
|
206638
206680
|
props.local,
|
206639
206681
|
props.legacyAssetsConfig,
|
206682
|
+
props.experimentalAssets,
|
206640
206683
|
props.processEntrypoint,
|
206641
206684
|
props.additionalModules,
|
206642
206685
|
props.env,
|
@@ -206790,6 +206833,7 @@ function DevSession(props) {
|
|
206790
206833
|
bindings: props.bindings,
|
206791
206834
|
workerDefinitions,
|
206792
206835
|
legacyAssetPaths: props.legacyAssetPaths,
|
206836
|
+
experimentalAssets: props.experimentalAssets,
|
206793
206837
|
initialPort: void 0,
|
206794
206838
|
initialIp: "127.0.0.1",
|
206795
206839
|
rules: props.rules,
|
@@ -207391,6 +207435,7 @@ async function startDevServer(props) {
|
|
207391
207435
|
compatibilityFlags: props.compatibilityFlags,
|
207392
207436
|
bindings: props.bindings,
|
207393
207437
|
legacyAssetPaths: props.legacyAssetPaths,
|
207438
|
+
experimentalAssets: props.experimentalAssets,
|
207394
207439
|
initialPort: void 0,
|
207395
207440
|
// hard-code for userworker, DevEnv-ProxyWorker now uses this prop value
|
207396
207441
|
initialIp: "127.0.0.1",
|
@@ -208175,6 +208220,15 @@ Move any existing data to .wrangler/state and use --persist, or
|
|
208175
208220
|
use --persist-to=./wrangler-local-state to keep using the old path.`
|
208176
208221
|
);
|
208177
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
|
+
}
|
208178
208232
|
const projectRoot = configPath && import_node_path63.default.dirname(configPath);
|
208179
208233
|
const devEnv = new DevEnv();
|
208180
208234
|
if (args.experimentalDevEnv) {
|
@@ -208327,6 +208381,9 @@ use --persist-to=./wrangler-local-state to keep using the old path.`
|
|
208327
208381
|
},
|
208328
208382
|
legacyAssets: (configParam) => configParam.legacy_assets,
|
208329
208383
|
enableServiceEnvironments: !(args.legacyEnv ?? true)
|
208384
|
+
},
|
208385
|
+
experimental: {
|
208386
|
+
assets: experimentalAssets
|
208330
208387
|
}
|
208331
208388
|
});
|
208332
208389
|
void sendMetricsEvent(
|
@@ -208355,10 +208412,6 @@ use --persist-to=./wrangler-local-state to keep using the old path.`
|
|
208355
208412
|
}
|
208356
208413
|
});
|
208357
208414
|
}
|
208358
|
-
const experimentalAssets = processExperimentalAssetsArg(args, config);
|
208359
|
-
if (experimentalAssets) {
|
208360
|
-
args.forceLocal = true;
|
208361
|
-
}
|
208362
208415
|
const {
|
208363
208416
|
entry,
|
208364
208417
|
upstreamProtocol,
|
@@ -208424,6 +208477,7 @@ use --persist-to=./wrangler-local-state to keep using the old path.`
|
|
208424
208477
|
accountId: args.accountId ?? configParam.account_id ?? getAccountFromCache()?.id,
|
208425
208478
|
legacyAssetPaths,
|
208426
208479
|
legacyAssetsConfig: configParam.legacy_assets,
|
208480
|
+
experimentalAssets,
|
208427
208481
|
initialPort: args.port ?? configParam.dev.port ?? await getLocalPort2(),
|
208428
208482
|
initialIp: args.ip || configParam.dev.ip,
|
208429
208483
|
inspectorPort: args.inspectorPort ?? configParam.dev.inspector_port ?? await getInspectorPort2(),
|
@@ -208563,6 +208617,7 @@ async function startApiDev(args) {
|
|
208563
208617
|
accountId: args.accountId ?? configParam.account_id ?? getAccountFromCache()?.id,
|
208564
208618
|
legacyAssetPaths,
|
208565
208619
|
legacyAssetsConfig: configParam.legacy_assets,
|
208620
|
+
experimentalAssets: void 0,
|
208566
208621
|
//port can be 0, which means to use a random port
|
208567
208622
|
initialPort: args.port ?? configParam.dev.port ?? await getLocalPort2(),
|
208568
208623
|
initialIp: args.ip ?? configParam.dev.ip,
|
@@ -208664,6 +208719,16 @@ You can explicitly set the \`dev.host\` configuration in your wrangler.toml file
|
|
208664
208719
|
}
|
208665
208720
|
__name(getInferredHost, "getInferredHost");
|
208666
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
|
+
}
|
208667
208732
|
const entry = await getEntry(
|
208668
208733
|
{
|
208669
208734
|
legacyAssets: args.legacyAssets,
|
@@ -208694,11 +208759,6 @@ async function validateDevServerSettings(args, config) {
|
|
208694
208759
|
).join(", ")}`
|
208695
208760
|
);
|
208696
208761
|
}
|
208697
|
-
if ((args.legacyAssets || config.legacy_assets || args.experimentalAssets || config.experimental_assets) && (args.site || config.site)) {
|
208698
|
-
throw new UserError(
|
208699
|
-
"Cannot use Assets and Workers Sites in the same Worker."
|
208700
|
-
);
|
208701
|
-
}
|
208702
208762
|
const upstreamProtocol = args.upstreamProtocol ?? config.dev.upstream_protocol;
|
208703
208763
|
if (upstreamProtocol === "http" && args.remote) {
|
208704
208764
|
logger.warn(
|
@@ -208965,7 +209025,7 @@ unstable_dev()'s behaviour will likely change in future releases`
|
|
208965
209025
|
localProtocol: options21?.localProtocol,
|
208966
209026
|
httpsKeyPath: options21?.httpsKeyPath,
|
208967
209027
|
httpsCertPath: options21?.httpsCertPath,
|
208968
|
-
experimentalAssets:
|
209028
|
+
experimentalAssets: void 0,
|
208969
209029
|
legacyAssets: options21?.legacyAssets,
|
208970
209030
|
site: options21?.site,
|
208971
209031
|
// Root folder of static assets for Workers Sites
|
@@ -209490,7 +209550,11 @@ async function resolveConfig(config, input) {
|
|
209490
209550
|
{
|
209491
209551
|
legacyAssets: Boolean(legacyAssets),
|
209492
209552
|
script: input.entrypoint,
|
209493
|
-
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
|
209494
209558
|
},
|
209495
209559
|
config,
|
209496
209560
|
"dev"
|
@@ -209536,6 +209600,9 @@ async function resolveConfig(config, input) {
|
|
209536
209600
|
unsafe: {
|
209537
209601
|
capnp: input.unsafe?.capnp ?? unsafe?.capnp,
|
209538
209602
|
metadata: input.unsafe?.metadata ?? unsafe?.metadata
|
209603
|
+
},
|
209604
|
+
experimental: {
|
209605
|
+
assets: input?.experimental?.assets
|
209539
209606
|
}
|
209540
209607
|
};
|
209541
209608
|
if (resolved.legacy.legacyAssets && resolved.legacy.site) {
|
@@ -209720,6 +209787,7 @@ async function convertToConfigBundle(event) {
|
|
209720
209787
|
excludePatterns: event.config.legacy?.site?.exclude ?? [],
|
209721
209788
|
includePatterns: event.config.legacy?.site?.include ?? []
|
209722
209789
|
} : void 0,
|
209790
|
+
experimentalAssets: event.config.experimental?.assets,
|
209723
209791
|
initialPort: void 0,
|
209724
209792
|
initialIp: "127.0.0.1",
|
209725
209793
|
rules: [],
|