wrangler 3.68.0 → 3.69.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wrangler",
3
- "version": "3.68.0",
3
+ "version": "3.69.1",
4
4
  "description": "Command-line interface for all things Cloudflare Workers",
5
5
  "keywords": [
6
6
  "wrangler",
@@ -66,7 +66,8 @@
66
66
  "workerd": "1.20240725.0",
67
67
  "xxhash-wasm": "^1.0.1",
68
68
  "@cloudflare/kv-asset-handler": "0.3.4",
69
- "miniflare": "3.20240725.0"
69
+ "miniflare": "3.20240725.0",
70
+ "@cloudflare/workers-shared": "0.1.0"
70
71
  },
71
72
  "devDependencies": {
72
73
  "@cloudflare/types": "^6.18.4",
@@ -151,9 +152,9 @@
151
152
  "xdg-app-paths": "^8.3.0",
152
153
  "yargs": "^17.7.2",
153
154
  "yoga-layout": "file:../../vendor/yoga-layout-2.0.0-beta.1.tgz",
155
+ "@cloudflare/pages-shared": "^0.11.50",
154
156
  "@cloudflare/cli": "1.1.1",
155
157
  "@cloudflare/eslint-config-worker": "1.1.0",
156
- "@cloudflare/pages-shared": "^0.11.50",
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
+ };
@@ -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 & {
@@ -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 dirname15 = path74.dirname;
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 = dirname15(loc);
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 dirname15 = '"' + path74.dirname(s) + '"';
97445
+ var dirname16 = '"' + path74.dirname(s) + '"';
97446
97446
  var basename5 = '"' + path74.basename(s) + '"';
97447
- return dirname15 + ":" + basename5;
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.68.0";
152675
+ var version = "3.69.1";
152676
152676
  var package_default = {
152677
152677
  name: "wrangler",
152678
152678
  version,
@@ -152745,6 +152745,7 @@ var package_default = {
152745
152745
  },
152746
152746
  dependencies: {
152747
152747
  "@cloudflare/kv-asset-handler": "workspace:*",
152748
+ "@cloudflare/workers-shared": "workspace:*",
152748
152749
  "@esbuild-plugins/node-globals-polyfill": "^0.2.3",
152749
152750
  "@esbuild-plugins/node-modules-polyfill": "^0.2.2",
152750
152751
  "blake3-wasm": "^2.1.5",
@@ -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 || args.experimentalAssets || config.experimental_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 ?? []) {
@@ -162929,12 +162933,50 @@ async function buildMiniflareOptions(log2, config, proxyToUserWorkerAuthenticati
162929
162933
  proxy: true
162930
162934
  }))
162931
162935
  },
162936
+ ...getAssetServerWorker(config),
162932
162937
  ...externalWorkers
162933
162938
  ]
162934
162939
  };
162935
162940
  return { options: options21, internalObjects, entrypointNames };
162936
162941
  }
162937
162942
  __name(buildMiniflareOptions, "buildMiniflareOptions");
