wrangler 4.98.0 → 4.99.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": "4.98.0",
3
+ "version": "4.99.0",
4
4
  "description": "Command-line interface for all things Cloudflare Workers",
5
5
  "keywords": [
6
6
  "assembly",
@@ -54,16 +54,16 @@
54
54
  "esbuild": "0.27.3",
55
55
  "path-to-regexp": "6.3.0",
56
56
  "unenv": "2.0.0-rc.24",
57
- "workerd": "1.20260603.1",
58
- "@cloudflare/kv-asset-handler": "0.5.0",
57
+ "workerd": "1.20260609.1",
59
58
  "@cloudflare/unenv-preset": "2.16.1",
60
- "miniflare": "4.20260603.0"
59
+ "@cloudflare/kv-asset-handler": "0.5.0",
60
+ "miniflare": "4.20260609.0"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@aws-sdk/client-s3": "^3.721.0",
64
64
  "@bomb.sh/tab": "^0.0.12",
65
65
  "@cloudflare/types": "6.18.4",
66
- "@cloudflare/workers-types": "^4.20260603.1",
66
+ "@cloudflare/workers-types": "^4.20260609.1",
67
67
  "@cspotcode/source-map-support": "0.8.1",
68
68
  "@netlify/build-info": "^10.5.1",
69
69
  "@sentry/node": "^7.86.0",
@@ -149,15 +149,15 @@
149
149
  "@cloudflare/codemod": "1.1.0",
150
150
  "@cloudflare/containers-shared": "0.15.1",
151
151
  "@cloudflare/deploy-helpers": "0.1.2",
152
- "@cloudflare/pages-shared": "^0.13.143",
152
+ "@cloudflare/pages-shared": "^0.13.144",
153
153
  "@cloudflare/workers-auth": "0.1.1",
154
154
  "@cloudflare/workers-tsconfig": "0.0.0",
155
- "@cloudflare/workers-shared": "0.19.6",
155
+ "@cloudflare/workers-utils": "0.23.0",
156
156
  "@cloudflare/workflows-shared": "0.11.1",
157
- "@cloudflare/workers-utils": "0.23.0"
157
+ "@cloudflare/workers-shared": "0.19.6"
158
158
  },
159
159
  "peerDependencies": {
160
- "@cloudflare/workers-types": "^4.20260603.1"
160
+ "@cloudflare/workers-types": "^4.20260609.1"
161
161
  },
