@cloudflare/vite-plugin 1.51.1 → 1.51.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/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@ import { a as __toESM, c as __toESM$1, i as __require$1, n as __export, o as __c
2
2
  import * as nodeModule from "node:module";
3
3
  import { builtinModules, createRequire } from "node:module";
4
4
  import assert from "node:assert";
5
- import { CoreHeaders, CorePaths, DeferredPromise, Log, LogLevel, Miniflare, MiniflareCoreError, Mutex, Request as Request$1, Response as Response$1, buildPublicUrl, coupleWebSocket, getDefaultDevRegistryPath, getNodeCompat, getWorkerRegistry, kUnsafeEphemeralUniqueKey, parseModuleFallbackRequest } from "miniflare";
5
+ import { CoreHeaders, CorePaths, DeferredPromise, Log, LogLevel, Miniflare, MiniflareCoreError, Mutex, Request as Request$1, Response as Response$1, buildPublicUrl, convertV4MiniflareOptions, coupleWebSocket, getDefaultDevRegistryPath, getNodeCompat, getWorkerRegistry, kUnsafeEphemeralUniqueKey, parseModuleFallbackRequest } from "miniflare";
6
6
  import * as wrangler from "wrangler";
7
7
  import * as path2 from "node:path";
8
8
  import path2__default, { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
@@ -1489,7 +1489,7 @@ async function assertWranglerVersion() {
1489
1489
  * The default compatibility date to use when the user omits one.
1490
1490
  * This value is injected at build time and remains fixed for each release.
1491
1491
  */
1492
- const DEFAULT_COMPAT_DATE = "2026-08-07";
1492
+ const DEFAULT_COMPAT_DATE = "2026-08-10";
1493
1493
 
1494
1494
  //#endregion
1495
1495
  //#region src/build-output-env.ts
@@ -53615,6 +53615,50 @@ const AssetsSchema = strictObject({
53615
53615
  ]).optional(),
53616
53616
  runWorkerFirst: union([array(string()), boolean()]).optional()
53617
53617
  });
53618
+ const BrowserBindingSchema = strictObject({
53619
+ type: literal$1("browser"),
53620
+ remote: boolean().optional()
53621
+ });
53622
+ const WorkerBindingSchema = strictObject({
53623
+ type: literal$1("worker"),
53624
+ workerName: string(),
53625
+ exportName: string().optional(),
53626
+ props: record(string(), unknown()).optional(),
53627
+ remote: boolean().optional()
53628
+ });
53629
+ const D1BindingSchema = strictObject({
53630
+ type: literal$1("d1"),
53631
+ name: string().optional(),
53632
+ id: string().optional(),
53633
+ remote: boolean().optional()
53634
+ });
53635
+ const KVBindingSchema = strictObject({
53636
+ type: literal$1("kv"),
53637
+ id: string().optional(),
53638
+ remote: boolean().optional()
53639
+ });
53640
+ const QueueBindingSchema = strictObject({
53641
+ type: literal$1("queue"),
53642
+ name: string().optional(),
53643
+ deliveryDelay: number().optional(),
53644
+ remote: boolean().optional()
53645
+ });
53646
+ const R2BindingSchema = strictObject({
53647
+ type: literal$1("r2"),
53648
+ name: string().optional(),
53649
+ jurisdiction: string().optional(),
53650
+ remote: boolean().optional()
53651
+ });
53652
+ const FlagshipBindingSchema = strictObject({
53653
+ type: literal$1("flagship"),
53654
+ id: string().optional(),
53655
+ remote: boolean().optional()
53656
+ });
53657
+ const HyperdriveBindingSchema = strictObject({
53658
+ type: literal$1("hyperdrive"),
53659
+ id: string(),
53660
+ localConnectionString: string().optional()
53661
+ });
53618
53662
  const KnownBindingSchema = discriminatedUnion("type", [
53619
53663
  strictObject({
53620
53664
  type: literal$1("agent-memory"),
@@ -53645,16 +53689,8 @@ const KnownBindingSchema = discriminatedUnion("type", [
53645
53689
  remote: boolean().optional()
53646
53690
  }),
53647
53691
  strictObject({ type: literal$1("assets") }),
53648
- strictObject({
53649
- type: literal$1("browser"),
53650
- remote: boolean().optional()
53651
- }),
53652
- strictObject({
53653
- type: literal$1("d1"),
53654
- name: string().optional(),
53655
- id: string().optional(),
53656
- remote: boolean().optional()
53657
- }),
53692
+ BrowserBindingSchema,
53693
+ D1BindingSchema,
53658
53694
  strictObject({
53659
53695
  type: literal$1("dispatch-namespace"),
53660
53696
  namespace: string().optional(),
@@ -53669,16 +53705,8 @@ const KnownBindingSchema = discriminatedUnion("type", [
53669
53705
  workerName: string(),
53670
53706
  exportName: string()
53671
53707
  }),
53672
- strictObject({
53673
- type: literal$1("flagship"),
53674
- id: string().optional(),
53675
- remote: boolean().optional()
53676
- }),
53677
- strictObject({
53678
- type: literal$1("hyperdrive"),
53679
- id: string(),
53680
- localConnectionString: string().optional()
53681
- }),
53708
+ FlagshipBindingSchema,
53709
+ HyperdriveBindingSchema,
53682
53710
  strictObject({
53683
53711
  type: literal$1("images"),
53684
53712
  remote: boolean().optional()
@@ -53687,11 +53715,7 @@ const KnownBindingSchema = discriminatedUnion("type", [
53687
53715
  type: literal$1("json"),
53688
53716
  value: json()
53689
53717
  }),
53690
- strictObject({
53691
- type: literal$1("kv"),
53692
- id: string().optional(),
53693
- remote: boolean().optional()
53694
- }),
53718
+ KVBindingSchema,
53695
53719
  strictObject({
53696
53720
  type: literal$1("logfwdr"),
53697
53721
  destination: string()
@@ -53710,12 +53734,7 @@ const KnownBindingSchema = discriminatedUnion("type", [
53710
53734
  name: string(),
53711
53735
  remote: boolean().optional()
53712
53736
  }),
53713
- strictObject({
53714
- type: literal$1("queue"),
53715
- name: string().optional(),
53716
- deliveryDelay: number().optional(),
53717
- remote: boolean().optional()
53718
- }),
53737
+ QueueBindingSchema,
53719
53738
  strictObject({
53720
53739
  type: literal$1("rate-limit"),
53721
53740
  namespace: string(),
@@ -53724,12 +53743,7 @@ const KnownBindingSchema = discriminatedUnion("type", [
53724
53743
  period: union([literal$1(10), literal$1(60)])
53725
53744
  })
53726
53745
  }),
53727
- strictObject({
53728
- type: literal$1("r2"),
53729
- name: string().optional(),
53730
- jurisdiction: string().optional(),
53731
- remote: boolean().optional()
53732
- }),
53746
+ R2BindingSchema,
53733
53747
  strictObject({ type: literal$1("secret") }),
53734
53748
  strictObject({
53735
53749
  type: literal$1("secrets-store-secret"),
@@ -53778,13 +53792,7 @@ const KnownBindingSchema = discriminatedUnion("type", [
53778
53792
  type: literal$1("web-search"),
53779
53793
  remote: boolean().optional()
53780
53794
  }),
53781
- strictObject({
53782
- type: literal$1("worker"),
53783
- workerName: string(),
53784
- exportName: string().optional(),
53785
- props: record(string(), unknown()).optional(),
53786
- remote: boolean().optional()
53787
- }),
53795
+ WorkerBindingSchema,
53788
53796
  strictObject({ type: literal$1("worker-loader") })
53789
53797
  ]);
53790
53798
  const UnsafeBindingSchema = looseObject({
@@ -53826,7 +53834,7 @@ const SINGLETON_BINDING_TYPES = new Set([
53826
53834
  "web-search"
53827
53835
  ]);
53828
53836
  const listFormatter = new Intl.ListFormat("en-US");
53829
- const EnvSchema = record(string(), BindingSchema).superRefine((env$3, ctx) => {
53837
+ function validateSingletonBindings(env$3, ctx) {
53830
53838
  const seen = /* @__PURE__ */ new Set();
53831
53839
  const duplicates = /* @__PURE__ */ new Set();
53832
53840
  for (const binding of Object.values(env$3)) {
@@ -53840,37 +53848,44 @@ const EnvSchema = record(string(), BindingSchema).superRefine((env$3, ctx) => {
53840
53848
  code: "custom",
53841
53849
  message: `${listFormatter.format([...duplicates].sort())} bindings can only be defined once`
53842
53850
  });
53843
- }).optional();
53851
+ }
53852
+ const EnvSchema = record(string(), BindingSchema).superRefine(validateSingletonBindings).optional();
53853
+ const DurableObjectCreatedExportSchema = strictObject({
53854
+ type: literal$1("durable-object"),
53855
+ state: literal$1("created").optional(),
53856
+ storage: _enum(["sqlite", "legacy-kv"])
53857
+ });
53858
+ const DurableObjectDeletedExportSchema = strictObject({
53859
+ type: literal$1("durable-object"),
53860
+ state: literal$1("deleted")
53861
+ });
53862
+ const DurableObjectRenamedExportSchema = strictObject({
53863
+ type: literal$1("durable-object"),
53864
+ state: literal$1("renamed"),
53865
+ renamedTo: string()
53866
+ });
53867
+ const DurableObjectTransferredExportSchema = strictObject({
53868
+ type: literal$1("durable-object"),
53869
+ state: literal$1("transferred"),
53870
+ transferredTo: string()
53871
+ });
53872
+ const DurableObjectExpectingTransferExportSchema = strictObject({
53873
+ type: literal$1("durable-object"),
53874
+ state: literal$1("expecting-transfer"),
53875
+ storage: _enum(["sqlite", "legacy-kv"]),
53876
+ transferFrom: string()
53877
+ });
53878
+ const WorkerEntrypointExportSchema = strictObject({
53879
+ type: literal$1("worker"),
53880
+ cache: strictObject({ enabled: boolean() }).optional()
53881
+ });
53844
53882
  const ExportSchema = union([
53845
- strictObject({
53846
- type: literal$1("durable-object"),
53847
- state: literal$1("created").optional(),
53848
- storage: _enum(["sqlite", "legacy-kv"])
53849
- }),
53850
- strictObject({
53851
- type: literal$1("durable-object"),
53852
- state: literal$1("deleted")
53853
- }),
53854
- strictObject({
53855
- type: literal$1("durable-object"),
53856
- state: literal$1("renamed"),
53857
- renamedTo: string()
53858
- }),
53859
- strictObject({
53860
- type: literal$1("durable-object"),
53861
- state: literal$1("transferred"),
53862
- transferredTo: string()
53863
- }),
53864
- strictObject({
53865
- type: literal$1("durable-object"),
53866
- state: literal$1("expecting-transfer"),
53867
- storage: _enum(["sqlite", "legacy-kv"]),
53868
- transferFrom: string()
53869
- }),
53870
- strictObject({
53871
- type: literal$1("worker"),
53872
- cache: strictObject({ enabled: boolean() }).optional()
53873
- })
53883
+ DurableObjectCreatedExportSchema,
53884
+ DurableObjectDeletedExportSchema,
53885
+ DurableObjectRenamedExportSchema,
53886
+ DurableObjectTransferredExportSchema,
53887
+ DurableObjectExpectingTransferExportSchema,
53888
+ WorkerEntrypointExportSchema
53874
53889
  ]);
53875
53890
  const LimitsSchema = strictObject({
53876
53891
  cpuMs: number().optional(),
@@ -57326,12 +57341,12 @@ async function generateRuntimeTypes({ compatibilityDate, compatibilityFlags = []
57326
57341
  * worker, and then making a request to that worker to fetch types.
57327
57342
  */
57328
57343
  async function generate({ compatibilityDate, compatibilityFlags = [] }) {
57329
- const mf = new Miniflare({
57344
+ const mf = new Miniflare(convertV4MiniflareOptions({
57330
57345
  compatibilityDate: "2024-01-01",
57331
57346
  compatibilityFlags: ["nodejs_compat", "rtti_api"],
57332
57347
  modules: true,
57333
57348
  script: (await fsp.readFile(require$1.resolve("workerd/worker.mjs"))).toString()
57334
- });
57349
+ }));
57335
57350
  const path$1 = `http://dummy.com/${compatibilityDate}${compatibilityFlags.length ? `+${compatibilityFlags.join("+")}` : ""}`;
57336
57351
  try {
57337
57352
  const res = await mf.dispatchFetch(path$1);
@@ -78763,7 +78778,7 @@ __name(createWorkerUploadForm, "createWorkerUploadForm");
78763
78778
  //#endregion
78764
78779
  //#region ../remote-bindings/dist/index.mjs
78765
78780
  var import_undici = require_undici();
78766
- var version$2 = "0.0.8";
78781
+ var version$2 = "0.0.9";
78767
78782
  var NoDefaultValueProvided = class extends UserError {
78768
78783
  constructor() {
78769
78784
  super("This command cannot be run in a non-interactive context", { telemetryMessage: "remote bindings prompt default missing" });
@@ -78883,7 +78898,7 @@ var ProxyController = class {
78883
78898
  createProxyWorker() {
78884
78899
  if (this._torndown || this.proxyWorker) return;
78885
78900
  assert(this.latestConfig !== void 0);
78886
- const proxyWorker = new Miniflare({
78901
+ const proxyWorker = new Miniflare(convertV4MiniflareOptions({
78887
78902
  host: this.latestConfig.server.hostname,
78888
78903
  port: this.latestConfig.server.port,
78889
78904
  https: this.latestConfig.server.secure,
@@ -78915,7 +78930,7 @@ var ProxyController = class {
78915
78930
  verbose: logger.loggerLevel === "debug",
78916
78931
  log: new ProxyControllerLogger(castLogLevel(logger.loggerLevel), { prefix: logger.loggerLevel === "debug" ? "remote-bindings-ProxyWorker" : "remote-bindings" }, this.localServerReady.promise),
78917
78932
  handleStructuredLogs
78918
- });
78933
+ }));
78919
78934
  this.proxyWorker = proxyWorker;
78920
78935
  proxyWorker.ready.then((url$2) => {
78921
78936
  assert(url$2);
@@ -82404,7 +82419,6 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
82404
82419
  const assetWorkers = [
82405
82420
  {
82406
82421
  name: ROUTER_WORKER_NAME,
82407
- unsafeExcludeFromObservability: true,
82408
82422
  unsafeRegisterWorker: false,
82409
82423
  compatibilityDate: INTERNAL_WORKERS_COMPATIBILITY_DATE,
82410
82424
  compatibilityFlags: ["enable_ctx_exports"],
@@ -82422,7 +82436,6 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
82422
82436
  },
82423
82437
  {
82424
82438
  name: ASSET_WORKER_NAME,
82425
- unsafeExcludeFromObservability: true,
82426
82439
  unsafeRegisterWorker: false,
82427
82440
  compatibilityDate: INTERNAL_WORKERS_COMPATIBILITY_DATE,
82428
82441
  modulesRoot: miniflareModulesRoot,
@@ -82484,7 +82497,6 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
82484
82497
  },
82485
82498
  {
82486
82499
  name: VITE_PROXY_WORKER_NAME,
82487
- unsafeExcludeFromObservability: true,
82488
82500
  unsafeRegisterWorker: false,
82489
82501
  compatibilityDate: INTERNAL_WORKERS_COMPATIBILITY_DATE,
82490
82502
  modulesRoot: miniflareModulesRoot,
@@ -82523,13 +82535,15 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
82523
82535
  });
82524
82536
  for (const option of options ?? []) containerTagToOptionsMap.set(option.image_tag, option);
82525
82537
  }
82526
- const { externalWorkers: externalWorkers$1, workerOptions } = wrangler.unstable_getMiniflareWorkerOptions({
82538
+ const miniflareWorkerOptions = wrangler.unstable_getMiniflareWorkerOptions({
82527
82539
  ...worker.config,
82528
82540
  assets: void 0
82529
82541
  }, resolvedPluginConfig.cloudflareEnv, {
82530
82542
  remoteProxyConnectionString: remoteProxySessionData?.session?.remoteProxyConnectionString,
82531
82543
  containerBuildId
82532
82544
  });
82545
+ const { externalWorkers: externalWorkers$1 } = miniflareWorkerOptions;
82546
+ const workerOptions = miniflareWorkerOptions.workerOptions;
82533
82547
  if (workerOptions.browserRendering && getBrowserRenderingHeadfulFromEnv()) workerOptions.browserRendering.headful = true;
82534
82548
  const wrappers = [
82535
82549
  `import { createWorkerEntrypointWrapper, createDurableObjectWrapper, createWorkflowEntrypointWrapper } from "${RUNNER_PATH}";`,
@@ -82596,7 +82610,7 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
82596
82610
  const logger$1 = new ViteMiniflareLogger(resolvedViteConfig);
82597
82611
  const serverConfig = viteDevServer.config.server;
82598
82612
  return {
82599
- miniflareOptions: {
82613
+ miniflareOptions: convertV4MiniflareOptions({
82600
82614
  log: logger$1,
82601
82615
  publicUrl: buildPublicUrl({
82602
82616
  hostname: typeof serverConfig.host === "string" ? serverConfig.host : void 0,
@@ -82647,7 +82661,7 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
82647
82661
  default: return Response$1.error();
82648
82662
  }
82649
82663
  }
82650
- },
82664
+ }),
82651
82665
  containerTagToOptionsMap
82652
82666
  };
82653
82667
  }
@@ -82744,10 +82758,11 @@ async function getPreviewMiniflareOptions(ctx, vitePreviewServer) {
82744
82758
  containerBuildId
82745
82759
  });
82746
82760
  const { externalWorkers } = miniflareWorkerOptions;
82747
- const { modulesRules,...workerOptions } = miniflareWorkerOptions.workerOptions;
82761
+ const { modulesRules,...sourcelessWorkerOptions } = miniflareWorkerOptions.workerOptions;
82762
+ const workerOptions = sourcelessWorkerOptions;
82748
82763
  return [{
82749
82764
  ...workerOptions,
82750
- name: workerOptions.name ?? workerConfig.name,
82765
+ name: typeof workerOptions.name === "string" ? workerOptions.name : workerConfig.name,
82751
82766
  unsafeInspectorProxy: inputInspectorPort !== false,
82752
82767
  ...previewWorker.source === "build-output" && previewWorker.bundle ? getModulesFromManifest(previewWorker.bundle) : miniflareWorkerOptions.main ? getPreviewModules(miniflareWorkerOptions.main, modulesRules) : {
82753
82768
  modules: true,
@@ -82758,7 +82773,7 @@ async function getPreviewMiniflareOptions(ctx, vitePreviewServer) {
82758
82773
  const logger$1 = new ViteMiniflareLogger(resolvedViteConfig);
82759
82774
  const serverConfig = vitePreviewServer.config.preview;
82760
82775
  return {
82761
- miniflareOptions: {
82776
+ miniflareOptions: convertV4MiniflareOptions({
82762
82777
  log: logger$1,
82763
82778
  publicUrl: buildPublicUrl({
82764
82779
  hostname: typeof serverConfig.host === "string" ? serverConfig.host : void 0,
@@ -82777,7 +82792,7 @@ async function getPreviewMiniflareOptions(ctx, vitePreviewServer) {
82777
82792
  resourceTmpPath: path2.resolve(resolvedViteConfig.root, ".wrangler/tmp"),
82778
82793
  containerEngine,
82779
82794
  workers
82780
- },
82795
+ }),
82781
82796
  containerTagToOptionsMap
82782
82797
  };
82783
82798
  }