@cloudflare/vite-plugin 1.45.1 → 1.46.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/README.md +2 -2
- package/dist/experimental-config.d.mts +108 -42
- package/dist/experimental-config.d.mts.map +1 -1
- package/dist/experimental-config.mjs +17 -4
- package/dist/experimental-config.mjs.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +13126 -3878
- package/dist/index.mjs.map +1 -1
- package/dist/{open-PBXRGS4R-B5qmtwhS.mjs → open-PBXRGS4R-7GUxLVbA.mjs} +14 -14
- package/dist/open-PBXRGS4R-7GUxLVbA.mjs.map +1 -0
- package/dist/{package-VLsxxiiN.mjs → package-Cjez0K_t.mjs} +3 -2
- package/dist/package-Cjez0K_t.mjs.map +1 -0
- package/package.json +11 -10
- package/dist/open-PBXRGS4R-B5qmtwhS.mjs.map +0 -1
- package/dist/package-VLsxxiiN.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -23,14 +23,14 @@ Full documentation can be found [here](https://developers.cloudflare.com/workers
|
|
|
23
23
|
- Uses the Vite [Environment API](https://vite.dev/guide/api-environment) to integrate Vite with the Workers runtime
|
|
24
24
|
- Provides direct access to [Workers runtime APIs](https://developers.cloudflare.com/workers/runtime-apis/) and [bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/)
|
|
25
25
|
- Builds your front-end assets for deployment to Cloudflare, enabling you to build static sites, SPAs, and full-stack applications
|
|
26
|
-
- Official support for [TanStack Start](https://tanstack.com/start/) and [React Router
|
|
26
|
+
- Official support for [TanStack Start](https://tanstack.com/start/) and [React Router v8](https://reactrouter.com/) with server-side rendering
|
|
27
27
|
- Leverages Vite's hot module replacement for consistently fast updates
|
|
28
28
|
- Supports `vite preview` for previewing your build output in the Workers runtime prior to deployment
|
|
29
29
|
|
|
30
30
|
## Use cases
|
|
31
31
|
|
|
32
32
|
- [TanStack Start](https://tanstack.com/start/)
|
|
33
|
-
- [React Router
|
|
33
|
+
- [React Router v8](https://reactrouter.com/)
|
|
34
34
|
- Support for more full-stack frameworks is coming soon
|
|
35
35
|
- Static sites, such as single-page applications, with or without an integrated backend API
|
|
36
36
|
- Standalone Workers
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Pipeline, PipelineRecord } from "cloudflare:pipelines";
|
|
2
2
|
|
|
3
|
-
//#region ../config/dist/public-
|
|
3
|
+
//#region ../config/dist/public-myuV_kLK.d.mts
|
|
4
4
|
|
|
5
5
|
//#region src/utils.d.ts
|
|
6
6
|
/**
|
|
@@ -134,7 +134,7 @@ interface D1Binding extends D1BindingOptions {
|
|
|
134
134
|
}
|
|
135
135
|
interface DispatchNamespaceBindingOptions {
|
|
136
136
|
/** The namespace to bind to. */
|
|
137
|
-
namespace
|
|
137
|
+
namespace?: string;
|
|
138
138
|
/** Details about the outbound Worker which will handle outbound requests from your namespace. */
|
|
139
139
|
outbound?: {
|
|
140
140
|
/** Name of the Worker handling the outbound requests. */
|
|
@@ -182,7 +182,7 @@ interface TypedDurableObjectBinding<TConfig$1, TExportName$1 extends string> ext
|
|
|
182
182
|
}
|
|
183
183
|
interface FlagshipBindingOptions {
|
|
184
184
|
/** The Flagship app ID to bind to. */
|
|
185
|
-
id
|
|
185
|
+
id?: string;
|
|
186
186
|
/** Set to `true` to suppress the remote binding warning in local dev. Flagship bindings are always remote. */
|
|
187
187
|
remote?: boolean;
|
|
188
188
|
}
|
|
@@ -295,7 +295,7 @@ interface TypedPipelineBinding<TRecord extends PipelineRecord = PipelineRecord>
|
|
|
295
295
|
}
|
|
296
296
|
interface QueueBindingOptions {
|
|
297
297
|
/** The name of this Queue. */
|
|
298
|
-
name
|
|
298
|
+
name?: string;
|
|
299
299
|
/** The number of seconds to wait before delivering a message. */
|
|
300
300
|
deliveryDelay?: number;
|
|
301
301
|
/** Whether the Queue producer should be remote or not in local development. */
|
|
@@ -602,7 +602,7 @@ interface Bindings {
|
|
|
602
602
|
*
|
|
603
603
|
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms
|
|
604
604
|
*/
|
|
605
|
-
dispatchNamespace(options
|
|
605
|
+
dispatchNamespace(options?: DispatchNamespaceBindingOptions): DispatchNamespaceBinding;
|
|
606
606
|
/**
|
|
607
607
|
* Binding to a Durable Object class. `workerName` is the name of the Worker
|
|
608
608
|
* that defines the class; `exportName` is the exported class name.
|
|
@@ -611,7 +611,7 @@ interface Bindings {
|
|
|
611
611
|
*/
|
|
612
612
|
durableObject(options: DurableObjectBindingOptions): DurableObjectBinding;
|
|
613
613
|
/** Binding to a Flagship feature-flag service. */
|
|
614
|
-
flagship(options
|
|
614
|
+
flagship(options?: FlagshipBindingOptions): FlagshipBinding;
|
|
615
615
|
/**
|
|
616
616
|
* Binding to a Hyperdrive configuration.
|
|
617
617
|
*
|
|
@@ -652,7 +652,7 @@ interface Bindings {
|
|
|
652
652
|
*
|
|
653
653
|
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
|
654
654
|
*/
|
|
655
|
-
queue<TBody = unknown>(options
|
|
655
|
+
queue<TBody = unknown>(options?: QueueBindingOptions): TypedQueueBinding<TBody>;
|
|
656
656
|
/**
|
|
657
657
|
* Binding to an R2 bucket.
|
|
658
658
|
*
|
|
@@ -1007,6 +1007,32 @@ interface Exports {
|
|
|
1007
1007
|
* ```
|
|
1008
1008
|
*/
|
|
1009
1009
|
declare const exports: Exports;
|
|
1010
|
+
//#endregion
|
|
1011
|
+
//#region src/definition.d.ts
|
|
1012
|
+
interface ConfigContext {
|
|
1013
|
+
/**
|
|
1014
|
+
* The mode the config is being evaluated in.
|
|
1015
|
+
* Set via the `--mode` CLI flag.
|
|
1016
|
+
* In Vite the mode defaults to `development` in `vite dev` and `production` in `vite build` ([more info](https://vite.dev/guide/env-and-mode.html#modes)).
|
|
1017
|
+
* In Wrangler the mode defaults to `undefined`.
|
|
1018
|
+
*/
|
|
1019
|
+
mode: string | undefined;
|
|
1020
|
+
}
|
|
1021
|
+
declare const DEFINITION: unique symbol;
|
|
1022
|
+
/**
|
|
1023
|
+
* The authored config in any of its supported shapes: a plain value, a promise,
|
|
1024
|
+
* or a function of {@link ConfigContext}.
|
|
1025
|
+
*/
|
|
1026
|
+
type ConfigInput<T$1> = T$1 | Promise<T$1> | ((ctx: ConfigContext) => T$1 | Promise<T$1>);
|
|
1027
|
+
/**
|
|
1028
|
+
* Resolve any `cloudflare.config.ts` export to its plain config value.
|
|
1029
|
+
*
|
|
1030
|
+
* A `define*` helper stores its authored config plus `type` under the
|
|
1031
|
+
* {@link DEFINITION} symbol; here we unwrap the config and stamp `type` back on.
|
|
1032
|
+
* Every other export — a raw object/promise/function — is unwrapped as-is and
|
|
1033
|
+
* already carries its own `type`. Discrimination happens afterwards via `type`.
|
|
1034
|
+
*/
|
|
1035
|
+
|
|
1010
1036
|
//#endregion
|
|
1011
1037
|
//#region src/types.d.ts
|
|
1012
1038
|
/**
|
|
@@ -1030,19 +1056,18 @@ type Export = DurableObjectCreatedExport | DurableObjectDeletedExport | DurableO
|
|
|
1030
1056
|
* Fields are validated at runtime by `InputWorkerSchema` and normalised before
|
|
1031
1057
|
* being passed to downstream tooling.
|
|
1032
1058
|
*/
|
|
1033
|
-
interface
|
|
1059
|
+
interface WorkerConfig {
|
|
1034
1060
|
/**
|
|
1035
|
-
*
|
|
1061
|
+
* Discriminates this config as a Worker config.
|
|
1062
|
+
*
|
|
1063
|
+
* Injected automatically by `defineWorker`; only needs to be written by
|
|
1064
|
+
* hand when authoring a raw config object without the helper.
|
|
1036
1065
|
*/
|
|
1037
|
-
|
|
1066
|
+
type: "worker";
|
|
1038
1067
|
/**
|
|
1039
|
-
*
|
|
1040
|
-
* You might have more than one account, so make sure to use
|
|
1041
|
-
* the ID of the account associated with the zone/route you
|
|
1042
|
-
* provide, if you provide one. It can also be specified through
|
|
1043
|
-
* the CLOUDFLARE_ACCOUNT_ID environment variable.
|
|
1068
|
+
* The name of your Worker.
|
|
1044
1069
|
*/
|
|
1045
|
-
|
|
1070
|
+
name: string;
|
|
1046
1071
|
/**
|
|
1047
1072
|
* A date in the form yyyy-mm-dd, which will be used to determine
|
|
1048
1073
|
* which version of the Workers runtime is used.
|
|
@@ -1231,13 +1256,6 @@ interface UserConfig {
|
|
|
1231
1256
|
* @default false
|
|
1232
1257
|
*/
|
|
1233
1258
|
previewUrls?: boolean;
|
|
1234
|
-
/**
|
|
1235
|
-
* Specify the compliance region mode of the Worker.
|
|
1236
|
-
*
|
|
1237
|
-
* Although if the user does not specify a compliance region, the default is `public`,
|
|
1238
|
-
* it can be set to `undefined` in configuration to delegate to the CLOUDFLARE_COMPLIANCE_REGION environment variable.
|
|
1239
|
-
*/
|
|
1240
|
-
complianceRegion?: "public" | "fedramp-high";
|
|
1241
1259
|
/**
|
|
1242
1260
|
* Designates this Worker as an internal-only "first-party" Worker.
|
|
1243
1261
|
*
|
|
@@ -1289,29 +1307,51 @@ interface UserConfig {
|
|
|
1289
1307
|
*/
|
|
1290
1308
|
exports?: Record<string, Export>;
|
|
1291
1309
|
}
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1310
|
+
/**
|
|
1311
|
+
* Settings shared by the other exports.
|
|
1312
|
+
* Authored as a named `settings` export via
|
|
1313
|
+
* `defineSettings`.
|
|
1314
|
+
*/
|
|
1315
|
+
interface SettingsConfig {
|
|
1295
1316
|
/**
|
|
1296
|
-
*
|
|
1297
|
-
*
|
|
1298
|
-
*
|
|
1299
|
-
*
|
|
1317
|
+
* Discriminates this config as a settings config.
|
|
1318
|
+
*
|
|
1319
|
+
* Injected automatically by `defineSettings`; only needs to be written by
|
|
1320
|
+
* hand when authoring a raw config object without the helper.
|
|
1300
1321
|
*/
|
|
1301
|
-
|
|
1322
|
+
type: "settings";
|
|
1323
|
+
/**
|
|
1324
|
+
* This is the ID of the account associated with your zone.
|
|
1325
|
+
* You might have more than one account, so make sure to use
|
|
1326
|
+
* the ID of the account associated with the zone/route you
|
|
1327
|
+
* provide, if you provide one. It can also be specified through
|
|
1328
|
+
* the CLOUDFLARE_ACCOUNT_ID environment variable.
|
|
1329
|
+
*/
|
|
1330
|
+
accountId?: string;
|
|
1331
|
+
/**
|
|
1332
|
+
* Specify the compliance region mode of the Worker.
|
|
1333
|
+
*
|
|
1334
|
+
* Although if the user does not specify a compliance region, the default is `public`,
|
|
1335
|
+
* it can be set to `undefined` in configuration to delegate to the CLOUDFLARE_COMPLIANCE_REGION environment variable.
|
|
1336
|
+
*/
|
|
1337
|
+
complianceRegion?: "public" | "fedramp-high";
|
|
1302
1338
|
}
|
|
1303
|
-
|
|
1339
|
+
//#endregion
|
|
1340
|
+
//#region src/worker-definition.d.ts
|
|
1304
1341
|
/**
|
|
1305
|
-
* Base shape of a Worker definition. Carries the
|
|
1306
|
-
* untyped cross-worker binding helpers.
|
|
1342
|
+
* Base shape of a Worker definition. Carries the authored config (under
|
|
1343
|
+
* {@link DEFINITION}) and the untyped cross-worker binding helpers.
|
|
1307
1344
|
*/
|
|
1308
|
-
interface WorkerDefinition<TConfig$1 extends
|
|
1309
|
-
[
|
|
1345
|
+
interface WorkerDefinition<TConfig$1 extends WorkerConfig = WorkerConfig> extends Pick<Bindings, "durableObject" | "worker"> {
|
|
1346
|
+
[DEFINITION]: {
|
|
1347
|
+
config: ConfigInput<Omit<TConfig$1, "type">>;
|
|
1348
|
+
type: "worker";
|
|
1349
|
+
};
|
|
1310
1350
|
}
|
|
1311
1351
|
/**
|
|
1312
1352
|
* Worker definition with typed cross-worker binding helpers.
|
|
1313
1353
|
*/
|
|
1314
|
-
interface TypedWorkerDefinition<TConfig$1 extends
|
|
1354
|
+
interface TypedWorkerDefinition<TConfig$1 extends WorkerConfig, TWorkerName extends string = InferWorkerName<TConfig$1>> extends WorkerDefinition<TConfig$1> {
|
|
1315
1355
|
/**
|
|
1316
1356
|
* Binding to a Durable Object class. `workerName` is the name of the Worker
|
|
1317
1357
|
* that defines the class; `exportName` is the exported class name.
|
|
@@ -1336,9 +1376,18 @@ interface TypedWorkerDefinition<TConfig$1 extends UserConfig, TWorkerName extend
|
|
|
1336
1376
|
remote?: boolean;
|
|
1337
1377
|
}): TypedWorkerBinding<TConfig$1, TExportName$1 extends string ? TExportName$1 : "default">;
|
|
1338
1378
|
}
|
|
1339
|
-
type
|
|
1340
|
-
|
|
1341
|
-
|
|
1379
|
+
type WorkerConfigExport<T$1 extends WorkerConfig = WorkerConfig> = ConfigInput<T$1>;
|
|
1380
|
+
/**
|
|
1381
|
+
* Authored Worker config shape — {@link WorkerConfig} without the `type`
|
|
1382
|
+
* discriminant, which `defineWorker` injects.
|
|
1383
|
+
*/
|
|
1384
|
+
type WorkerConfigInput = Omit<WorkerConfig, "type">;
|
|
1385
|
+
declare function defineWorker<const T$1 extends WorkerConfigInput>(config: (ctx: ConfigContext) => (WorkerConfigInput & T$1) | Promise<WorkerConfigInput & T$1>): TypedWorkerDefinition<T$1 & {
|
|
1386
|
+
type: "worker";
|
|
1387
|
+
}>;
|
|
1388
|
+
declare function defineWorker<const T$1 extends WorkerConfigInput>(config: (WorkerConfigInput & T$1) | Promise<WorkerConfigInput & T$1>): TypedWorkerDefinition<T$1 & {
|
|
1389
|
+
type: "worker";
|
|
1390
|
+
}>;
|
|
1342
1391
|
//#endregion
|
|
1343
1392
|
//#region src/inference.d.ts
|
|
1344
1393
|
/**
|
|
@@ -1476,7 +1525,7 @@ type InferWorkerEntrypointExports<TUnwrappedConfig$1> = Exclude<keyof InferMainM
|
|
|
1476
1525
|
* Unwrap function and promise types to get the underlying config.
|
|
1477
1526
|
* Use this to normalize a config before passing it to other inference utilities.
|
|
1478
1527
|
*/
|
|
1479
|
-
type UnwrapConfig<TConfig$1> = TConfig$1 extends WorkerDefinition<infer TUnwrappedConfig> ? TUnwrappedConfig : TConfig$1 extends
|
|
1528
|
+
type UnwrapConfig<TConfig$1> = TConfig$1 extends WorkerDefinition<infer TUnwrappedConfig> ? TUnwrappedConfig : TConfig$1 extends WorkerConfigExport<infer TUnwrappedConfig> ? TUnwrappedConfig : never;
|
|
1480
1529
|
/**
|
|
1481
1530
|
* Infer the `Env` interface type from a Worker config.
|
|
1482
1531
|
*
|
|
@@ -1546,6 +1595,23 @@ type InferMainModule<TUnwrappedConfig$1> = TUnwrappedConfig$1 extends {
|
|
|
1546
1595
|
entrypoint: infer TModule extends WorkerModule;
|
|
1547
1596
|
} ? TModule : DefaultModule;
|
|
1548
1597
|
//#endregion
|
|
1598
|
+
//#region src/settings-definition.d.ts
|
|
1599
|
+
/**
|
|
1600
|
+
* Authored settings config shape — {@link SettingsConfig} without the `type`
|
|
1601
|
+
* discriminant, which `defineSettings` injects.
|
|
1602
|
+
*/
|
|
1603
|
+
type SettingsConfigInput = Omit<SettingsConfig, "type">;
|
|
1604
|
+
/**
|
|
1605
|
+
* Declare shared settings.
|
|
1606
|
+
* Authored as a named `settings` export.
|
|
1607
|
+
*/
|
|
1608
|
+
declare function defineSettings(config: ConfigInput<SettingsConfigInput>): {
|
|
1609
|
+
[DEFINITION]: {
|
|
1610
|
+
config: ConfigInput<SettingsConfigInput>;
|
|
1611
|
+
type: string;
|
|
1612
|
+
};
|
|
1613
|
+
};
|
|
1614
|
+
//#endregion
|
|
1549
1615
|
//#endregion
|
|
1550
|
-
export { AgentMemoryBinding, AiBinding, AiSearchBinding, AiSearchNamespaceBinding, AnalyticsEngineDatasetBinding, ArtifactsBinding, AssetsBinding, Bindings, BrowserBinding, ConfigContext, D1Binding, DispatchNamespaceBinding, DurableObjectBinding, DurableObjectCreatedExport, DurableObjectDeletedExport, DurableObjectExpectingTransferExport, DurableObjectRenamedExport, DurableObjectTransferredExport, EmailTrigger, Exports, FetchTrigger, FlagshipBinding, HyperdriveBinding, ImagesBinding$1 as ImagesBinding, InferDurableNamespaces, InferEnv, InferMainModule, JsonBinding, KvBinding, LogfwdrBinding, MediaBinding$1 as MediaBinding, MtlsCertificateBinding, PipelineBinding, QueueBinding, QueueConsumerTrigger, R2Binding, RateLimitBinding, ScheduledTrigger, SecretBinding, SecretsStoreSecretBinding, SendEmailBinding, StreamBinding$1 as StreamBinding, TextBinding, Triggers, TypedAiBinding, TypedDurableObjectBinding, TypedKvBinding, TypedPipelineBinding, TypedQueueBinding, TypedWorkerBinding, TypedWorkerDefinition, TypedWorkflowBinding, UnsafeBinding, UnwrapConfig,
|
|
1616
|
+
export { AgentMemoryBinding, AiBinding, AiSearchBinding, AiSearchNamespaceBinding, AnalyticsEngineDatasetBinding, ArtifactsBinding, AssetsBinding, Bindings, BrowserBinding, ConfigContext, D1Binding, DispatchNamespaceBinding, DurableObjectBinding, DurableObjectCreatedExport, DurableObjectDeletedExport, DurableObjectExpectingTransferExport, DurableObjectRenamedExport, DurableObjectTransferredExport, EmailTrigger, Exports, FetchTrigger, FlagshipBinding, HyperdriveBinding, ImagesBinding$1 as ImagesBinding, InferDurableNamespaces, InferEnv, InferMainModule, JsonBinding, KvBinding, LogfwdrBinding, MediaBinding$1 as MediaBinding, MtlsCertificateBinding, PipelineBinding, QueueBinding, QueueConsumerTrigger, R2Binding, RateLimitBinding, ScheduledTrigger, SecretBinding, SecretsStoreSecretBinding, SendEmailBinding, SettingsConfig, SettingsConfigInput, StreamBinding$1 as StreamBinding, TextBinding, Triggers, TypedAiBinding, TypedDurableObjectBinding, TypedKvBinding, TypedPipelineBinding, TypedQueueBinding, TypedWorkerBinding, TypedWorkerDefinition, TypedWorkflowBinding, UnsafeBinding, UnwrapConfig, VectorizeBinding, VersionMetadataBinding, VpcNetworkBinding, VpcServiceBinding, WebSearchBinding, WorkerBinding, WorkerConfig, WorkerConfigExport, WorkerConfigInput, WorkerEntrypointExport, WorkerEntrypointExportOptions, WorkerLoaderBinding, WorkflowBinding, bindings, defineSettings, defineWorker, exports, triggers };
|
|
1551
1617
|
//# sourceMappingURL=experimental-config.d.mts.map
|