162
162
  "peerDependenciesMeta": {
163
163
  "@cloudflare/workers-types": {
@@ -1,14 +1,14 @@
1
- import { Rule as Rule$1, CfModule, Environment as Environment$1, Entry, CfModuleType, ApiCredentials, Config as Config$1, Binding, DurableObjectMigration as DurableObjectMigration$1, ContainerApp as ContainerApp$1, Trigger, CfTailConsumer, ServiceFetch, ContainerEngine as ContainerEngine$1, CfUnsafe, CfScriptFormat, AssetsOptions as AssetsOptions$1, ConfigBindingFieldName, NormalizeAndValidateConfigArgs, ResolveConfigPathOptions, RawConfig as RawConfig$1, PackageJSON, ParseError, ComplianceConfig, UserError, FatalError } from '@cloudflare/workers-utils';
1
+ import { Rule as Rule$1, CfModule, Environment as Environment$1, Entry, CfModuleType, ApiCredentials, Config as Config$1, Binding, DurableObjectMigration as DurableObjectMigration$1, ContainerApp as ContainerApp$1, Trigger, CfTailConsumer, ServiceFetch, ContainerEngine as ContainerEngine$1, CfUnsafe, CfScriptFormat, AssetsOptions as AssetsOptions$1, ConfigBindingFieldName, RawConfig as RawConfig$1, NormalizeAndValidateConfigArgs, ResolveConfigPathOptions, PackageJSON, ParseError, ComplianceConfig, UserError, FatalError } from '@cloudflare/workers-utils';
2
2
  export { Binding, experimental_patchConfig, experimental_readRawConfig, defaultWranglerConfig as unstable_defaultWranglerConfig } from '@cloudflare/workers-utils';
3
- import { Json as Json$1, WorkerRegistry, Miniflare, MiniflareOptions, Mutex, Response as Response$1, NodeJSCompatMode, DispatchFetch, RemoteProxyConnectionString, WorkerOptions, ModuleRule, Request } from 'miniflare';
3
+ import { Json as Json$1, WorkerRegistry, Miniflare, MiniflareOptions, Mutex, Response as Response$1, NodeJSCompatMode, WorkerdStructuredLog, DispatchFetch, RemoteProxyConnectionString, WorkerOptions, ModuleRule, Request } from 'miniflare';
4
4
  import * as undici from 'undici';
5
5
  import { RequestInfo, RequestInit, Response, FormData } from 'undici';
6
6
  import { Metafile } from 'esbuild';
7
7
  import Protocol from 'devtools-protocol/types/protocol-mapping';
8
8
  import { EventEmitter } from 'node:events';
9
9
  import { ContainerNormalizedConfig } from '@cloudflare/containers-shared';
10
+ import { FetcherScheduledOptions, FetcherScheduledResult, IncomingRequestCfProperties } from '@cloudflare/workers-types/experimental';
10
11
  import { RouterConfig, AssetConfig } from '@cloudflare/workers-shared';
11
- import { IncomingRequestCfProperties } from '@cloudflare/workers-types/experimental';
12
12
  import { URLSearchParams } from 'node:url';
13
13
  import { Argv, PositionalOptions, Options, ArgumentsCamelCase, InferredOptionTypes, InferredOptionType } from 'yargs';
14
14
  import Cloudflare from 'cloudflare';
@@ -470,6 +470,7 @@ declare abstract class RuntimeController extends Controller {
470
470
  abstract onBundleStart(_: BundleStartEvent): void;
471
471
  abstract onBundleComplete(_: BundleCompleteEvent): void;
472
472
  abstract onPreviewTokenExpired(_: PreviewTokenExpiredEvent): void;
473
+ abstract get mf(): Miniflare | undefined;
473
474
  protected emitReloadStartEvent(data: ReloadStartEvent): void;
474
475
  protected emitReloadCompleteEvent(data: ReloadCompleteEvent): void;
475
476
  protected emitDevRegistryUpdateEvent(data: DevRegistryUpdateEvent): void;
@@ -582,8 +583,8 @@ interface StartDevWorkerInput {
582
583
  * This is the `main` property of a Wrangler configuration file.
583
584
  */
584
585
  entrypoint?: string;
585
- /** The configuration path of the worker. */
586
- config?: string;
586
+ /** The configuration path of the worker, or a normalized configuration object. */
587
+ config?: string | Config$1;
587
588
  /** The compatibility date for the workerd runtime. */
588
589
  compatibilityDate?: string;
589
590
  /** The compatibility flags for the workerd runtime. */
@@ -696,11 +697,15 @@ interface StartDevWorkerInput {
696
697
  };
697
698
  /** A hook for outbound fetch calls from within the worker. */
698
699
  outboundService?: ServiceFetch;
700
+ /** Handles structured runtime logs. */
701
+ structuredLogsHandler?: (log: WorkerdStructuredLog) => void;
699
702
  /** An undici MockAgent to declaratively mock fetch calls to particular resources. */
700
703
  mockFetch?: undici.MockAgent;
701
704
  testScheduled?: boolean;
702
705
  /** Treat this as the primary worker in a multiworker setup (i.e. the first Worker in Miniflare's options) */
703
706
  multiworkerPrimary?: boolean;
707
+ /** Whether to infer the local request origin from configured routes. */
708
+ inferOriginFromRoutes?: boolean;
704
709
  containerBuildId?: string;
705
710
  /** Whether to build and connect to containers during local dev. Requires Docker daemon to be running. Defaults to true. */
706
711
  enableContainers?: boolean;
@@ -726,7 +731,9 @@ interface StartDevWorkerInput {
726
731
  assets?: string;
727
732
  experimental?: Record<string, never>;
728
733
  }
729
- type StartDevWorkerOptions = Omit<StartDevWorkerInput, "assets" | "containers" | "dev"> & {
734
+ type StartDevWorkerOptions = Omit<StartDevWorkerInput, "assets" | "config" | "containers" | "dev"> & {
735
+ /** The configuration path of the worker */
736
+ config?: string;
730
737
  /** A worker's directory. Usually where the Wrangler configuration file is located */
731
738
  projectRoot: string;
732
739
  build: StartDevWorkerInput["build"] & {
@@ -768,6 +775,169 @@ declare function convertConfigBindingsToStartWorkerBindings(configBindings: Part
768
775
 
769
776
  declare function startWorker(options: StartDevWorkerInput): Promise<Worker>;
770
777
 
778
+ type TestHarnessOptions = {
779
+ /**
780
+ * Base directory used to resolve relative worker config paths.
781
+ * Defaults to `process.cwd()`.
782
+ */
783
+ root?: string | undefined;
784
+ /**
785
+ * Workers to run in this server. The first worker is the primary worker.
786
+ */
787
+ workers: WorkerInput[];
788
+ };
789
+ type WorkerHandle = {
790
+ /**
791
+ * Dispatches a fetch event directly to this worker.
792
+ * Relative URL inputs are resolved against the URL returned by `listen()`.
793
+ *
794
+ * @example
795
+ * ```ts
796
+ * const response = await worker.fetch("/", {
797
+ * method: "POST",
798
+ * body: "Hello, world!"
799
+ * });
800
+ * ```
801
+ */
802
+ fetch: DispatchFetch;
803
+ /**
804
+ * Dispatches a scheduled event directly to this Worker.
805
+ *
806
+ * @example
807
+ * ```ts
808
+ * const result = await worker.scheduled({
809
+ * cron: "0 * * * *",
810
+ * scheduledTime: new Date(),
811
+ * });
812
+ * ```
813
+ */
814
+ scheduled(options: FetcherScheduledOptions): Promise<FetcherScheduledResult>;
815
+ };
816
+ type TestHarness = {
817
+ /**
818
+ * Starts the server and returns its current URL.
819
+ * Calling this more than once returns the same running server session until
820
+ * the server is closed or reset.
821
+ *
822
+ * If no options were passed to `createTestHarness()`, call `update(options)`
823
+ * before starting the server.
824
+ */
825
+ listen(): Promise<{
826
+ url: URL;
827
+ }>;
828
+ /**
829
+ * Dispatches a fetch request through the server.
830
+ *
831
+ * - Relative URLs are resolved against the current server URL. Absolute URLs
832
+ * are also accepted, and can be used to control the hostname seen by the Worker.
833
+ * - Requests are matched against each Worker's configured routes and dispatched to
834
+ * the first matching Worker, or to the primary Worker if no routes match.
835
+ * - To dispatch directly to a specific Worker, use `server.getWorker(name).fetch()`.
836
+ *
837
+ * @example
838
+ * ```ts
839
+ * const server = createTestHarness({
840
+ * workers: [
841
+ * { configPath: "./wrangler.dashboard.jsonc" }, // No route pattern
842
+ * { configPath: "./wrangler.api.jsonc" }, // Route pattern: "example.com/api/*"
843
+ * { configPath: "./wrangler.admin.jsonc" }, // Route pattern: "admin.example.com/*"
844
+ * ]
845
+ * });
846
+ *
847
+ * await server.fetch("/users");
848
+ * // Dispatches a request to the dashboard Worker (the first Worker) with URL "http://localhost:{port}/users"
849
+ *
850
+ * await server.fetch("http://admin.example.com/accounts");
851
+ * // Dispatches a request to the admin Worker with URL "http://admin.example.com/accounts"
852
+ *
853
+ * await server.fetch("http://example.com/api/data");
854
+ * // Dispatches a request to the API Worker with URL "http://example.com/api/data"
855
+ * ```
856
+ */
857
+ fetch: DispatchFetch;
858
+ /**
859
+ * Returns a handle for dispatching events directly to a Worker.
860
+ * When no name is provided, this returns the primary Worker, which is the first
861
+ * Worker in the server's `workers` options.
862
+ */
863
+ getWorker(name?: string): WorkerHandle;
864
+ /**
865
+ * Returns captured Workers runtime logs since the current server session
866
+ * started or `clearLogs()` was last called.
867
+ */
868
+ getLogs(): WorkerdStructuredLog[];
869
+ /**
870
+ * Clears captured Workers runtime logs.
871
+ */
872
+ clearLogs(): void;
873
+ /**
874
+ * Prints a diagnostic timeline for this test server.
875
+ *
876
+ * Use this to trace the sequence of server events and Workers runtime logs
877
+ * leading up to a test failure. Call `server.debug()` from your test runner's
878
+ * failure or cleanup hook when the current test has failed.
879
+ */
880
+ debug(): void;
881
+ /**
882
+ * Updates the server configuration and reloads the running Workers.
883
+ *
884
+ * If the server has not started yet, this configures the options that will be
885
+ * used by `listen()`.
886
+ */
887
+ update(options: TestHarnessOptions | ((currentOptions: TestHarnessOptions) => TestHarnessOptions)): Promise<void>;
888
+ /**
889
+ * Restores the server to the options used when the current session first
890
+ * started. Storage is recreated, and the server URL may change after reset.
891
+ */
892
+ reset(): Promise<void>;
893
+ /**
894
+ * Stops the server and releases all runtime resources.
895
+ */
896
+ close(): Promise<void>;
897
+ };
898
+ type InlineConfig = Omit<RawConfig$1, "env">;
899
+ type WorkerInput = {
900
+ /**
901
+ * Path to a Wrangler config file for this Worker.
902
+ * Relative paths resolve from server `root`.
903
+ */
904
+ configPath: string | URL;
905
+ /**
906
+ * Wrangler environment to load from the config file.
907
+ */
908
+ env?: string;
909
+ /**
910
+ * Test-only vars that override vars from the Wrangler config.
911
+ */
912
+ vars?: Record<string, Json$1>;
913
+ /**
914
+ * Test-only secrets that override values loaded from `.dev.vars` and `.env` files.
915
+ */
916
+ secrets?: Record<string, string>;
917
+ } | {
918
+ /**
919
+ * Inline Wrangler config for this Worker.
920
+ */
921
+ config: InlineConfig;
922
+ };
923
+ /**
924
+ * Creates a local test server for running Workers.
925
+ *
926
+ * The server can run one or more Workers from Wrangler config files, including
927
+ * generated configs from Vite, or from inline configuration objects.
928
+ *
929
+ * @example
930
+ * ```ts
931
+ * const server = createTestHarness({
932
+ * workers: [{ configPath: "./wrangler.jsonc" }],
933
+ * });
934
+ * await server.listen();
935
+ * const response = await server.fetch("/api/users");
936
+ * await server.close();
937
+ * ```
938
+ */
939
+ declare function createTestHarness(options?: TestHarnessOptions): TestHarness;
940
+
771
941
  type ReadConfigCommandArgs = NormalizeAndValidateConfigArgs & {
772
942
  config?: string;
773
943
  script?: string;
@@ -3506,4 +3676,4 @@ interface Unstable_ASSETSBindingsOptions {
3506
3676
  }
3507
3677
  declare const unstable_generateASSETSBinding: (opts: Unstable_ASSETSBindingsOptions) => (request: Request) => Promise<Response$1>;
3508
3678
 
3509
- export { type Experimental_GenerateTypesOptions, type Experimental_GenerateTypesResult, type GetPlatformProxyOptions, type PlatformProxy, type RemoteProxySession, type SourcelessWorkerOptions, type StartRemoteProxySessionOptions, type Unstable_ASSETSBindingsOptions, type Config as Unstable_Config, type Unstable_DevOptions, type Unstable_DevWorker, type Unstable_MiniflareWorkerOptions, type RawConfig as Unstable_RawConfig, type RawEnvironment as Unstable_RawEnvironment, Framework as experimental_AutoConfigFramework, generateTypes as experimental_generateTypes, getDetailsForAutoConfig as experimental_getDetailsForAutoConfig, experimental_getWranglerCommands, runAutoConfig as experimental_runAutoConfig, getPlatformProxy, maybeStartOrUpdateRemoteProxySession, startRemoteProxySession, DevEnv as unstable_DevEnv, convertConfigBindingsToStartWorkerBindings as unstable_convertConfigBindingsToStartWorkerBindings, unstable_dev, unstable_generateASSETSBinding, unstable_getDevCompatibilityDate, getDurableObjectClassNameToUseSQLiteMap as unstable_getDurableObjectClassNameToUseSQLiteMap, unstable_getMiniflareWorkerOptions, getVarsForDev as unstable_getVarsForDev, getWorkerNameFromProject as unstable_getWorkerNameFromProject, unstable_pages, printBindings as unstable_printBindings, readConfig as unstable_readConfig, resolveNamedTunnel as unstable_resolveNamedTunnel, splitSqlQuery as unstable_splitSqlQuery, startWorker as unstable_startWorker };
3679
+ export { type Experimental_GenerateTypesOptions, type Experimental_GenerateTypesResult, type GetPlatformProxyOptions, type PlatformProxy, type RemoteProxySession, type SourcelessWorkerOptions, type StartRemoteProxySessionOptions, type TestHarness, type TestHarnessOptions, type Unstable_ASSETSBindingsOptions, type Config as Unstable_Config, type Unstable_DevOptions, type Unstable_DevWorker, type Unstable_MiniflareWorkerOptions, type RawConfig as Unstable_RawConfig, type RawEnvironment as Unstable_RawEnvironment, type WorkerHandle, createTestHarness, Framework as experimental_AutoConfigFramework, generateTypes as experimental_generateTypes, getDetailsForAutoConfig as experimental_getDetailsForAutoConfig, experimental_getWranglerCommands, runAutoConfig as experimental_runAutoConfig, getPlatformProxy, maybeStartOrUpdateRemoteProxySession, startRemoteProxySession, DevEnv as unstable_DevEnv, convertConfigBindingsToStartWorkerBindings as unstable_convertConfigBindingsToStartWorkerBindings, unstable_dev, unstable_generateASSETSBinding, unstable_getDevCompatibilityDate, getDurableObjectClassNameToUseSQLiteMap as unstable_getDurableObjectClassNameToUseSQLiteMap, unstable_getMiniflareWorkerOptions, getVarsForDev as unstable_getVarsForDev, getWorkerNameFromProject as unstable_getWorkerNameFromProject, unstable_pages, printBindings as unstable_printBindings, readConfig as unstable_readConfig, resolveNamedTunnel as unstable_resolveNamedTunnel, splitSqlQuery as unstable_splitSqlQuery, startWorker as unstable_startWorker };