wrangler 3.63.0 → 3.63.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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/wrangler-dist/cli.js +120 -108
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wrangler",
3
- "version": "3.63.0",
3
+ "version": "3.63.1",
4
4
  "description": "Command-line interface for all things Cloudflare Workers",
5
5
  "keywords": [
6
6
  "wrangler",
@@ -151,8 +151,8 @@
151
151
  "xdg-app-paths": "^8.3.0",
152
152
  "yargs": "^17.7.2",
153
153
  "yoga-layout": "file:../../vendor/yoga-layout-2.0.0-beta.1.tgz",
154
- "@cloudflare/eslint-config-worker": "1.1.0",
155
154
  "@cloudflare/cli": "1.1.1",
155
+ "@cloudflare/eslint-config-worker": "1.1.0",
156
156
  "@cloudflare/pages-shared": "^0.11.46",
157
157
  "@cloudflare/workers-tsconfig": "0.0.0"
158
158
  },
@@ -85870,7 +85870,7 @@ var require_view = __commonJS({
85870
85870
  var debug = require_src3()("express:view");
85871
85871
  var path72 = require("path");
85872
85872
  var fs26 = require("fs");
85873
- var dirname13 = path72.dirname;
85873
+ var dirname14 = path72.dirname;
85874
85874
  var basename4 = path72.basename;
85875
85875
  var extname4 = path72.extname;
85876
85876
  var join16 = path72.join;
@@ -85910,7 +85910,7 @@ var require_view = __commonJS({
85910
85910
  for (var i = 0; i < roots.length && !path73; i++) {
85911
85911
  var root = roots[i];
85912
85912
  var loc = resolve19(root, name);
85913
- var dir = dirname13(loc);
85913
+ var dir = dirname14(loc);
85914
85914
  var file = basename4(loc);
85915
85915
  path73 = this.resolve(dir, file);
85916
85916
  }
@@ -103142,9 +103142,9 @@ var require_command_exists = __commonJS({
103142
103142
  cleanInput = /* @__PURE__ */ __name(function(s) {
103143
103143
  var isPathName = /[\\]/.test(s);
103144
103144
  if (isPathName) {
103145
- var dirname13 = '"' + path72.dirname(s) + '"';
103145
+ var dirname14 = '"' + path72.dirname(s) + '"';
103146
103146
  var basename4 = '"' + path72.basename(s) + '"';
103147
- return dirname13 + ":" + basename4;
103147
+ return dirname14 + ":" + basename4;
103148
103148
  }
103149
103149
  return '"' + s + '"';
103150
103150
  }, "cleanInput");
@@ -152612,7 +152612,7 @@ init_import_meta_url();
152612
152612
  init_import_meta_url();
152613
152613
 
152614
152614
  // package.json
152615
- var version = "3.63.0";
152615
+ var version = "3.63.1";
152616
152616
  var package_default = {
152617
152617
  name: "wrangler",
152618
152618
  version,
@@ -152965,10 +152965,6 @@ var FunctionsBuildError = class extends UserError {
152965
152965
  }
152966
152966
  };
152967
152967
  __name(FunctionsBuildError, "FunctionsBuildError");
152968
- function getFunctionsBuildWarning(functionsDirectory, suffix) {
152969
- return `Unexpected error building Functions directory: ${functionsDirectory}${suffix ? " - " + suffix : ""}`;
152970
- }
152971
- __name(getFunctionsBuildWarning, "getFunctionsBuildWarning");
152972
152968
  var FunctionsNoRoutesError = class extends UserError {
152973
152969
  constructor(message) {
152974
152970
  super(message);
@@ -176235,7 +176231,10 @@ var Handler4 = /* @__PURE__ */ __name(async (args) => {
176235
176231
  await printWranglerBanner();
176236
176232
  const config = readConfig(args.config, args);
176237
176233
  if (file && command2) {
176238
- return logger.error(`Error: can't provide both --command and --file.`);
176234
+ throw createFatalError(
176235
+ `Error: can't provide both --command and --file.`,
176236
+ json
176237
+ );
176239
176238
  }
176240
176239
  const isInteractive3 = process.stdout.isTTY;
176241
176240
  try {
@@ -176573,17 +176572,24 @@ async function pollUntilComplete(response, accountId, db) {
176573
176572
  }
176574
176573
  __name(pollUntilComplete, "pollUntilComplete");
176575
176574
  async function d1ApiPost(accountId, db, action, body) {
176576
- return await fetchResult(
176577
- `/accounts/${accountId}/d1/database/${db.uuid}/${action}`,
176578
- {
176579
- method: "POST",
176580
- headers: {
176581
- "Content-Type": "application/json",
176582
- ...db.internal_env ? { "x-d1-internal-env": db.internal_env } : {}
176583
- },
176584
- body: JSON.stringify(body)
176575
+ try {
176576
+ return await fetchResult(
176577
+ `/accounts/${accountId}/d1/database/${db.uuid}/${action}`,
176578
+ {
176579
+ method: "POST",
176580
+ headers: {
176581
+ "Content-Type": "application/json",
176582
+ ...db.internal_env ? { "x-d1-internal-env": db.internal_env } : {}
176583
+ },
176584
+ body: JSON.stringify(body)
176585
+ }
176586
+ );
176587
+ } catch (x2) {
176588
+ if (x2 instanceof APIError) {
176589
+ x2.preventReport();
176585
176590
  }
176586
- );
176591
+ throw x2;
176592
+ }
176587
176593
  }
176588
176594
  __name(d1ApiPost, "d1ApiPost");
176589
176595
  function logResult(r3) {
@@ -185042,6 +185048,11 @@ The Worker script should be named \`_worker.js\` and located in the build output
185042
185048
  }
185043
185049
  });
185044
185050
  } else if (usingWorkerScript) {
185051
+ const watcher = (0, import_chokidar3.watch)([workerScriptPath], {
185052
+ persistent: true,
185053
+ ignoreInitial: true
185054
+ });
185055
+ let watchedBundleDependencies = [];
185045
185056
  scriptPath3 = workerScriptPath;
185046
185057
  let runBuild2 = /* @__PURE__ */ __name(async () => {
185047
185058
  await checkRawWorker(
@@ -185056,33 +185067,54 @@ The Worker script should be named \`_worker.js\` and located in the build output
185056
185067
  `./bundledWorker-${Math.random()}.mjs`
185057
185068
  );
185058
185069
  runBuild2 = /* @__PURE__ */ __name(async () => {
185059
- try {
185060
- await buildRawWorker({
185061
- workerScriptPath: usingWorkerDirectory ? (0, import_node_path50.join)(workerScriptPath, "index.js") : workerScriptPath,
185062
- outfile: scriptPath3,
185063
- directory: directory ?? ".",
185064
- nodejsCompatMode,
185065
- local: true,
185066
- sourcemap: true,
185067
- watch: false,
185068
- onEnd: () => scriptReadyResolve(),
185069
- defineNavigatorUserAgent
185070
- });
185071
- } catch (e3) {
185072
- logger.warn("Failed to bundle _worker.js.", e3);
185070
+ const workerScriptDirectory = (0, import_node_path50.dirname)(workerScriptPath);
185071
+ let currentBundleDependencies = [];
185072
+ const bundle = await buildRawWorker({
185073
+ workerScriptPath: usingWorkerDirectory ? (0, import_node_path50.join)(workerScriptPath, "index.js") : workerScriptPath,
185074
+ outfile: scriptPath3,
185075
+ directory: directory ?? ".",
185076
+ nodejsCompatMode,
185077
+ local: true,
185078
+ sourcemap: true,
185079
+ watch: false,
185080
+ onEnd: () => scriptReadyResolve(),
185081
+ defineNavigatorUserAgent
185082
+ });
185083
+ const bundleDependencies = Object.keys(bundle.dependencies).map((dep) => (0, import_node_path50.resolve)(workerScriptDirectory, dep)).filter(
185084
+ (resolvedDep) => !resolvedDep.includes((0, import_node_path50.normalize)(singleWorkerScriptPath)) && !resolvedDep.includes((0, import_node_path50.normalize)("/.wrangler/")) && resolvedDep.includes((0, import_node_path50.resolve)(process.cwd()))
185085
+ );
185086
+ const bundleModules = bundle.modules.filter((module3) => !!module3.filePath).map(
185087
+ (module3) => (0, import_node_path50.resolve)(workerScriptDirectory, module3.filePath)
185088
+ );
185089
+ currentBundleDependencies = [...bundleDependencies, ...bundleModules];
185090
+ if (watchedBundleDependencies.length) {
185091
+ watcher.unwatch(watchedBundleDependencies);
185073
185092
  }
185093
+ watcher.add(currentBundleDependencies);
185094
+ watchedBundleDependencies = [...currentBundleDependencies];
185074
185095
  }, "runBuild");
185075
185096
  }
185076
- await runBuild2();
185077
- (0, import_chokidar3.watch)([workerScriptPath], {
185078
- persistent: true,
185079
- ignoreInitial: true
185080
- }).on("all", async (event) => {
185081
- if (event === "unlink") {
185082
- return;
185097
+ const debouncedRunBuild = debounce(async () => {
185098
+ try {
185099
+ await runBuild2();
185100
+ } catch (e3) {
185101
+ logger.warn(
185102
+ `Failed to build ${singleWorkerScriptPath}. Continuing to serve the last successfully built version of the Worker.`
185103
+ );
185083
185104
  }
185105
+ }, 50);
185106
+ try {
185084
185107
  await runBuild2();
185085
- });
185108
+ watcher.on("all", async (eventName, path72) => {
185109
+ logger.debug(`\u{1F300} "${eventName}" event detected at ${path72}.`);
185110
+ if (eventName === "unlink") {
185111
+ return;
185112
+ }
185113
+ debouncedRunBuild();
185114
+ });
185115
+ } catch (e3) {
185116
+ throw new FatalError(`Failed to build ${singleWorkerScriptPath}.`);
185117
+ }
185086
185118
  } else if (usingFunctions) {
185087
185119
  scriptPath3 = (0, import_node_path50.join)(
185088
185120
  getPagesTmpDir(),
@@ -185094,74 +185126,55 @@ The Worker script should be named \`_worker.js\` and located in the build output
185094
185126
  );
185095
185127
  logger.debug(`Compiling worker to "${scriptPath3}"...`);
185096
185128
  const onEnd = /* @__PURE__ */ __name(() => scriptReadyResolve(), "onEnd");
185097
- const watchedBundleDependencies = /* @__PURE__ */ new Set();
185098
185129
  const watcher = (0, import_chokidar3.watch)([functionsDirectory], {
185099
185130
  persistent: true,
185100
185131
  ignoreInitial: true
185101
185132
  });
185102
- try {
185103
- const buildFn = /* @__PURE__ */ __name(async () => {
185104
- const currentBundleDependencies = /* @__PURE__ */ new Set();
185105
- const bundle = await buildFunctions({
185106
- outfile: scriptPath3,
185107
- functionsDirectory,
185108
- sourcemap: true,
185109
- watch: false,
185110
- onEnd,
185111
- buildOutputDirectory: directory,
185112
- nodejsCompatMode,
185113
- local: true,
185114
- routesModule,
185115
- defineNavigatorUserAgent
185116
- });
185117
- for (const dep in bundle.dependencies) {
185118
- const resolvedDep = (0, import_node_path50.resolve)(functionsDirectory, dep);
185119
- if (!resolvedDep.includes((0, import_node_path50.normalize)("/functions/")) && !resolvedDep.includes((0, import_node_path50.normalize)("/.wrangler/")) && resolvedDep.includes((0, import_node_path50.resolve)(process.cwd()))) {
185120
- currentBundleDependencies.add(resolvedDep);
185121
- if (!watchedBundleDependencies.has(resolvedDep)) {
185122
- watchedBundleDependencies.add(resolvedDep);
185123
- watcher.add(resolvedDep);
185124
- }
185125
- }
185126
- }
185127
- for (const module3 of bundle.modules) {
185128
- if (module3.filePath) {
185129
- const resolvedDep = (0, import_node_path50.resolve)(functionsDirectory, module3.filePath);
185130
- currentBundleDependencies.add(resolvedDep);
185131
- if (!watchedBundleDependencies.has(resolvedDep)) {
185132
- watchedBundleDependencies.add(resolvedDep);
185133
- watcher.add(resolvedDep);
185134
- }
185135
- }
185136
- }
185137
- watchedBundleDependencies.forEach(async (path72) => {
185138
- if (!currentBundleDependencies.has(path72)) {
185139
- watchedBundleDependencies.delete(path72);
185140
- watcher.unwatch(path72);
185141
- }
185142
- });
185143
- await sendMetricsEvent("build pages functions");
185144
- }, "buildFn");
185145
- const debouncedBuildFn = debounce(async () => {
185146
- try {
185147
- await buildFn();
185148
- } catch (e3) {
185149
- if (e3 instanceof FunctionsNoRoutesError) {
185150
- logger.error(
185151
- getFunctionsNoRoutesWarning(functionsDirectory, "skipping")
185152
- );
185153
- } else if (e3 instanceof FunctionsBuildError) {
185154
- logger.error(
185155
- getFunctionsBuildWarning(functionsDirectory, e3.message)
185156
- );
185157
- } else {
185158
- logger.error(
185159
- `Error while attempting to build the Functions directory ${functionsDirectory}. Skipping to last successfully built version of Functions.
185160
- ${e3}`
185161
- );
185162
- }
185133
+ let watchedBundleDependencies = [];
185134
+ const buildFn = /* @__PURE__ */ __name(async () => {
185135
+ let currentBundleDependencies = [];
185136
+ const bundle = await buildFunctions({
185137
+ outfile: scriptPath3,
185138
+ functionsDirectory,
185139
+ sourcemap: true,
185140
+ watch: false,
185141
+ onEnd,
185142
+ buildOutputDirectory: directory,
185143
+ nodejsCompatMode,
185144
+ local: true,
185145
+ routesModule,
185146
+ defineNavigatorUserAgent
185147
+ });
185148
+ const bundleDependencies = Object.keys(bundle.dependencies).map((dep) => (0, import_node_path50.resolve)(functionsDirectory, dep)).filter(
185149
+ (resolvedDep) => !resolvedDep.includes((0, import_node_path50.normalize)("/functions/")) && !resolvedDep.includes((0, import_node_path50.normalize)("/.wrangler/")) && resolvedDep.includes((0, import_node_path50.resolve)(process.cwd()))
185150
+ );
185151
+ const bundleModules = bundle.modules.filter((module3) => !!module3.filePath).map(
185152
+ (module3) => (0, import_node_path50.resolve)(functionsDirectory, module3.filePath)
185153
+ );
185154
+ currentBundleDependencies = [...bundleDependencies, ...bundleModules];
185155
+ if (watchedBundleDependencies.length) {
185156
+ watcher.unwatch(watchedBundleDependencies);
185157
+ }
185158
+ watcher.add(currentBundleDependencies);
185159
+ watchedBundleDependencies = [...currentBundleDependencies];
185160
+ await sendMetricsEvent("build pages functions");
185161
+ }, "buildFn");
185162
+ const debouncedBuildFn = debounce(async () => {
185163
+ try {
185164
+ await buildFn();
185165
+ } catch (e3) {
185166
+ if (e3 instanceof FunctionsNoRoutesError) {
185167
+ logger.warn(
185168
+ `${getFunctionsNoRoutesWarning(functionsDirectory)}. Continuing to serve the last successfully built version of Functions.`
185169
+ );
185170
+ } else {
185171
+ logger.warn(
185172
+ `Failed to build Functions at ${functionsDirectory}. Continuing to serve the last successfully built version of Functions.`
185173
+ );
185163
185174
  }
185164
- }, 50);
185175
+ }
185176
+ }, 50);
185177
+ try {
185165
185178
  await buildFn();
185166
185179
  watcher.on("all", async (eventName, path72) => {
185167
185180
  logger.debug(`\u{1F300} "${eventName}" event detected at ${path72}.`);
@@ -185176,15 +185189,14 @@ ${e3}`
185176
185189
  usingFunctions = false;
185177
185190
  } else {
185178
185191
  throw new FatalError(
185179
- `Error while attempting to build the Functions directory ${functionsDirectory}
185180
- ${e3}`
185192
+ `Failed to build Functions at ${functionsDirectory}.`
185181
185193
  );
185182
185194
  }
185183
185195
  }
185184
185196
  }
185185
185197
  if (!usingFunctions && !usingWorkerScript) {
185186
185198
  scriptReadyResolve();
185187
- logger.log("No functions. Shimming...");
185199
+ logger.log("No Functions. Shimming...");
185188
185200
  scriptPath3 = (0, import_node_path50.resolve)(getBasePath(), "templates/pages-shim.ts");
185189
185201
  }
185190
185202
  await scriptReadyPromise;