@cloudflare/vite-plugin 2.0.0-beta.v.14 → 2.0.0-beta.v.15
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/cf-vite.mjs +0 -6
- package/dist/index.mjs +151 -123
- package/dist/{package-SsjAyYbP.mjs → package-ByA-1wsg.mjs} +1 -1
- package/package.json +11 -11
package/dist/cf-vite.mjs
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { parseArgs } from "node:util";
|
|
2
2
|
import { createBuilder, createServer } from "vite";
|
|
3
3
|
|
|
4
|
-
//#region src/build-output-env.ts
|
|
5
|
-
/** Internal caller name set by the `cf-vite` delegate. */
|
|
6
|
-
const CLI_DISPLAY_NAME_ENV_VAR = "CLOUDFLARE_VITE_CLI_DISPLAY_NAME";
|
|
7
|
-
|
|
8
|
-
//#endregion
|
|
9
4
|
//#region src/cf-vite.ts
|
|
10
5
|
/**
|
|
11
6
|
* `cf-vite` delegate binary entry point for `@cloudflare/vite-plugin`.
|
|
@@ -89,7 +84,6 @@ function parseBuildArgs(argv) {
|
|
|
89
84
|
return out;
|
|
90
85
|
}
|
|
91
86
|
async function main() {
|
|
92
|
-
process.env[CLI_DISPLAY_NAME_ENV_VAR] = "cf";
|
|
93
87
|
const verb = process.argv[2];
|
|
94
88
|
const userArgv = process.argv.slice(3);
|
|
95
89
|
if (verb === "dev") return runDev(userArgv);
|
package/dist/index.mjs
CHANGED
|
@@ -52084,6 +52084,53 @@ function getWranglerTmpDir(projectRoot, prefix, cleanup = true) {
|
|
|
52084
52084
|
};
|
|
52085
52085
|
}
|
|
52086
52086
|
__name$3(getWranglerTmpDir, "getWranglerTmpDir");
|
|
52087
|
+
var MetricsRegistry = class {
|
|
52088
|
+
static {
|
|
52089
|
+
__name$3(this, "MetricsRegistry");
|
|
52090
|
+
}
|
|
52091
|
+
counters = [];
|
|
52092
|
+
/**
|
|
52093
|
+
* Create and register a new counter metric.
|
|
52094
|
+
*
|
|
52095
|
+
* @param name - The metric name (e.g. "service_request_total")
|
|
52096
|
+
* @param help - A human-readable description of the metric
|
|
52097
|
+
* @returns A Counter that can be incremented
|
|
52098
|
+
*/
|
|
52099
|
+
createCounter(name, help) {
|
|
52100
|
+
const entry = {
|
|
52101
|
+
name,
|
|
52102
|
+
help,
|
|
52103
|
+
value: 0
|
|
52104
|
+
};
|
|
52105
|
+
this.counters.push(entry);
|
|
52106
|
+
return {
|
|
52107
|
+
inc: /* @__PURE__ */ __name$3(() => {
|
|
52108
|
+
entry.value++;
|
|
52109
|
+
}, "inc"),
|
|
52110
|
+
add: /* @__PURE__ */ __name$3((amount) => {
|
|
52111
|
+
if (amount < 0) throw new Error("Counter value cannot decrease");
|
|
52112
|
+
entry.value += amount;
|
|
52113
|
+
}, "add")
|
|
52114
|
+
};
|
|
52115
|
+
}
|
|
52116
|
+
/**
|
|
52117
|
+
* Serialize all registered metrics in Prometheus text exposition format.
|
|
52118
|
+
*
|
|
52119
|
+
* @see https://prometheus.io/docs/instrumenting/exposition_formats/#text-based-format
|
|
52120
|
+
*/
|
|
52121
|
+
metrics() {
|
|
52122
|
+
return this.counters.map((c$1) => {
|
|
52123
|
+
let result = "";
|
|
52124
|
+
if (c$1.help.length > 0) result += `# HELP ${c$1.name} ${c$1.help}
|
|
52125
|
+
`;
|
|
52126
|
+
result += `# TYPE ${c$1.name} counter
|
|
52127
|
+
`;
|
|
52128
|
+
result += `${c$1.name} ${c$1.value}
|
|
52129
|
+
`;
|
|
52130
|
+
return result;
|
|
52131
|
+
}).join("");
|
|
52132
|
+
}
|
|
52133
|
+
};
|
|
52087
52134
|
function buildDetailedError(message, ...extra) {
|
|
52088
52135
|
return new ParseError({
|
|
52089
52136
|
text: message,
|
|
@@ -69035,6 +69082,8 @@ const ROUTER_WORKER_NAME = "__router-worker__";
|
|
|
69035
69082
|
const ASSET_WORKER_NAME = "__asset-worker__";
|
|
69036
69083
|
const VITE_PROXY_WORKER_NAME = "__vite_proxy_worker__";
|
|
69037
69084
|
const PROXY_SHARED_SECRET = randomUUID();
|
|
69085
|
+
/** The CLI named in actionable messages. The plugin is only compatible with `cf`. */
|
|
69086
|
+
const CLI_DISPLAY_NAME = "cf";
|
|
69038
69087
|
const kRequestType = Symbol("kRequestType");
|
|
69039
69088
|
|
|
69040
69089
|
//#endregion
|
|
@@ -71944,14 +71993,8 @@ const PRERENDER_WORKER_DIRECTORY_NAME = "prerender";
|
|
|
71944
71993
|
|
|
71945
71994
|
//#endregion
|
|
71946
71995
|
//#region src/build-output-env.ts
|
|
71947
|
-
/** Internal caller name set by the `cf-vite` delegate. */
|
|
71948
|
-
const CLI_DISPLAY_NAME_ENV_VAR = "CLOUDFLARE_VITE_CLI_DISPLAY_NAME";
|
|
71949
71996
|
/** Shared build context flag set by Cloudflare tooling for Preview builds. */
|
|
71950
71997
|
const PREVIEW_BUILD_ENV_VAR = "CLOUDFLARE_PREVIEW_BUILD";
|
|
71951
|
-
/** Return the CLI name used in actionable messages. */
|
|
71952
|
-
function getCliDisplayName() {
|
|
71953
|
-
return process.env[CLI_DISPLAY_NAME_ENV_VAR] === "cf" ? "cf" : "Wrangler";
|
|
71954
|
-
}
|
|
71955
71998
|
/** Whether Cloudflare tooling requested Preview Build Output. */
|
|
71956
71999
|
function isPreviewBuild() {
|
|
71957
72000
|
return process.env[PREVIEW_BUILD_ENV_VAR] === "true";
|
|
@@ -78642,7 +78685,6 @@ async function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
78642
78685
|
Object.assign(process.env, Object.fromEntries(Object.entries(localEnv.values).filter(([name]) => name.startsWith("CLOUDFLARE_"))));
|
|
78643
78686
|
const types$5 = normalizeTypes(pluginConfig.types);
|
|
78644
78687
|
const shared = {
|
|
78645
|
-
cliDisplayName: getCliDisplayName(),
|
|
78646
78688
|
persistState: pluginConfig.persistState ?? true,
|
|
78647
78689
|
inspectorPort: pluginConfig.inspectorPort,
|
|
78648
78690
|
types: types$5,
|
|
@@ -85882,7 +85924,7 @@ async function prepareContainerImagesForDev(args) {
|
|
|
85882
85924
|
dockerPath,
|
|
85883
85925
|
operation: args.operation ?? "running dev",
|
|
85884
85926
|
imageNoun: containerOptions.length !== 1 ? "the configured images" : "the configured image",
|
|
85885
|
-
hint: args.
|
|
85927
|
+
hint: args.dockerUnavailableHint
|
|
85886
85928
|
});
|
|
85887
85929
|
for (const options of containerOptions) {
|
|
85888
85930
|
if ("dockerfile" in options) {
|
|
@@ -87564,6 +87606,20 @@ function createContainerPreviewPlanForCfConfig(options) {
|
|
|
87564
87606
|
});
|
|
87565
87607
|
}
|
|
87566
87608
|
__name$2(createContainerPreviewPlanForCfConfig, "createContainerPreviewPlanForCfConfig");
|
|
87609
|
+
function createMiniflareExports(options) {
|
|
87610
|
+
const workerExports = {};
|
|
87611
|
+
for (const [name, workerExport] of Object.entries(options.exports ?? {})) if (workerExport.type === "durable-object" && "storage" in workerExport) {
|
|
87612
|
+
const containerName = "container" in workerExport ? workerExport.container : void 0;
|
|
87613
|
+
const container = containerName === void 0 ? void 0 : options.containerRuntimeOptions?.get(name);
|
|
87614
|
+
assert(containerName === void 0 || container !== void 0, `Expected runtime options for Container-backed Durable Object export "${name}".`);
|
|
87615
|
+
workerExports[name] = {
|
|
87616
|
+
...workerExport,
|
|
87617
|
+
container
|
|
87618
|
+
};
|
|
87619
|
+
} else workerExports[name] = workerExport;
|
|
87620
|
+
return workerExports;
|
|
87621
|
+
}
|
|
87622
|
+
__name$2(createMiniflareExports, "createMiniflareExports");
|
|
87567
87623
|
function createContainerPlanForCfConfig(options) {
|
|
87568
87624
|
const containersByName = indexContainersByName(options.containers);
|
|
87569
87625
|
const containerOptions = [];
|
|
@@ -87960,6 +88016,78 @@ function isValidImageTag(value) {
|
|
|
87960
88016
|
}
|
|
87961
88017
|
__name$2(isValidImageTag, "isValidImageTag");
|
|
87962
88018
|
|
|
88019
|
+
//#endregion
|
|
88020
|
+
//#region src/build.ts
|
|
88021
|
+
var import_picocolors$4 = /* @__PURE__ */ __toESM$2(require_picocolors(), 1);
|
|
88022
|
+
const CLIENT_FALLBACK_ENTRY_NAME = "__cloudflare_fallback_entry__";
|
|
88023
|
+
/** Build the remaining Worker and client environments and transfer imported assets. */
|
|
88024
|
+
async function buildApp(builder, resolvedPluginConfig, environmentNameToImportedAssetPaths) {
|
|
88025
|
+
const clientEnvironment = builder.environments.client;
|
|
88026
|
+
assert(clientEnvironment, `No "client" environment`);
|
|
88027
|
+
const defaultHtmlPath = path.resolve(builder.config.root, "index.html");
|
|
88028
|
+
const hasClientEntry = clientEnvironment.config.build.rollupOptions.input || fs$3.existsSync(defaultHtmlPath);
|
|
88029
|
+
const workerEnvironments = [...resolvedPluginConfig.environmentNameToWorkerMap.entries()].filter(([_, worker]) => !resolveDevOnly(worker.devOnly)).map(([environmentName]) => {
|
|
88030
|
+
const environment = builder.environments[environmentName];
|
|
88031
|
+
assert(environment, `"${environmentName}" environment not found`);
|
|
88032
|
+
return environment;
|
|
88033
|
+
});
|
|
88034
|
+
await Promise.all(workerEnvironments.filter((environment) => !environment.isBuilt).map((environment) => builder.build(environment)));
|
|
88035
|
+
const assetEnvironments = workerEnvironments.filter((environment) => environment.name === resolvedPluginConfig.prerenderWorkerEnvironmentName || resolvedPluginConfig.type === "workers" && environment.name === resolvedPluginConfig.entryWorkerEnvironmentName).flatMap((environment) => {
|
|
88036
|
+
return [environment, ...(resolvedPluginConfig.environmentNameToChildEnvironmentNamesMap.get(environment.name) ?? []).map((name) => {
|
|
88037
|
+
const childEnvironment = builder.environments[name];
|
|
88038
|
+
assert(childEnvironment, `"${name}" environment not found`);
|
|
88039
|
+
return childEnvironment;
|
|
88040
|
+
}).filter((childEnvironment) => childEnvironment.isBuilt)].map((assetEnvironment) => ({
|
|
88041
|
+
environment: assetEnvironment,
|
|
88042
|
+
preserveOriginalAssets: environment.name === resolvedPluginConfig.prerenderWorkerEnvironmentName
|
|
88043
|
+
}));
|
|
88044
|
+
});
|
|
88045
|
+
if (!clientEnvironment.isBuilt) {
|
|
88046
|
+
if (hasClientEntry) await builder.build(clientEnvironment);
|
|
88047
|
+
else if (assetEnvironments.some(({ environment }) => environmentNameToImportedAssetPaths.get(environment.name)?.size) || getHasPublicAssets(builder.config) || resolvedPluginConfig.prerenderWorkerEnvironmentName) await fallbackBuild(builder, clientEnvironment);
|
|
88048
|
+
}
|
|
88049
|
+
if (!clientEnvironment.isBuilt) return;
|
|
88050
|
+
const clientBuildDirectory = path.resolve(builder.config.root, clientEnvironment.config.build.outDir);
|
|
88051
|
+
for (const { environment, preserveOriginalAssets } of assetEnvironments) {
|
|
88052
|
+
const importedAssetPaths = environmentNameToImportedAssetPaths.get(environment.name);
|
|
88053
|
+
if (!importedAssetPaths?.size) continue;
|
|
88054
|
+
const workerBuildDirectory = path.resolve(builder.config.root, environment.config.build.outDir);
|
|
88055
|
+
const transferredAssetPaths = [];
|
|
88056
|
+
for (const assetPath of importedAssetPaths) {
|
|
88057
|
+
const src$1 = path.join(workerBuildDirectory, assetPath);
|
|
88058
|
+
const dest = path.join(clientBuildDirectory, assetPath);
|
|
88059
|
+
if (!fs$3.existsSync(src$1)) continue;
|
|
88060
|
+
if (fs$3.existsSync(dest)) {
|
|
88061
|
+
if (!preserveOriginalAssets) fs$3.unlinkSync(src$1);
|
|
88062
|
+
} else {
|
|
88063
|
+
const destDir = path.dirname(dest);
|
|
88064
|
+
fs$3.mkdirSync(destDir, { recursive: true });
|
|
88065
|
+
if (preserveOriginalAssets) fs$3.copyFileSync(src$1, dest);
|
|
88066
|
+
else fs$3.renameSync(src$1, dest);
|
|
88067
|
+
transferredAssetPaths.push(dest);
|
|
88068
|
+
}
|
|
88069
|
+
}
|
|
88070
|
+
if (transferredAssetPaths.length) builder.config.logger.info([`${import_picocolors$4.default.green("✓")} ${transferredAssetPaths.length} asset${transferredAssetPaths.length > 1 ? "s" : ""} ${preserveOriginalAssets ? "copied" : "moved"} from "${environment.name}" to "client" build output.`, ...transferredAssetPaths.map((assetPath) => import_picocolors$4.default.dim(path.relative(builder.config.root, assetPath)))].join("\n"));
|
|
88071
|
+
}
|
|
88072
|
+
}
|
|
88073
|
+
function getHasPublicAssets({ publicDir }) {
|
|
88074
|
+
let hasPublicAssets = false;
|
|
88075
|
+
if (publicDir) try {
|
|
88076
|
+
if (fs$3.readdirSync(publicDir).length) hasPublicAssets = true;
|
|
88077
|
+
} catch {}
|
|
88078
|
+
return hasPublicAssets;
|
|
88079
|
+
}
|
|
88080
|
+
async function fallbackBuild(builder, environment) {
|
|
88081
|
+
environment.config.build.rollupOptions = {
|
|
88082
|
+
input: VIRTUAL_CLIENT_FALLBACK_ENTRY,
|
|
88083
|
+
logLevel: "silent",
|
|
88084
|
+
output: { entryFileNames: CLIENT_FALLBACK_ENTRY_NAME }
|
|
88085
|
+
};
|
|
88086
|
+
await builder.build(environment);
|
|
88087
|
+
const fallbackEntryPath = path.resolve(builder.config.root, environment.config.build.outDir, CLIENT_FALLBACK_ENTRY_NAME);
|
|
88088
|
+
fs$3.unlinkSync(fallbackEntryPath);
|
|
88089
|
+
}
|
|
88090
|
+
|
|
87963
88091
|
//#endregion
|
|
87964
88092
|
//#region src/cloudflare-environment.ts
|
|
87965
88093
|
const MAIN_ENTRY_NAME = "index";
|
|
@@ -88123,7 +88251,6 @@ function createCloudflareEnvironmentOptions({ workerConfig, userConfig, mode, en
|
|
|
88123
88251
|
target,
|
|
88124
88252
|
cssTarget: getWorkerCssTarget(userConfig, environmentName),
|
|
88125
88253
|
emitAssets: true,
|
|
88126
|
-
manifest: isParentEnvironment,
|
|
88127
88254
|
outDir: getOutputDirectory(userConfig, environmentName),
|
|
88128
88255
|
sourcemap: getWorkerSourcemap(userConfig, environmentName),
|
|
88129
88256
|
copyPublicDir: false,
|
|
@@ -88246,15 +88373,21 @@ function initRunners(resolvedPluginConfig, viteDevServer, miniflare) {
|
|
|
88246
88373
|
/** Emits Workers using the Build Output Specification after every environment has built. */
|
|
88247
88374
|
const buildOutputPlugin = createPlugin("build-output", (ctx) => {
|
|
88248
88375
|
const environmentNameToMainModule = /* @__PURE__ */ new Map();
|
|
88376
|
+
const environmentNameToImportedAssetPaths = /* @__PURE__ */ new Map();
|
|
88249
88377
|
return {
|
|
88250
88378
|
writeBundle(_options, bundle) {
|
|
88251
|
-
|
|
88379
|
+
const importedAssetPaths = ctx.getWorkerConfig(this.environment.name) ? /* @__PURE__ */ new Set() : void 0;
|
|
88380
|
+
if (importedAssetPaths) environmentNameToImportedAssetPaths.set(this.environment.name, importedAssetPaths);
|
|
88381
|
+
for (const output$1 of Object.values(bundle)) {
|
|
88382
|
+
if (importedAssetPaths) for (const assetPath of output$1.viteMetadata?.importedAssets ?? []) importedAssetPaths.add(assetPath);
|
|
88383
|
+
if (output$1.type === "chunk" && output$1.isEntry && output$1.name === MAIN_ENTRY_NAME) environmentNameToMainModule.set(this.environment.name, output$1.fileName);
|
|
88384
|
+
}
|
|
88252
88385
|
},
|
|
88253
88386
|
buildApp: {
|
|
88254
88387
|
order: "post",
|
|
88255
88388
|
async handler(builder) {
|
|
88256
88389
|
assertIsNotPreview(ctx);
|
|
88257
|
-
await
|
|
88390
|
+
await buildApp(builder, ctx.resolvedPluginConfig, environmentNameToImportedAssetPaths);
|
|
88258
88391
|
if (ctx.resolvedPluginConfig.type === "assets-only") await writeWorkerConfig({
|
|
88259
88392
|
root: builder.config.root,
|
|
88260
88393
|
config: ctx.resolvedPluginConfig.config
|
|
@@ -88272,15 +88405,6 @@ const buildOutputPlugin = createPlugin("build-output", (ctx) => {
|
|
|
88272
88405
|
}
|
|
88273
88406
|
}
|
|
88274
88407
|
};
|
|
88275
|
-
async function buildUnbuiltWorkerEnvironments(builder) {
|
|
88276
|
-
if (ctx.resolvedPluginConfig.type === "preview") return;
|
|
88277
|
-
const workerEnvironments = [...ctx.resolvedPluginConfig.environmentNameToWorkerMap.entries()].filter(([_, worker]) => !resolveDevOnly(worker.devOnly)).map(([environmentName]) => {
|
|
88278
|
-
const environment = builder.environments[environmentName];
|
|
88279
|
-
assert(environment, `"${environmentName}" environment not found`);
|
|
88280
|
-
return environment;
|
|
88281
|
-
});
|
|
88282
|
-
await Promise.all(workerEnvironments.filter((environment) => !environment.isBuilt).map((environment) => builder.build(environment)));
|
|
88283
|
-
}
|
|
88284
88408
|
async function writeWorkerConfig$1(builder, environmentName, workerDirectoryName) {
|
|
88285
88409
|
const workerConfig = ctx.getWorkerNewConfig(environmentName);
|
|
88286
88410
|
assert(workerConfig, `No config found for "${environmentName}" environment`);
|
|
@@ -88347,79 +88471,6 @@ const buildOutputPlugin = createPlugin("build-output", (ctx) => {
|
|
|
88347
88471
|
}
|
|
88348
88472
|
});
|
|
88349
88473
|
|
|
88350
|
-
//#endregion
|
|
88351
|
-
//#region src/build.ts
|
|
88352
|
-
var import_picocolors$4 = /* @__PURE__ */ __toESM$2(require_picocolors(), 1);
|
|
88353
|
-
const CLIENT_FALLBACK_ENTRY_NAME = "__cloudflare_fallback_entry__";
|
|
88354
|
-
function createBuildApp(resolvedPluginConfig) {
|
|
88355
|
-
return async (builder) => {
|
|
88356
|
-
const clientEnvironment = builder.environments.client;
|
|
88357
|
-
assert(clientEnvironment, `No "client" environment`);
|
|
88358
|
-
const defaultHtmlPath = path.resolve(builder.config.root, "index.html");
|
|
88359
|
-
const hasClientEntry = clientEnvironment.config.build.rollupOptions.input || fs$3.existsSync(defaultHtmlPath);
|
|
88360
|
-
const workerEnvironments = [...resolvedPluginConfig.environmentNameToWorkerMap.entries()].filter(([_, worker]) => !resolveDevOnly(worker.devOnly)).map(([environmentName]) => {
|
|
88361
|
-
const environment = builder.environments[environmentName];
|
|
88362
|
-
assert(environment, `"${environmentName}" environment not found`);
|
|
88363
|
-
return environment;
|
|
88364
|
-
});
|
|
88365
|
-
await Promise.all(workerEnvironments.map((environment) => builder.build(environment)));
|
|
88366
|
-
if (resolvedPluginConfig.type === "assets-only" || !workerEnvironments.some((environment) => environment.name === resolvedPluginConfig.entryWorkerEnvironmentName)) {
|
|
88367
|
-
if (hasClientEntry) await builder.build(clientEnvironment);
|
|
88368
|
-
else if (getHasPublicAssets(builder.config) || resolvedPluginConfig.prerenderWorkerEnvironmentName) await fallbackBuild(builder, clientEnvironment);
|
|
88369
|
-
return;
|
|
88370
|
-
}
|
|
88371
|
-
const { entryWorkerEnvironmentName } = resolvedPluginConfig;
|
|
88372
|
-
const entryWorkerEnvironment = builder.environments[entryWorkerEnvironmentName];
|
|
88373
|
-
assert(entryWorkerEnvironment, `No "${entryWorkerEnvironmentName}" environment`);
|
|
88374
|
-
const entryWorkerBuildDirectory = path.resolve(builder.config.root, entryWorkerEnvironment.config.build.outDir);
|
|
88375
|
-
const importedAssetPaths = getImportedAssetPaths(loadViteManifest(entryWorkerBuildDirectory));
|
|
88376
|
-
if (hasClientEntry) await builder.build(clientEnvironment);
|
|
88377
|
-
else if (importedAssetPaths.size || getHasPublicAssets(builder.config) || resolvedPluginConfig.prerenderWorkerEnvironmentName) await fallbackBuild(builder, clientEnvironment);
|
|
88378
|
-
else return;
|
|
88379
|
-
const clientBuildDirectory = path.resolve(builder.config.root, clientEnvironment.config.build.outDir);
|
|
88380
|
-
const movedAssetPaths = [];
|
|
88381
|
-
for (const assetPath of importedAssetPaths) {
|
|
88382
|
-
const src$1 = path.join(entryWorkerBuildDirectory, assetPath);
|
|
88383
|
-
const dest = path.join(clientBuildDirectory, assetPath);
|
|
88384
|
-
if (!fs$3.existsSync(src$1)) continue;
|
|
88385
|
-
if (fs$3.existsSync(dest)) fs$3.unlinkSync(src$1);
|
|
88386
|
-
else {
|
|
88387
|
-
const destDir = path.dirname(dest);
|
|
88388
|
-
fs$3.mkdirSync(destDir, { recursive: true });
|
|
88389
|
-
fs$3.renameSync(src$1, dest);
|
|
88390
|
-
movedAssetPaths.push(dest);
|
|
88391
|
-
}
|
|
88392
|
-
}
|
|
88393
|
-
if (movedAssetPaths.length) builder.config.logger.info([`${import_picocolors$4.default.green("✓")} ${movedAssetPaths.length} asset${movedAssetPaths.length > 1 ? "s" : ""} moved from "${entryWorkerEnvironmentName}" to "client" build output.`, ...movedAssetPaths.map((assetPath) => import_picocolors$4.default.dim(path.relative(builder.config.root, assetPath)))].join("\n"));
|
|
88394
|
-
};
|
|
88395
|
-
}
|
|
88396
|
-
function getHasPublicAssets({ publicDir }) {
|
|
88397
|
-
let hasPublicAssets = false;
|
|
88398
|
-
if (publicDir) try {
|
|
88399
|
-
if (fs$3.readdirSync(publicDir).length) hasPublicAssets = true;
|
|
88400
|
-
} catch {}
|
|
88401
|
-
return hasPublicAssets;
|
|
88402
|
-
}
|
|
88403
|
-
async function fallbackBuild(builder, environment) {
|
|
88404
|
-
environment.config.build.rollupOptions = {
|
|
88405
|
-
input: VIRTUAL_CLIENT_FALLBACK_ENTRY,
|
|
88406
|
-
logLevel: "silent",
|
|
88407
|
-
output: { entryFileNames: CLIENT_FALLBACK_ENTRY_NAME }
|
|
88408
|
-
};
|
|
88409
|
-
await builder.build(environment);
|
|
88410
|
-
const fallbackEntryPath = path.resolve(builder.config.root, environment.config.build.outDir, CLIENT_FALLBACK_ENTRY_NAME);
|
|
88411
|
-
fs$3.unlinkSync(fallbackEntryPath);
|
|
88412
|
-
}
|
|
88413
|
-
/** Read the Vite manifest emitted for a completed environment build. */
|
|
88414
|
-
function loadViteManifest(directory) {
|
|
88415
|
-
const contents = fs$3.readFileSync(path.resolve(directory, ".vite", "manifest.json"), "utf-8");
|
|
88416
|
-
return JSON.parse(contents);
|
|
88417
|
-
}
|
|
88418
|
-
function getImportedAssetPaths(viteManifest) {
|
|
88419
|
-
const assetPaths = Object.values(viteManifest).flatMap((chunk) => chunk.assets ?? []);
|
|
88420
|
-
return new Set(assetPaths);
|
|
88421
|
-
}
|
|
88422
|
-
|
|
88423
88474
|
//#endregion
|
|
88424
88475
|
//#region src/vite-config.ts
|
|
88425
88476
|
const NODE_BUILTIN_SET = new Set([...builtinModules, ...builtinModules.filter((m) => !m.startsWith("node:")).map((m) => `node:${m}`)]);
|
|
@@ -88510,7 +88561,7 @@ const configPlugin = createPlugin("config", (ctx) => {
|
|
|
88510
88561
|
], ...Array.from(ctx.resolvedPluginConfig.configPaths, (configPath) => normalizePath(configPath))] }
|
|
88511
88562
|
},
|
|
88512
88563
|
environments: getEnvironmentsConfig(ctx, userConfig, env$3.mode),
|
|
88513
|
-
builder: {
|
|
88564
|
+
builder: {}
|
|
88514
88565
|
};
|
|
88515
88566
|
},
|
|
88516
88567
|
configEnvironment: {
|
|
@@ -88768,8 +88819,7 @@ async function prepareContainerImagesForVite(options) {
|
|
|
88768
88819
|
onContainerImagePreparationEnd: () => {},
|
|
88769
88820
|
logger: options.logger,
|
|
88770
88821
|
complianceConfig,
|
|
88771
|
-
|
|
88772
|
-
registryConfigureCommand: options.cliDisplayName === "cf" ? "cf containers registries create" : "wrangler containers registries configure"
|
|
88822
|
+
registryConfigureCommand: "cf containers registries create"
|
|
88773
88823
|
});
|
|
88774
88824
|
}
|
|
88775
88825
|
|
|
@@ -89594,7 +89644,7 @@ __name(createWorkerUploadForm, "createWorkerUploadForm");
|
|
|
89594
89644
|
//#endregion
|
|
89595
89645
|
//#region ../remote-bindings/dist/index.mjs
|
|
89596
89646
|
var import_undici = require_undici();
|
|
89597
|
-
var version$1 = "0.0.
|
|
89647
|
+
var version$1 = "0.0.63";
|
|
89598
89648
|
var NoDefaultValueProvided = class extends UserError {
|
|
89599
89649
|
constructor() {
|
|
89600
89650
|
super("This command cannot be run in a non-interactive context", { telemetryMessage: "remote bindings prompt default missing" });
|
|
@@ -91024,7 +91074,7 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
|
|
|
91024
91074
|
account_id: settings.accountId,
|
|
91025
91075
|
profileDir: resolvedViteConfig.root
|
|
91026
91076
|
}, preExistingRemoteProxySession ?? null, getRemoteBindingsAuth(resolvedViteConfig.root, settings.accountId, () => ctx.getCloudflareAuth(resolvedViteConfig.root, createLogger(viteDevServer.config.logger))), {
|
|
91027
|
-
cliDisplayName:
|
|
91077
|
+
cliDisplayName: CLI_DISPLAY_NAME,
|
|
91028
91078
|
logger: createRemoteBindingsLogger(viteDevServer.config.logger)
|
|
91029
91079
|
});
|
|
91030
91080
|
if (remoteProxySessionData) remoteProxySessionsDataMap.set(worker.config.name, remoteProxySessionData);
|
|
@@ -91197,7 +91247,7 @@ async function getPreviewMiniflareOptions(ctx, vitePreviewServer) {
|
|
|
91197
91247
|
account_id: resolvedPluginConfig.settings.accountId,
|
|
91198
91248
|
profileDir: resolvedViteConfig.root
|
|
91199
91249
|
}, preExistingRemoteProxySessionData ?? null, getRemoteBindingsAuth(resolvedViteConfig.root, resolvedPluginConfig.settings.accountId, () => ctx.getCloudflareAuth(resolvedViteConfig.root, createLogger(vitePreviewServer.config.logger))), {
|
|
91200
|
-
cliDisplayName:
|
|
91250
|
+
cliDisplayName: CLI_DISPLAY_NAME,
|
|
91201
91251
|
logger: createRemoteBindingsLogger(vitePreviewServer.config.logger)
|
|
91202
91252
|
});
|
|
91203
91253
|
if (remoteProxySessionData) remoteProxySessionsDataMap.set(workerConfig.name, remoteProxySessionData);
|
|
@@ -91254,26 +91304,6 @@ async function getPreviewMiniflareOptions(ctx, vitePreviewServer) {
|
|
|
91254
91304
|
containerOptions: containerPlansByWorkerName.size === 0 ? void 0 : containerOptions
|
|
91255
91305
|
};
|
|
91256
91306
|
}
|
|
91257
|
-
/**
|
|
91258
|
-
* Replaces authored Container names on Durable Object exports with workerd's
|
|
91259
|
-
* local Container runtime metadata.
|
|
91260
|
-
*
|
|
91261
|
-
* @param options - Worker exports and their planned local Container metadata.
|
|
91262
|
-
* @returns Exports accepted by Miniflare's native Worker config schema.
|
|
91263
|
-
*/
|
|
91264
|
-
function createMiniflareExports(options) {
|
|
91265
|
-
const workerExports = {};
|
|
91266
|
-
for (const [name, workerExport] of Object.entries(options.exports ?? {})) if (workerExport.type === "durable-object" && "storage" in workerExport) {
|
|
91267
|
-
const containerName = "container" in workerExport ? workerExport.container : void 0;
|
|
91268
|
-
const container = containerName === void 0 ? void 0 : options.containerRuntimeOptions?.get(name);
|
|
91269
|
-
assert(containerName === void 0 || container !== void 0, `Expected runtime options for Container-backed Durable Object export "${name}".`);
|
|
91270
|
-
workerExports[name] = {
|
|
91271
|
-
...workerExport,
|
|
91272
|
-
container
|
|
91273
|
-
};
|
|
91274
|
-
} else workerExports[name] = workerExport;
|
|
91275
|
-
return workerExports;
|
|
91276
|
-
}
|
|
91277
91307
|
function resolveLocalBindingsByWorkerName(workerConfigs, localEnv, devVars, remoteBindings, mode, logger$2) {
|
|
91278
91308
|
const resolvedLocalBindingsByWorkerName = /* @__PURE__ */ new Map();
|
|
91279
91309
|
for (const config$3 of workerConfigs) resolvedLocalBindingsByWorkerName.set(config$3.name, resolveLocalBindings(config$3.env, {
|
|
@@ -91514,8 +91544,7 @@ const devPlugin = createPlugin("dev", (ctx) => {
|
|
|
91514
91544
|
dockerPath,
|
|
91515
91545
|
containerOptions,
|
|
91516
91546
|
settings: ctx.resolvedPluginConfig.settings,
|
|
91517
|
-
logger: viteDevServer.config.logger
|
|
91518
|
-
cliDisplayName: ctx.resolvedPluginConfig.cliDisplayName
|
|
91547
|
+
logger: viteDevServer.config.logger
|
|
91519
91548
|
});
|
|
91520
91549
|
viteDevServer.config.logger.info(import_picocolors$2.default.dim(import_picocolors$2.default.yellow("\n⚡️ Containers successfully built. To rebuild your containers during development, restart the Vite dev server (r + enter).")));
|
|
91521
91550
|
}
|
|
@@ -91660,8 +91689,7 @@ const previewPlugin = createPlugin("preview", (ctx) => {
|
|
|
91660
91689
|
dockerPath: getDockerPath(),
|
|
91661
91690
|
containerOptions,
|
|
91662
91691
|
settings: ctx.resolvedPluginConfig.settings,
|
|
91663
|
-
logger: vitePreviewServer.config.logger
|
|
91664
|
-
cliDisplayName: ctx.resolvedPluginConfig.cliDisplayName
|
|
91692
|
+
logger: vitePreviewServer.config.logger
|
|
91665
91693
|
});
|
|
91666
91694
|
}
|
|
91667
91695
|
if (vitePreviewServer.httpServer) vitePreviewServer.httpServer.on("listening", () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudflare/vite-plugin",
|
|
3
|
-
"version": "2.0.0-beta.v.
|
|
3
|
+
"version": "2.0.0-beta.v.15",
|
|
4
4
|
"description": "Cloudflare plugin for Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"unenv": "2.0.0-rc.24",
|
|
44
44
|
"ws": "8.21.0",
|
|
45
|
-
"@cloudflare/build-output-utils": "0.9.
|
|
46
|
-
"@cloudflare/
|
|
45
|
+
"@cloudflare/build-output-utils": "0.9.13",
|
|
46
|
+
"@cloudflare/runtime-types": "0.1.26",
|
|
47
|
+
"@cloudflare/config": "0.32.0",
|
|
47
48
|
"@cloudflare/unenv-preset": "2.16.2",
|
|
48
|
-
"miniflare": "5.20261110.
|
|
49
|
-
"@cloudflare/runtime-types": "0.1.25"
|
|
49
|
+
"miniflare": "5.20261110.1-beta"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@cloudflare/workers-types": "^5.20261110.1",
|
|
@@ -69,14 +69,14 @@
|
|
|
69
69
|
"vite": "8.3.4",
|
|
70
70
|
"vite-legacy": "npm:vite@7.1.12",
|
|
71
71
|
"vitest": "5.0.4",
|
|
72
|
-
"@cloudflare/
|
|
73
|
-
"@cloudflare/
|
|
72
|
+
"@cloudflare/containers-shared": "0.26.0",
|
|
73
|
+
"@cloudflare/cli-shared-helpers": "0.3.7",
|
|
74
74
|
"@cloudflare/mock-npm-registry": "0.0.0",
|
|
75
|
-
"@cloudflare/remote-bindings": "0.0.
|
|
76
|
-
"@cloudflare/workers-auth": "0.18.
|
|
75
|
+
"@cloudflare/remote-bindings": "0.0.63",
|
|
76
|
+
"@cloudflare/workers-auth": "0.18.1",
|
|
77
77
|
"@cloudflare/workers-shared": "0.20.2",
|
|
78
|
-
"@cloudflare/workers-
|
|
79
|
-
"@cloudflare/workers-
|
|
78
|
+
"@cloudflare/workers-utils": "0.53.1",
|
|
79
|
+
"@cloudflare/workers-tsconfig": "0.0.0"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
82
|
"vite": "^7.0.0 || ^8.0.0"
|