wrangler 3.80.0 → 3.80.2

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.80.0",
3
+ "version": "3.80.2",
4
4
  "description": "Command-line interface for all things Cloudflare Workers",
5
5
  "keywords": [
6
6
  "wrangler",
@@ -66,7 +66,7 @@
66
66
  "xxhash-wasm": "^1.0.1",
67
67
  "@cloudflare/kv-asset-handler": "0.3.4",
68
68
  "@cloudflare/workers-shared": "0.5.4",
69
- "miniflare": "3.20240925.0"
69
+ "miniflare": "3.20240925.1"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@cloudflare/types": "^6.18.4",
@@ -151,9 +151,9 @@
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",
156
- "@cloudflare/pages-shared": "^0.11.62",
155
+ "@cloudflare/eslint-config-worker": "1.1.0",
156
+ "@cloudflare/pages-shared": "^0.11.63",
157
157
  "@cloudflare/workers-tsconfig": "0.0.0"
158
158
  },
159
159
  "peerDependencies": {
@@ -156596,7 +156596,10 @@ ${message}
156596
156596
  logger.debug(`\u{1FAB5} Writing logs to "${debugLogFilepath}"`);
156597
156597
  (0, import_signal_exit.default)(() => {
156598
156598
  if (hasSeenErrorMessage) {
156599
- console.warn(`\u{1FAB5} Logs were written to "${debugLogFilepath}"`);
156599
+ logger.console(
156600
+ "warn",
156601
+ `\u{1FAB5} Logs were written to "${debugLogFilepath}"`
156602
+ );
156600
156603
  }
156601
156604
  });
156602
156605
  }
@@ -156754,14 +156757,14 @@ var logger = new Logger();
156754
156757
  function logBuildWarnings(warnings) {
156755
156758
  const logs = (0, import_esbuild.formatMessagesSync)(warnings, { kind: "warning", color: true });
156756
156759
  for (const log2 of logs) {
156757
- console.warn(log2);
156760
+ logger.console("warn", log2);
156758
156761
  }
156759
156762
  }
156760
156763
  __name(logBuildWarnings, "logBuildWarnings");
156761
156764
  function logBuildFailure(errors, warnings) {
156762
156765
  const logs = (0, import_esbuild.formatMessagesSync)(errors, { kind: "error", color: true });
156763
156766
  for (const log2 of logs) {
156764
- console.error(log2);
156767
+ logger.console("error", log2);
156765
156768
  }
156766
156769
  logBuildWarnings(warnings);
156767
156770
  }
@@ -157959,7 +157962,7 @@ var import_undici3 = __toESM(require_undici());
157959
157962
 
157960
157963
  // package.json
157961
157964
  var name = "wrangler";
157962
- var version = "3.80.0";
157965
+ var version = "3.80.2";
157963
157966
 
157964
157967
  // src/user/index.ts
157965
157968
  init_import_meta_url();
@@ -159550,7 +159553,7 @@ async function fetchWorker(resource, bodyInit = {}) {
159550
159553
  headers
159551
159554
  });