162943
+ function getAssetServerWorker(config) {
162944
+ if (!config.experimentalAssets) {
162945
+ return [];
162946
+ }
162947
+ const assetServerModulePath = require.resolve("@cloudflare/workers-shared/dist/asset-server-worker.mjs");
162948
+ const assetServerConfigPath = require.resolve("@cloudflare/workers-shared/asset-server-worker/wrangler.toml");
162949
+ let assetServerConfig;
162950
+ try {
162951
+ assetServerConfig = readConfig(assetServerConfigPath, {});
162952
+ } catch (err) {
162953
+ throw new UserError(
162954
+ `Failed to read the Asset Server Worker configuration file.
162955
+ ${err}`
162956
+ );
162957
+ }
162958
+ return [
162959
+ {
162960
+ name: assetServerConfig?.name,
162961
+ compatibilityDate: assetServerConfig?.compatibility_date,
162962
+ compatibilityFlags: assetServerConfig?.compatibility_flags,
162963
+ modulesRoot: (0, import_node_path22.dirname)(assetServerModulePath),
162964
+ modules: [
162965
+ {
162966
+ type: "ESModule",
162967
+ path: assetServerModulePath
162968
+ }
162969
+ ],
162970
+ unsafeDirectSockets: [
162971
+ {
162972
+ host: "127.0.0.1",
162973
+ port: 0
162974
+ }
162975
+ ]
162976
+ }
162977
+ ];
162978
+ }
162979
+ __name(getAssetServerWorker, "getAssetServerWorker");
162938
162980
  var ReloadedEvent = class extends Event {
162939
162981
  url;
162940
162982
  internalDurableObjects;
@@ -163041,6 +163083,7 @@ async function localPropsToConfigBundle(props) {
163041
163083
  bindings: props.bindings,
163042
163084
  workerDefinitions: props.workerDefinitions,
163043
163085
  legacyAssetPaths: props.legacyAssetPaths,
163086
+ experimentalAssets: props.experimentalAssets,
163044
163087
  initialPort: props.initialPort,
163045
163088
  initialIp: props.initialIp,
163046
163089
  rules: props.rules,
@@ -163397,11 +163440,6 @@ async function printBundleSize(main2, modules) {
163397
163440
  const percentage = gzipSize / ALLOWED_INITIAL_MAX * 100;
163398
163441
  const colorizedReport = percentage > 90 ? source_default.red(bundleReport) : percentage > 70 ? source_default.yellow(bundleReport) : source_default.green(bundleReport);
163399
163442
  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
163443
  }
163406
163444
  __name(printBundleSize, "printBundleSize");
163407
163445
  function printOffendingDependencies(dependencies) {
@@ -201053,8 +201091,11 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
201053
201091
  }
201054
201092
  }
201055
201093
  printBindings({ ...withoutStaticAssets, vars: maskedVars });
201056
- if (!props.dryRun) {
201094
+ if (props.dryRun) {
201095
+ printBindings({ ...withoutStaticAssets, vars: maskedVars });
201096
+ } else {
201057
201097
  await ensureQueuesExistByConfig(config);
201098
+ let bindingsPrinted = false;
201058
201099
  try {
201059
201100
  const body = createWorkerUploadForm(worker);
201060
201101
  const result = await fetchResult(
@@ -201071,8 +201112,14 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
201071
201112
  excludeScript: "true"
201072
201113
  })
201073
201114
  );
201115
+ logger.log("Worker Startup Time:", result.startup_time_ms, "ms");
201116
+ bindingsPrinted = true;
201117
+ printBindings({ ...withoutStaticAssets, vars: maskedVars });
201074
201118
  logger.log("Worker Version ID:", result.id);
201075
201119
  } catch (err) {
201120
+ if (!bindingsPrinted) {
201121
+ printBindings({ ...withoutStaticAssets, vars: maskedVars });
201122
+ }
201076
201123
  helpIfErrorIsSizeOrScriptStartup(err, dependencies);
201077
201124
  if (err instanceof ParseError && "code" in err && err.code === 10021 && err.notes.length > 0) {
201078
201125
  const maybeNameToFilePath = /* @__PURE__ */ __name((moduleName) => {
@@ -206622,6 +206669,9 @@ function DevSession(props) {
206622
206669
  unsafe: {
206623
206670
  capnp: props.bindings.unsafe?.capnp,
206624
206671
  metadata: props.bindings.unsafe?.metadata
206672
+ },
206673
+ experimental: {
206674
+ assets: props.experimentalAssets
206625
206675
  }
206626
206676
  };
206627
206677
  }, [
@@ -206637,6 +206687,7 @@ function DevSession(props) {
206637
206687
  props.isWorkersSite,
206638
206688
  props.local,
206639
206689
  props.legacyAssetsConfig,
206690
+ props.experimentalAssets,
206640
206691
  props.processEntrypoint,
206641
206692
  props.additionalModules,
206642
206693
  props.env,
@@ -206790,6 +206841,7 @@ function DevSession(props) {
206790
206841
  bindings: props.bindings,
206791
206842
  workerDefinitions,
206792
206843
  legacyAssetPaths: props.legacyAssetPaths,
206844
+ experimentalAssets: props.experimentalAssets,
206793
206845
  initialPort: void 0,
206794
206846
  initialIp: "127.0.0.1",
206795
206847
  rules: props.rules,
@@ -207391,6 +207443,7 @@ async function startDevServer(props) {
207391
207443
  compatibilityFlags: props.compatibilityFlags,
207392
207444
  bindings: props.bindings,
207393
207445
  legacyAssetPaths: props.legacyAssetPaths,
207446
+ experimentalAssets: props.experimentalAssets,
207394
207447
  initialPort: void 0,
207395
207448
  // hard-code for userworker, DevEnv-ProxyWorker now uses this prop value
207396
207449
  initialIp: "127.0.0.1",
@@ -208175,6 +208228,15 @@ Move any existing data to .wrangler/state and use --persist, or
208175
208228
  use --persist-to=./wrangler-local-state to keep using the old path.`
208176
208229
  );
208177
208230
  }
208231
+ const experimentalAssets = processExperimentalAssetsArg(args, config);
208232
+ if (experimentalAssets) {
208233
+ args.forceLocal = true;
208234
+ }
208235
+ if ((args.legacyAssets || config.legacy_assets) && experimentalAssets) {
208236
+ throw new UserError(
208237
+ "Cannot use Legacy Assets and Experimental Assets in the same Worker."
208238
+ );
208239
+ }
208178
208240
  const projectRoot = configPath && import_node_path63.default.dirname(configPath);
208179
208241
  const devEnv = new DevEnv();
208180
208242
  if (args.experimentalDevEnv) {
@@ -208327,6 +208389,9 @@ use --persist-to=./wrangler-local-state to keep using the old path.`
208327
208389
  },
208328
208390
  legacyAssets: (configParam) => configParam.legacy_assets,
208329
208391
  enableServiceEnvironments: !(args.legacyEnv ?? true)
208392
+ },
208393
+ experimental: {
208394
+ assets: experimentalAssets
208330
208395
  }
208331
208396
  });
208332
208397
  void sendMetricsEvent(
@@ -208355,10 +208420,6 @@ use --persist-to=./wrangler-local-state to keep using the old path.`
208355
208420
  }
208356
208421
  });
208357
208422
  }
208358
- const experimentalAssets = processExperimentalAssetsArg(args, config);
208359
- if (experimentalAssets) {
208360
- args.forceLocal = true;
208361
- }
208362
208423
  const {
208363
208424
  entry,
208364
208425
  upstreamProtocol,
@@ -208424,6 +208485,7 @@ use --persist-to=./wrangler-local-state to keep using the old path.`
208424
208485
  accountId: args.accountId ?? configParam.account_id ?? getAccountFromCache()?.id,
208425
208486
  legacyAssetPaths,
208426
208487
  legacyAssetsConfig: configParam.legacy_assets,
208488
+ experimentalAssets,
208427
208489
  initialPort: args.port ?? configParam.dev.port ?? await getLocalPort2(),
208428
208490
  initialIp: args.ip || configParam.dev.ip,
208429
208491
  inspectorPort: args.inspectorPort ?? configParam.dev.inspector_port ?? await getInspectorPort2(),
@@ -208563,6 +208625,7 @@ async function startApiDev(args) {
208563
208625
  accountId: args.accountId ?? configParam.account_id ?? getAccountFromCache()?.id,
208564
208626
  legacyAssetPaths,
208565
208627
  legacyAssetsConfig: configParam.legacy_assets,
208628
+ experimentalAssets: void 0,
208566
208629
  //port can be 0, which means to use a random port
208567
208630
  initialPort: args.port ?? configParam.dev.port ?? await getLocalPort2(),
208568
208631
  initialIp: args.ip ?? configParam.dev.ip,
@@ -208664,6 +208727,16 @@ You can explicitly set the \`dev.host\` configuration in your wrangler.toml file
208664
208727
  }
208665
208728
  __name(getInferredHost, "getInferredHost");
208666
208729
  async function validateDevServerSettings(args, config) {
208730
+ if ((args.legacyAssets || config.legacy_assets) && (args.site || config.site)) {
208731
+ throw new UserError(
208732
+ "Cannot use Legacy Assets and Workers Sites in the same Worker."
208733
+ );
208734
+ }
208735
+ if ((args.experimentalAssets || config.experimental_assets) && (args.site || config.site)) {
208736
+ throw new UserError(
208737
+ "Cannot use Experimental Assets and Workers Sites in the same Worker."
208738
+ );
208739
+ }
208667
208740
  const entry = await getEntry(
208668
208741
  {
208669
208742
  legacyAssets: args.legacyAssets,
@@ -208694,11 +208767,6 @@ async function validateDevServerSettings(args, config) {
208694
208767
  ).join(", ")}`
208695
208768
  );
208696
208769
  }
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
208770
  const upstreamProtocol = args.upstreamProtocol ?? config.dev.upstream_protocol;
208703
208771
  if (upstreamProtocol === "http" && args.remote) {
208704
208772
  logger.warn(
@@ -208965,7 +209033,7 @@ unstable_dev()'s behaviour will likely change in future releases`
208965
209033
  localProtocol: options21?.localProtocol,
208966
209034
  httpsKeyPath: options21?.httpsKeyPath,
208967
209035
  httpsCertPath: options21?.httpsCertPath,
208968
- experimentalAssets: options21?.experimentalAssets,
209036
+ experimentalAssets: void 0,
208969
209037
  legacyAssets: options21?.legacyAssets,
208970
209038
  site: options21?.site,
208971
209039
  // Root folder of static assets for Workers Sites
@@ -209490,7 +209558,11 @@ async function resolveConfig(config, input) {
209490
209558
  {
209491
209559
  legacyAssets: Boolean(legacyAssets),
209492
209560
  script: input.entrypoint,
209493
- moduleRoot: input.build?.moduleRoot
209561
+ moduleRoot: input.build?.moduleRoot,
209562
+ // getEntry only needs to know if experimental_assets was specified.
209563
+ // The actualy value is not relevant here, which is why not passing
209564
+ // the entire ExperimentalAssets object is fine.
209565
+ experimentalAssets: input?.experimental?.assets?.directory
209494
209566
  },
209495
209567
  config,
209496
209568
  "dev"
@@ -209536,6 +209608,9 @@ async function resolveConfig(config, input) {
209536
209608
  unsafe: {
209537
209609
  capnp: input.unsafe?.capnp ?? unsafe?.capnp,
209538
209610
  metadata: input.unsafe?.metadata ?? unsafe?.metadata
209611
+ },
209612
+ experimental: {
209613
+ assets: input?.experimental?.assets
209539
209614
  }
209540
209615
  };
209541
209616
  if (resolved.legacy.legacyAssets && resolved.legacy.site) {
@@ -209720,6 +209795,7 @@ async function convertToConfigBundle(event) {
209720
209795
  excludePatterns: event.config.legacy?.site?.exclude ?? [],
209721
209796
  includePatterns: event.config.legacy?.site?.include ?? []
209722
209797
  } : void 0,
209798
+ experimentalAssets: event.config.experimental?.assets,
209723
209799
  initialPort: void 0,
209724
209800
  initialIp: "127.0.0.1",
209725
209801
  rules: [],