@cloudflare/vite-plugin 1.54.0 → 1.54.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/experimental-config.d.mts +21 -21
- package/dist/experimental-config.d.mts.map +1 -1
- package/dist/index.mjs +84 -45
- package/dist/index.mjs.map +1 -1
- package/dist/{package-UdAQsMe9.mjs → package-D3W0Crto.mjs} +2 -2
- package/dist/{package-UdAQsMe9.mjs.map → package-D3W0Crto.mjs.map} +1 -1
- package/package.json +11 -11
package/dist/index.mjs
CHANGED
|
@@ -43,8 +43,8 @@ import { basename as basename$1, dirname as dirname$1, isAbsolute as isAbsolute$
|
|
|
43
43
|
import { fileURLToPath as fileURLToPath$1 } from "url";
|
|
44
44
|
import { createRequire as createRequire$1 } from "module";
|
|
45
45
|
|
|
46
|
-
//#region ../workers-utils/dist/chunk-
|
|
47
|
-
var DEFAULT_COMPAT_DATE = "2026-08-
|
|
46
|
+
//#region ../workers-utils/dist/chunk-2DE5GBFL.mjs
|
|
47
|
+
var DEFAULT_COMPAT_DATE = "2026-08-28";
|
|
48
48
|
function assertNever(_value) {}
|
|
49
49
|
__name$5(assertNever, "assertNever");
|
|
50
50
|
function mapWorkerMetadataBindings(bindings$1) {
|
|
@@ -41819,12 +41819,24 @@ var validateWorkflowBinding$1 = /* @__PURE__ */ __name$5((diagnostics, field, va
|
|
|
41819
41819
|
for (const key of ["success_retention", "error_retention"]) if (defaultRetention[key] !== void 0 && !validateWorkflowRetentionValue$1(diagnostics, field, key, defaultRetention[key])) isValid = false;
|
|
41820
41820
|
validateAdditionalProperties$1(diagnostics, `${field}.default_retention`, Object.keys(defaultRetention), ["success_retention", "error_retention"]);
|
|
41821
41821
|
}
|
|
41822
|
+
if (hasProperty$1(value, "concurrency") && value.concurrency !== void 0) if (typeof value.concurrency !== "object" || value.concurrency === null || Array.isArray(value.concurrency)) {
|
|
41823
|
+
diagnostics.errors.push(`"${field}" bindings should, optionally, have an object "concurrency" field but got ${JSON.stringify(value)}.`);
|
|
41824
|
+
isValid = false;
|
|
41825
|
+
} else {
|
|
41826
|
+
const concurrency = value.concurrency;
|
|
41827
|
+
if (concurrency.limit !== void 0 && (typeof concurrency.limit !== "number" || !Number.isInteger(concurrency.limit) || concurrency.limit < 1)) {
|
|
41828
|
+
diagnostics.errors.push(`"${field}" bindings "concurrency.limit" field must be a positive integer but got ${JSON.stringify(concurrency.limit)}.`);
|
|
41829
|
+
isValid = false;
|
|
41830
|
+
}
|
|
41831
|
+
validateAdditionalProperties$1(diagnostics, `${field}.concurrency`, Object.keys(concurrency), ["limit"]);
|
|
41832
|
+
}
|
|
41822
41833
|
validateAdditionalProperties$1(diagnostics, field, Object.keys(value), [
|
|
41823
41834
|
"binding",
|
|
41824
41835
|
"name",
|
|
41825
41836
|
"class_name",
|
|
41826
41837
|
"script_name",
|
|
41827
41838
|
"limits",
|
|
41839
|
+
"concurrency",
|
|
41828
41840
|
"schedules",
|
|
41829
41841
|
"default_retention"
|
|
41830
41842
|
]);
|
|
@@ -53944,7 +53956,7 @@ const BrowserBindingSchema = strictObject$1({
|
|
|
53944
53956
|
});
|
|
53945
53957
|
const WorkerBindingSchema = strictObject$1({
|
|
53946
53958
|
type: literal$2("worker"),
|
|
53947
|
-
|
|
53959
|
+
worker: string$1(),
|
|
53948
53960
|
exportName: string$1().optional(),
|
|
53949
53961
|
props: record$1(string$1(), unknown$1()).optional(),
|
|
53950
53962
|
dev: RemoteBindingDevSchema.optional()
|
|
@@ -54022,14 +54034,14 @@ const KnownBindingSchema = discriminatedUnion$1("type", [
|
|
|
54022
54034
|
type: literal$2("dispatch-namespace"),
|
|
54023
54035
|
namespace: string$1().optional(),
|
|
54024
54036
|
outbound: strictObject$1({
|
|
54025
|
-
|
|
54037
|
+
worker: string$1(),
|
|
54026
54038
|
parameters: array$1(string$1()).optional()
|
|
54027
54039
|
}).optional(),
|
|
54028
54040
|
dev: RemoteBindingDevSchema.optional()
|
|
54029
54041
|
}),
|
|
54030
54042
|
strictObject$1({
|
|
54031
54043
|
type: literal$2("durable-object"),
|
|
54032
|
-
|
|
54044
|
+
worker: string$1(),
|
|
54033
54045
|
exportName: string$1()
|
|
54034
54046
|
}),
|
|
54035
54047
|
FlagshipBindingSchema,
|
|
@@ -54259,7 +54271,7 @@ const PlacementSchema = union$1([
|
|
|
54259
54271
|
})
|
|
54260
54272
|
]);
|
|
54261
54273
|
const TailConsumerSchema = strictObject$1({
|
|
54262
|
-
|
|
54274
|
+
worker: string$1(),
|
|
54263
54275
|
streaming: boolean$1().optional()
|
|
54264
54276
|
});
|
|
54265
54277
|
const TriggerSchema = discriminatedUnion$1("type", [
|
|
@@ -57181,7 +57193,7 @@ function convertBindingsAndAssets(config$3, result) {
|
|
|
57181
57193
|
namespace: binding.namespace
|
|
57182
57194
|
};
|
|
57183
57195
|
if (binding.outbound) entry.outbound = omitUndefined({
|
|
57184
|
-
service: binding.outbound.
|
|
57196
|
+
service: binding.outbound.worker,
|
|
57185
57197
|
parameters: binding.outbound.parameters
|
|
57186
57198
|
});
|
|
57187
57199
|
if (binding.dev?.remote !== void 0) entry.remote = binding.dev.remote;
|
|
@@ -57192,7 +57204,7 @@ function convertBindingsAndAssets(config$3, result) {
|
|
|
57192
57204
|
durableObjectBindings.push({
|
|
57193
57205
|
name,
|
|
57194
57206
|
class_name: binding.exportName,
|
|
57195
|
-
script_name: binding.
|
|
57207
|
+
script_name: binding.worker
|
|
57196
57208
|
});
|
|
57197
57209
|
break;
|
|
57198
57210
|
case "flagship":
|
|
@@ -57343,7 +57355,7 @@ function convertBindingsAndAssets(config$3, result) {
|
|
|
57343
57355
|
case "worker":
|
|
57344
57356
|
services.push(omitUndefined({
|
|
57345
57357
|
binding: name,
|
|
57346
|
-
service: binding.
|
|
57358
|
+
service: binding.worker,
|
|
57347
57359
|
entrypoint: binding.exportName,
|
|
57348
57360
|
props: binding.props,
|
|
57349
57361
|
remote: binding.dev?.remote
|
|
@@ -57524,8 +57536,8 @@ function convertTailConsumers(config$3, result) {
|
|
|
57524
57536
|
if (!consumers || consumers.length === 0) return;
|
|
57525
57537
|
const tail$1 = [];
|
|
57526
57538
|
const streaming = [];
|
|
57527
|
-
for (const consumer of consumers) if (consumer.streaming) streaming.push({ service: consumer.
|
|
57528
|
-
else tail$1.push({ service: consumer.
|
|
57539
|
+
for (const consumer of consumers) if (consumer.streaming) streaming.push({ service: consumer.worker });
|
|
57540
|
+
else tail$1.push({ service: consumer.worker });
|
|
57529
57541
|
if (tail$1.length) result.tail_consumers = tail$1;
|
|
57530
57542
|
if (streaming.length) result.streaming_tail_consumers = streaming;
|
|
57531
57543
|
}
|
|
@@ -98744,12 +98756,24 @@ var validateWorkflowBinding = /* @__PURE__ */ __name$3((diagnostics, field, valu
|
|
|
98744
98756
|
for (const key of ["success_retention", "error_retention"]) if (defaultRetention[key] !== void 0 && !validateWorkflowRetentionValue(diagnostics, field, key, defaultRetention[key])) isValid = false;
|
|
98745
98757
|
validateAdditionalProperties(diagnostics, `${field}.default_retention`, Object.keys(defaultRetention), ["success_retention", "error_retention"]);
|
|
98746
98758
|
}
|
|
98759
|
+
if (hasProperty(value, "concurrency") && value.concurrency !== void 0) if (typeof value.concurrency !== "object" || value.concurrency === null || Array.isArray(value.concurrency)) {
|
|
98760
|
+
diagnostics.errors.push(`"${field}" bindings should, optionally, have an object "concurrency" field but got ${JSON.stringify(value)}.`);
|
|
98761
|
+
isValid = false;
|
|
98762
|
+
} else {
|
|
98763
|
+
const concurrency = value.concurrency;
|
|
98764
|
+
if (concurrency.limit !== void 0 && (typeof concurrency.limit !== "number" || !Number.isInteger(concurrency.limit) || concurrency.limit < 1)) {
|
|
98765
|
+
diagnostics.errors.push(`"${field}" bindings "concurrency.limit" field must be a positive integer but got ${JSON.stringify(concurrency.limit)}.`);
|
|
98766
|
+
isValid = false;
|
|
98767
|
+
}
|
|
98768
|
+
validateAdditionalProperties(diagnostics, `${field}.concurrency`, Object.keys(concurrency), ["limit"]);
|
|
98769
|
+
}
|
|
98747
98770
|
validateAdditionalProperties(diagnostics, field, Object.keys(value), [
|
|
98748
98771
|
"binding",
|
|
98749
98772
|
"name",
|
|
98750
98773
|
"class_name",
|
|
98751
98774
|
"script_name",
|
|
98752
98775
|
"limits",
|
|
98776
|
+
"concurrency",
|
|
98753
98777
|
"schedules",
|
|
98754
98778
|
"default_retention"
|
|
98755
98779
|
]);
|
|
@@ -102466,11 +102490,9 @@ const BUILD_OUTPUT_ROOT = ".cloudflare/output";
|
|
|
102466
102490
|
*/
|
|
102467
102491
|
const CONFIG_FILENAME = "config.json";
|
|
102468
102492
|
/**
|
|
102469
|
-
* Name of the sub-directory under `workers/` holding the Worker.
|
|
102470
|
-
*
|
|
102471
|
-
* This corresponds with the export name in the input `cloudflare.config.ts`.
|
|
102493
|
+
* Name of the sub-directory under `workers/` holding the default Worker.
|
|
102472
102494
|
*/
|
|
102473
|
-
const
|
|
102495
|
+
const DEFAULT_WORKER_DIRECTORY_NAME = "default";
|
|
102474
102496
|
/**
|
|
102475
102497
|
* Absolute path to the Build Output Specification root for the current project.
|
|
102476
102498
|
*/
|
|
@@ -102494,28 +102516,29 @@ function getWorkersDir(root) {
|
|
|
102494
102516
|
return path2.join(getBuildOutputDir(root), BUILD_OUTPUT_VERSION, "workers");
|
|
102495
102517
|
}
|
|
102496
102518
|
/**
|
|
102497
|
-
* Absolute path to
|
|
102519
|
+
* Absolute path to a Worker's directory (`workers/<worker-directory-name>`).
|
|
102498
102520
|
*/
|
|
102499
|
-
function getWorkerDir(root) {
|
|
102500
|
-
|
|
102521
|
+
function getWorkerDir(root, workerDirectoryName = DEFAULT_WORKER_DIRECTORY_NAME) {
|
|
102522
|
+
if (workerDirectoryName.length === 0 || workerDirectoryName === "." || workerDirectoryName === ".." || workerDirectoryName.includes("/") || workerDirectoryName.includes("\\") || workerDirectoryName.includes("\0")) throw new Error("Worker directory names must be non-empty, single path segments.");
|
|
102523
|
+
return path2.join(getWorkersDir(root), workerDirectoryName);
|
|
102501
102524
|
}
|
|
102502
102525
|
/**
|
|
102503
102526
|
* Absolute path to the Worker's config file.
|
|
102504
102527
|
*/
|
|
102505
|
-
function getWorkerConfigPath(root) {
|
|
102506
|
-
return path2.join(getWorkerDir(root), CONFIG_FILENAME);
|
|
102528
|
+
function getWorkerConfigPath(root, workerDirectoryName = DEFAULT_WORKER_DIRECTORY_NAME) {
|
|
102529
|
+
return path2.join(getWorkerDir(root, workerDirectoryName), CONFIG_FILENAME);
|
|
102507
102530
|
}
|
|
102508
102531
|
/**
|
|
102509
102532
|
* Absolute path to the Worker's bundle directory.
|
|
102510
102533
|
*/
|
|
102511
|
-
function getWorkerBundleDir(root) {
|
|
102512
|
-
return path2.join(getWorkerDir(root), "bundle");
|
|
102534
|
+
function getWorkerBundleDir(root, workerDirectoryName = DEFAULT_WORKER_DIRECTORY_NAME) {
|
|
102535
|
+
return path2.join(getWorkerDir(root, workerDirectoryName), "bundle");
|
|
102513
102536
|
}
|
|
102514
102537
|
/**
|
|
102515
102538
|
* Absolute path to the Worker's assets directory.
|
|
102516
102539
|
*/
|
|
102517
|
-
function getWorkerAssetsDir(root) {
|
|
102518
|
-
return path2.join(getWorkerDir(root), "assets");
|
|
102540
|
+
function getWorkerAssetsDir(root, workerDirectoryName = DEFAULT_WORKER_DIRECTORY_NAME) {
|
|
102541
|
+
return path2.join(getWorkerDir(root, workerDirectoryName), "assets");
|
|
102519
102542
|
}
|
|
102520
102543
|
var __defProp$2 = Object.defineProperty;
|
|
102521
102544
|
var __name$2 = (target$1, value) => __defProp$2(target$1, "name", {
|
|
@@ -102553,20 +102576,19 @@ async function cleanBuildOutputDir(root) {
|
|
|
102553
102576
|
await removeDir(getBuildOutputDir(root));
|
|
102554
102577
|
}
|
|
102555
102578
|
/**
|
|
102556
|
-
* Write
|
|
102557
|
-
* tree (`workers/default/`).
|
|
102579
|
+
* Write an output Worker `config.json` to the Build Output Specification tree.
|
|
102558
102580
|
*
|
|
102559
102581
|
* - Workers mode: `manifest` is provided (bundle/ present on disk).
|
|
102560
102582
|
* - Assets-only mode: `manifest` is omitted (no bundle/ directory).
|
|
102561
102583
|
*/
|
|
102562
|
-
async function writeWorkerConfig(root,
|
|
102563
|
-
const { entrypoint: _entrypoint,...rest } =
|
|
102584
|
+
async function writeWorkerConfig({ root, config: config$3, manifest, workerDirectoryName = DEFAULT_WORKER_DIRECTORY_NAME }) {
|
|
102585
|
+
const { entrypoint: _entrypoint,...rest } = config$3;
|
|
102564
102586
|
const outputConfig = {
|
|
102565
102587
|
...rest,
|
|
102566
102588
|
manifest
|
|
102567
102589
|
};
|
|
102568
|
-
await fsp.mkdir(getWorkerDir(root), { recursive: true });
|
|
102569
|
-
await fsp.writeFile(getWorkerConfigPath(root), JSON.stringify(outputConfig));
|
|
102590
|
+
await fsp.mkdir(getWorkerDir(root, workerDirectoryName), { recursive: true });
|
|
102591
|
+
await fsp.writeFile(getWorkerConfigPath(root, workerDirectoryName), JSON.stringify(outputConfig));
|
|
102570
102592
|
}
|
|
102571
102593
|
/**
|
|
102572
102594
|
* Write the top-level `config.json` to the Build Output Specification tree.
|
|
@@ -102612,11 +102634,18 @@ var BuildOutputError = class extends Error {
|
|
|
102612
102634
|
* the Worker config is missing, is not valid JSON, or fails schema validation.
|
|
102613
102635
|
*/
|
|
102614
102636
|
async function readBuildOutput(root) {
|
|
102637
|
+
const settings = await readSettings(root);
|
|
102638
|
+
const defaultWorker = await readWorker(root, DEFAULT_WORKER_DIRECTORY_NAME);
|
|
102639
|
+
const additionalWorkerDirectoryNames = (await fsp.readdir(getWorkersDir(root), { withFileTypes: true })).filter((entry) => entry.isDirectory() && entry.name !== DEFAULT_WORKER_DIRECTORY_NAME).map((entry) => entry.name).sort();
|
|
102640
|
+
const additionalWorkers = await Promise.all(additionalWorkerDirectoryNames.map(async (workerDirectoryName) => [workerDirectoryName, await readWorker(root, workerDirectoryName)]));
|
|
102615
102641
|
return {
|
|
102616
102642
|
root,
|
|
102617
102643
|
version: BUILD_OUTPUT_VERSION,
|
|
102618
|
-
settings
|
|
102619
|
-
workers:
|
|
102644
|
+
settings,
|
|
102645
|
+
workers: {
|
|
102646
|
+
default: defaultWorker,
|
|
102647
|
+
...Object.fromEntries(additionalWorkers)
|
|
102648
|
+
}
|
|
102620
102649
|
};
|
|
102621
102650
|
}
|
|
102622
102651
|
/**
|
|
@@ -102627,14 +102656,14 @@ async function readBuildOutput(root) {
|
|
|
102627
102656
|
* @throws {BuildOutputError} if the config is missing, is not valid JSON, or
|
|
102628
102657
|
* fails schema validation.
|
|
102629
102658
|
*/
|
|
102630
|
-
async function readWorker(root) {
|
|
102631
|
-
const configPath = getWorkerConfigPath(root);
|
|
102659
|
+
async function readWorker(root, workerDirectoryName) {
|
|
102660
|
+
const configPath = getWorkerConfigPath(root, workerDirectoryName);
|
|
102632
102661
|
if (!fs$1.existsSync(configPath)) throw new BuildOutputError(`no Worker config found at ${configPath}.`);
|
|
102633
102662
|
const contents = await fsp.readFile(configPath, "utf-8");
|
|
102634
102663
|
const result = OutputWorkerSchema.safeParse(parseJson(contents, configPath));
|
|
102635
102664
|
if (!result.success) throw new BuildOutputError(`invalid Worker config at ${configPath}.\n${result.error.message}`);
|
|
102636
|
-
const bundleDir = getWorkerBundleDir(root);
|
|
102637
|
-
const assetsDir = getWorkerAssetsDir(root);
|
|
102665
|
+
const bundleDir = getWorkerBundleDir(root, workerDirectoryName);
|
|
102666
|
+
const assetsDir = getWorkerAssetsDir(root, workerDirectoryName);
|
|
102638
102667
|
const hasBundleDir = fs$1.existsSync(bundleDir);
|
|
102639
102668
|
const hasAssetsDir = fs$1.existsSync(assetsDir);
|
|
102640
102669
|
if (result.data.manifest && !hasBundleDir) throw new BuildOutputError(`Worker config at ${configPath} contains a manifest, but no bundle directory exists at ${bundleDir}.`);
|
|
@@ -102687,12 +102716,12 @@ function parseJson(contents, configPath) {
|
|
|
102687
102716
|
* `<root>/.cloudflare/output/v0/workers/default/` and reconstruct a
|
|
102688
102717
|
* `BuildOutputPreviewWorker`.
|
|
102689
102718
|
*
|
|
102690
|
-
*
|
|
102691
|
-
* array.
|
|
102719
|
+
* Preview currently uses only the `default` Worker, so this returns a
|
|
102720
|
+
* single-element array.
|
|
102692
102721
|
*/
|
|
102693
102722
|
async function readBuildOutputWorkers(root) {
|
|
102694
102723
|
const { workers, settings } = await readBuildOutput(root);
|
|
102695
|
-
const
|
|
102724
|
+
const worker = workers[DEFAULT_WORKER_DIRECTORY_NAME];
|
|
102696
102725
|
const { manifest,...inputShape } = worker.config;
|
|
102697
102726
|
const { config: config$3, diagnostics } = normalizeAndValidateConfig(convertToWranglerConfig(inputShape, settings), void 0, void 0, {}, true);
|
|
102698
102727
|
if (diagnostics.hasWarnings()) console.warn(diagnostics.renderWarnings());
|
|
@@ -111732,7 +111761,10 @@ const buildOutputPlugin = createPlugin("build-output", (ctx) => {
|
|
|
111732
111761
|
const defaultExport = ctx.resolvedPluginConfig.parsedNewConfig?.default;
|
|
111733
111762
|
const workerNewConfig$1 = defaultExport?.type === "worker" ? defaultExport : void 0;
|
|
111734
111763
|
assert2(workerNewConfig$1, "Expected a default worker export on assets-only resolved config");
|
|
111735
|
-
await writeWorkerConfig(
|
|
111764
|
+
await writeWorkerConfig({
|
|
111765
|
+
root: ctx.resolvedViteConfig.root,
|
|
111766
|
+
config: workerNewConfig$1
|
|
111767
|
+
});
|
|
111736
111768
|
await writeSettings();
|
|
111737
111769
|
return;
|
|
111738
111770
|
}
|
|
@@ -111749,9 +111781,13 @@ const buildOutputPlugin = createPlugin("build-output", (ctx) => {
|
|
|
111749
111781
|
if (importedAssetPaths.has(fileName)) continue;
|
|
111750
111782
|
modules[fileName] = { type: detectModuleType(fileName) };
|
|
111751
111783
|
}
|
|
111752
|
-
await writeWorkerConfig(
|
|
111753
|
-
|
|
111754
|
-
|
|
111784
|
+
await writeWorkerConfig({
|
|
111785
|
+
root: ctx.resolvedViteConfig.root,
|
|
111786
|
+
config: workerNewConfig,
|
|
111787
|
+
manifest: {
|
|
111788
|
+
mainModule: entryChunk.fileName,
|
|
111789
|
+
modules
|
|
111790
|
+
}
|
|
111755
111791
|
});
|
|
111756
111792
|
await writeSettings();
|
|
111757
111793
|
} };
|
|
@@ -114124,7 +114160,10 @@ const configPlugin = createPlugin("config", (ctx) => {
|
|
|
114124
114160
|
if (cfBuildOutput) {
|
|
114125
114161
|
const entryWorkerNewConfig = ctx.getWorkerNewConfig(entryWorkerEnvironmentName);
|
|
114126
114162
|
assert2(entryWorkerNewConfig, `No config found for "${entryWorkerEnvironmentName}" environment`);
|
|
114127
|
-
await writeWorkerConfig(
|
|
114163
|
+
await writeWorkerConfig({
|
|
114164
|
+
root: builder.config.root,
|
|
114165
|
+
config: entryWorkerNewConfig
|
|
114166
|
+
});
|
|
114128
114167
|
} else {
|
|
114129
114168
|
const entryWorkerConfig = ctx.getWorkerConfig(entryWorkerEnvironmentName);
|
|
114130
114169
|
assert2(entryWorkerConfig, `No config found for "${entryWorkerEnvironmentName}" environment`);
|
|
@@ -123867,7 +123906,7 @@ __name(createWorkerUploadForm, "createWorkerUploadForm");
|
|
|
123867
123906
|
//#endregion
|
|
123868
123907
|
//#region ../remote-bindings/dist/index.mjs
|
|
123869
123908
|
var import_undici = require_undici();
|
|
123870
|
-
var version$2 = "0.0.
|
|
123909
|
+
var version$2 = "0.0.17";
|
|
123871
123910
|
var NoDefaultValueProvided = class extends UserError {
|
|
123872
123911
|
constructor() {
|
|
123873
123912
|
super("This command cannot be run in a non-interactive context", { telemetryMessage: "remote bindings prompt default missing" });
|