159552
159555
  if (!response.ok || !response.body) {
159553
- console.error(response.ok, response.body);
159556
+ logger.error(response.ok, response.body);
159554
159557
  throw new Error(
159555
159558
  `Failed to fetch ${resource} - ${response.status}: ${response.statusText});`
159556
159559
  );
@@ -165305,6 +165308,7 @@ async function bundleWorker(entry, destination, {
165305
165308
  bundle,
165306
165309
  absWorkingDir: entry.directory,
165307
165310
  outdir: destination,
165311
+ keepNames: true,
165308
165312
  entryNames: entryName || path14.parse(entryFile).name,
165309
165313
  ...isOutfile ? {
165310
165314
  outdir: void 0,
@@ -167587,9 +167591,8 @@ function buildAssetOptions(config) {
167587
167591
  if (config.assets) {
167588
167592
  return {
167589
167593
  assets: {
167590
- workerName: config.name,
167591
- path: config.assets.directory,
167592
- bindingName: config.assets.binding,
167594
+ directory: config.assets.directory,
167595
+ binding: config.assets.binding,
167593
167596
  routingConfig: config.assets.routingConfig,
167594
167597
  assetConfig: config.assets.assetConfig
167595
167598
  }
@@ -172764,7 +172767,8 @@ async function guessWorkerFormat(entryFile, entryWorkingDirectory, hint, tsconfi
172764
172767
  metafile: true,
172765
172768
  bundle: false,
172766
172769
  write: false,
172767
- ...tsconfig && { tsconfig }
172770
+ ...tsconfig && { tsconfig },
172771
+ logLevel: "silent"
172768
172772
  });
172769
172773
  const metafile = result.metafile;
172770
172774
  const { exports: exports2 } = getEntryPointFromMetafile(entryFile, metafile);
@@ -176364,7 +176368,6 @@ function registerDevHotKeys(devEnv, args) {
176364
176368
  keys: ["x", "q", "ctrl+c"],
176365
176369
  label: "to exit",
176366
176370
  handler: async () => {
176367
- unregisterHotKeys();
176368
176371
  await devEnv.teardown();
176369
176372
  }
176370
176373
  }
@@ -210274,36 +210277,54 @@ function writeDTSFile({
210274
210277
  throw error2;
210275
210278
  }
210276
210279
  }
210277
- let combinedTypeStrings = "";
210278
- if (formatType === "modules") {
210279
- combinedTypeStrings += `interface ${envInterface} {${envTypeStructure.map((value) => `
210280
- ${value}`).join("")}
210281
- }
210282
- ${modulesTypeStructure.join("\n")}`;
210283
- } else {
210284
- combinedTypeStrings += `export {};
210285
- declare global {
210286
- ${envTypeStructure.map((value) => ` const ${value}`).join("\n")}
210287
- }
210288
- ${modulesTypeStructure.join("\n")}`;
210289
- }
210290
210280
  const wranglerCommandUsed = ["wrangler", ...process.argv.slice(2)].join(" ");
210291
210281
  const typesHaveBeenFound = envTypeStructure.length || modulesTypeStructure.length;
210292
210282
  if (formatType === "modules" || typesHaveBeenFound) {
210283
+ const { fileContent, consoleOutput } = generateTypeStrings(
210284
+ formatType,
210285
+ envInterface,
210286
+ envTypeStructure,
210287
+ modulesTypeStructure
210288
+ );
210293
210289
  fs25.writeFileSync(
210294
210290
  path74,
210295
210291
  [
210296
210292
  `// Generated by Wrangler by running \`${wranglerCommandUsed}\``,
210297
210293
  "",
210298
- combinedTypeStrings
210294
+ fileContent
210299
210295
  ].join("\n")
210300
210296
  );
210301
210297
  logger.log(`Generating project types...
210302
210298
  `);
210303
- logger.log(combinedTypeStrings);
210299
+ logger.log(consoleOutput);
210304
210300
  }
210305
210301
  }
210306
210302
  __name(writeDTSFile, "writeDTSFile");
210303
+ function generateTypeStrings(formatType, envInterface, envTypeStructure, modulesTypeStructure) {
210304
+ let baseContent = "";
210305
+ let eslintDisable = "";
210306
+ if (formatType === "modules") {
210307
+ if (envTypeStructure.length === 0) {
210308
+ eslintDisable = "// eslint-disable-next-line @typescript-eslint/no-empty-interface,@typescript-eslint/no-empty-object-type\n";
210309
+ }
210310
+ baseContent = `interface ${envInterface} {${envTypeStructure.map((value) => `
210311
+ ${value}`).join("")}
210312
+ }`;
210313
+ } else {
210314
+ baseContent = `export {};
210315
+ declare global {
210316
+ ${envTypeStructure.map((value) => ` const ${value}`).join("\n")}
210317
+ }`;
210318
+ }
210319
+ const modulesContent = modulesTypeStructure.join("\n");
210320
+ return {
210321
+ fileContent: `${eslintDisable}${baseContent}
210322
+ ${modulesContent}`,
210323
+ consoleOutput: `${baseContent}
210324
+ ${modulesContent}`
210325
+ };
210326
+ }
210327
+ __name(generateTypeStrings, "generateTypeStrings");
210307
210328
  function readTsconfigTypes(tsconfigPath) {
210308
210329
  if (!fs25.existsSync(tsconfigPath)) {
210309
210330
  return [];
@@ -214195,10 +214216,15 @@ To learn more about Workers with assets, visit our documentation at https://deve
214195
214216
  () => startDev(args)
214196
214217
  );
214197
214218
  if (args.experimentalDevEnv) {
214198
- (0, import_node_assert24.default)(devInstance instanceof DevEnv);
214199
- await import_node_events3.default.once(devInstance, "teardown");
214219
+ (0, import_node_assert24.default)(devInstance.devEnv !== void 0);
214220
+ await import_node_events3.default.once(devInstance.devEnv, "teardown");
214221
+ if (devInstance.teardownRegistryPromise) {
214222
+ const teardownRegistry = await devInstance.teardownRegistryPromise;
214223
+ await teardownRegistry(devInstance.devEnv.config.latestConfig?.name);
214224
+ }
214225
+ devInstance.unregisterHotKeys?.();
214200
214226
  } else {
214201
- (0, import_node_assert24.default)(!(devInstance instanceof DevEnv));
214227
+ (0, import_node_assert24.default)(devInstance.devEnv === void 0);
214202
214228
  configFileWatcher = devInstance.configFileWatcher;
214203
214229
  assetsWatcher = devInstance.assetsWatcher;
214204
214230
  const { waitUntilExit } = devInstance.devReactElement;
@@ -214268,6 +214294,9 @@ async function startDev(args) {
214268
214294
  let configFileWatcher;
214269
214295
  let assetsWatcher;
214270
214296
  let rerender;
214297
+ const devEnv = new DevEnv();
214298
+ let teardownRegistryPromise;
214299
+ let unregisterHotKeys;
214271
214300
  try {
214272
214301
  if (args.logLevel) {
214273
214302
  logger.loggerLevel = args.logLevel;
@@ -214300,7 +214329,6 @@ use --persist-to=./wrangler-local-state to keep using the old path.`
214300
214329
  );
214301
214330
  }
214302
214331
  const configPath = args.config || args.script && findWranglerToml(import_node_path64.default.dirname(args.script));
214303
- const devEnv = new DevEnv();
214304
214332
  if (args.experimentalDevEnv) {
214305
214333
  void devEnv.proxy.ready.promise.then(({ url: url4 }) => {
214306
214334
  if (process.send && typeof vitest === "undefined") {
@@ -214314,13 +214342,9 @@ use --persist-to=./wrangler-local-state to keep using the old path.`
214314
214342
  }
214315
214343
  });
214316
214344
  if (!args.disableDevRegistry) {
214317
- const teardownRegistryPromise = devRegistry(
214345
+ teardownRegistryPromise = devRegistry(
214318
214346
  (registry) => updateDevEnvRegistry(devEnv, registry)
214319
214347
  );
214320
- devEnv.once("teardown", async () => {
214321
- const teardownRegistry = await teardownRegistryPromise;
214322
- await teardownRegistry(devEnv.config.latestConfig?.name);
214323
- });
214324
214348
  devEnv.runtimes.forEach((runtime) => {
214325
214349
  runtime.on(
214326
214350
  "reloadComplete",
@@ -214338,7 +214362,6 @@ use --persist-to=./wrangler-local-state to keep using the old path.`
214338
214362
  );
214339
214363
  });
214340
214364
  }
214341
- let unregisterHotKeys;
214342
214365
  if (isInteractive() && args.showInteractiveDevSession !== false) {
214343
214366
  unregisterHotKeys = registerDevHotKeys(devEnv, args);
214344
214367
  }
@@ -214476,7 +214499,7 @@ use --persist-to=./wrangler-local-state to keep using the old path.`
214476
214499
  offline: !args.remote
214477
214500
  }
214478
214501
  );
214479
- return devEnv;
214502
+ return { devEnv, unregisterHotKeys, teardownRegistryPromise };
214480
214503
  } else {
214481
214504
  const projectRoot = configPath && import_node_path64.default.dirname(configPath);
214482
214505
  let config = readConfig(configPath, args);
@@ -214674,7 +214697,15 @@ use --persist-to=./wrangler-local-state to keep using the old path.`
214674
214697
  } catch (e3) {
214675
214698
  await Promise.allSettled([
214676
214699
  configFileWatcher?.close(),
214677
- assetsWatcher?.close()
214700
+ assetsWatcher?.close(),
214701
+ devEnv.teardown(),
214702
+ (async () => {
214703
+ if (teardownRegistryPromise) {
214704
+ const teardownRegistry = await teardownRegistryPromise;
214705
+ await teardownRegistry(devEnv.config.latestConfig?.name);
214706
+ }
214707
+ unregisterHotKeys?.();
214708
+ })()
214678
214709
  ]);
214679
214710
  throw e3;
214680
214711
  }
@@ -215565,6 +215596,11 @@ var BundlerController = class extends Controller {
215565
215596
  #assetsWatcher;
215566
215597
  async #ensureWatchingAssets(config) {
215567
215598
  await this.#assetsWatcher?.close();
215599
+ const debouncedRefreshBundle = debounce(() => {
215600
+ if (this.#currentBundle) {
215601
+ this.emitBundleCompleteEvent(config, this.#currentBundle);
215602
+ }
215603
+ });
215568
215604
  if (config.assets?.directory) {
215569
215605
  this.#assetsWatcher = (0, import_chokidar7.watch)(config.assets.directory, {
215570
215606
  persistent: true,
@@ -215572,9 +215608,7 @@ var BundlerController = class extends Controller {
215572
215608
  }).on("all", async (eventName, filePath) => {
215573
215609
  const message = getAssetChangeMessage(eventName, filePath);
215574
215610
  logger.debug(`\u{1F300} ${message}...`);
215575
- if (this.#currentBundle) {
215576
- this.emitBundleCompleteEvent(config, this.#currentBundle);
215577
- }
215611
+ debouncedRefreshBundle();
215578
215612
  });
215579
215613
  }
215580
215614
  }
@@ -215782,6 +215816,7 @@ async function resolveConfig(config, input) {
215782
215816
  triggers: await resolveTriggers(config, input),
215783
215817
  env: input.env,
215784
215818
  build: {
215819
+ alias: input.build?.alias ?? config.alias,
215785
215820
  additionalModules: input.build?.additionalModules ?? [],
215786
215821
  processEntrypoint: Boolean(input.build?.processEntrypoint),
215787
215822
  bundle: input.build?.bundle ?? !config.no_bundle,
@@ -217244,8 +217279,9 @@ function deepFreeze(obj) {
217244
217279
  }
217245
217280
  __name(deepFreeze, "deepFreeze");
217246
217281
  function unstable_getMiniflareWorkerOptions(configPath, env7) {
217282
+ const isJsonConfigFile = configPath.endsWith(".json") || configPath.endsWith(".jsonc");
217247
217283
  const config = readConfig(configPath, {
217248
- experimentalJsonConfig: true,
217284
+ experimentalJsonConfig: isJsonConfigFile,
217249
217285
  env: env7
217250
217286
  });
217251
217287
  const modulesRules = config.rules.concat(DEFAULT_MODULE_RULES).map((rule) => ({
@@ -217289,12 +217325,15 @@ function unstable_getMiniflareWorkerOptions(configPath, env7) {
217289
217325
  }
217290
217326
  const legacyAssetPaths = config.legacy_assets ? getLegacyAssetPaths(config, void 0) : getSiteAssetPaths(config);
217291
217327
  const sitesOptions = buildSitesOptions({ legacyAssetPaths });
217328
+ const processedAssetOptions = processAssetsArg({ assets: void 0 }, config);
217329
+ const assetOptions = processedAssetOptions ? buildAssetOptions({ assets: processedAssetOptions }) : {};
217292
217330
  const workerOptions = {
217293
217331
  compatibilityDate: config.compatibility_date,
217294
217332
  compatibilityFlags: config.compatibility_flags,
217295
217333
  modulesRules,
217296
217334
  ...bindingOptions,
217297
- ...sitesOptions
217335
+ ...sitesOptions,
217336
+ ...assetOptions
217298
217337
  };
217299
217338
  return { workerOptions, define: config.define, main: config.main };
217300
217339
  }