@cloudflare/vite-plugin 1.15.3 → 1.16.1
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.d.mts +45 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +263 -192
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -8
package/dist/index.mjs
CHANGED
|
@@ -2,14 +2,15 @@ import { builtinModules } from "node:module";
|
|
|
2
2
|
import * as vite from "vite";
|
|
3
3
|
import assert from "node:assert";
|
|
4
4
|
import { CoreHeaders, Log, LogLevel, Miniflare, Request as Request$1, Response as Response$1, coupleWebSocket, getDefaultDevRegistryPath, getNodeCompat, kUnsafeEphemeralUniqueKey } from "miniflare";
|
|
5
|
-
import { maybeStartOrUpdateRemoteProxySession, unstable_convertConfigBindingsToStartWorkerBindings, unstable_getDurableObjectClassNameToUseSQLiteMap, unstable_getMiniflareWorkerOptions, unstable_getVarsForDev, unstable_readConfig } from "wrangler";
|
|
6
|
-
import * as path$
|
|
5
|
+
import { maybeStartOrUpdateRemoteProxySession, unstable_convertConfigBindingsToStartWorkerBindings, unstable_defaultWranglerConfig, unstable_getDevCompatibilityDate, unstable_getDurableObjectClassNameToUseSQLiteMap, unstable_getMiniflareWorkerOptions, unstable_getVarsForDev, unstable_getWorkerNameFromProject, unstable_readConfig } from "wrangler";
|
|
6
|
+
import * as path$1 from "node:path";
|
|
7
7
|
import path, { relative } from "node:path";
|
|
8
8
|
import * as util$1 from "node:util";
|
|
9
9
|
import { format, inspect } from "node:util";
|
|
10
10
|
import { createHeaders, createRequest, sendResponse } from "@remix-run/node-fetch-server";
|
|
11
|
+
import { defu } from "defu";
|
|
11
12
|
import * as fs$1 from "node:fs";
|
|
12
|
-
import fs, { readFileSync, realpathSync, statSync } from "node:fs";
|
|
13
|
+
import fs, { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
13
14
|
import { getCloudflarePreset } from "@cloudflare/unenv-preset";
|
|
14
15
|
import { URL as URL$1, fileURLToPath, pathToFileURL } from "node:url";
|
|
15
16
|
import process$1 from "node:process";
|
|
@@ -18,11 +19,8 @@ import { defineEnv } from "unenv";
|
|
|
18
19
|
import * as fsp from "node:fs/promises";
|
|
19
20
|
import colors from "picocolors";
|
|
20
21
|
import getPort, { portNumbers } from "get-port";
|
|
21
|
-
import { execFileSync, spawn } from "child_process";
|
|
22
|
-
import {
|
|
23
|
-
import { spawn as spawn$1 } from "node:child_process";
|
|
24
|
-
import { randomUUID } from "crypto";
|
|
25
|
-
import path$1 from "path";
|
|
22
|
+
import { execFileSync, spawn } from "node:child_process";
|
|
23
|
+
import { randomUUID } from "node:crypto";
|
|
26
24
|
import { globSync } from "tinyglobby";
|
|
27
25
|
import { WebSocketServer } from "ws";
|
|
28
26
|
|
|
@@ -69,14 +67,14 @@ function createPlugin(name, pluginFactory) {
|
|
|
69
67
|
}
|
|
70
68
|
function getOutputDirectory(userConfig, environmentName) {
|
|
71
69
|
const rootOutputDirectory = userConfig.build?.outDir ?? "dist";
|
|
72
|
-
return userConfig.environments?.[environmentName]?.build?.outDir ?? path$
|
|
70
|
+
return userConfig.environments?.[environmentName]?.build?.outDir ?? path$1.join(rootOutputDirectory, environmentName);
|
|
73
71
|
}
|
|
74
72
|
const postfixRE = /[?#].*$/;
|
|
75
73
|
function cleanUrl(url) {
|
|
76
74
|
return url.replace(postfixRE, "");
|
|
77
75
|
}
|
|
78
|
-
function withTrailingSlash(path$
|
|
79
|
-
return path$
|
|
76
|
+
function withTrailingSlash(path$2) {
|
|
77
|
+
return path$2.endsWith("/") ? path$2 : `${path$2}/`;
|
|
80
78
|
}
|
|
81
79
|
function createRequestHandler(handler) {
|
|
82
80
|
return async (req, res, next) => {
|
|
@@ -358,21 +356,21 @@ const formatInvalidRoutes = (invalidRules) => {
|
|
|
358
356
|
//#endregion
|
|
359
357
|
//#region src/deploy-config.ts
|
|
360
358
|
function getDeployConfigPath(root) {
|
|
361
|
-
return path$
|
|
359
|
+
return path$1.resolve(root, ".wrangler", "deploy", "config.json");
|
|
362
360
|
}
|
|
363
361
|
function getWorkerConfigs(root) {
|
|
364
362
|
const deployConfigPath = getDeployConfigPath(root);
|
|
365
363
|
const deployConfig = JSON.parse(fs$1.readFileSync(deployConfigPath, "utf-8"));
|
|
366
364
|
return [{ configPath: deployConfig.configPath }, ...deployConfig.auxiliaryWorkers].map(({ configPath }) => {
|
|
367
|
-
return unstable_readConfig({ config: path$
|
|
365
|
+
return unstable_readConfig({ config: path$1.resolve(path$1.dirname(deployConfigPath), configPath) });
|
|
368
366
|
});
|
|
369
367
|
}
|
|
370
368
|
function getRelativePathToWorkerConfig(deployConfigDirectory, root, outputDirectory) {
|
|
371
|
-
return path$
|
|
369
|
+
return path$1.relative(deployConfigDirectory, path$1.resolve(root, outputDirectory, "wrangler.json"));
|
|
372
370
|
}
|
|
373
371
|
function writeDeployConfig(resolvedPluginConfig, resolvedViteConfig) {
|
|
374
372
|
const deployConfigPath = getDeployConfigPath(resolvedViteConfig.root);
|
|
375
|
-
const deployConfigDirectory = path$
|
|
373
|
+
const deployConfigDirectory = path$1.dirname(deployConfigPath);
|
|
376
374
|
fs$1.mkdirSync(deployConfigDirectory, { recursive: true });
|
|
377
375
|
if (resolvedPluginConfig.type === "assets-only") {
|
|
378
376
|
const clientOutputDirectory = resolvedViteConfig.environments.client?.build.outDir;
|
|
@@ -5388,15 +5386,15 @@ function hasTrailingSlash(input = "", respectQueryAndFragment) {
|
|
|
5388
5386
|
function withTrailingSlash$1(input = "", respectQueryAndFragment) {
|
|
5389
5387
|
if (!respectQueryAndFragment) return input.endsWith("/") ? input : input + "/";
|
|
5390
5388
|
if (hasTrailingSlash(input, true)) return input || "/";
|
|
5391
|
-
let path$
|
|
5389
|
+
let path$2 = input;
|
|
5392
5390
|
let fragment = "";
|
|
5393
5391
|
const fragmentIndex = input.indexOf("#");
|
|
5394
5392
|
if (fragmentIndex >= 0) {
|
|
5395
|
-
path$
|
|
5393
|
+
path$2 = input.slice(0, fragmentIndex);
|
|
5396
5394
|
fragment = input.slice(fragmentIndex);
|
|
5397
|
-
if (!path$
|
|
5395
|
+
if (!path$2) return fragment;
|
|
5398
5396
|
}
|
|
5399
|
-
const [s0, ...s] = path$
|
|
5397
|
+
const [s0, ...s] = path$2.split("?");
|
|
5400
5398
|
return s0 + "/" + (s.length > 0 ? `?${s.join("?")}` : "") + fragment;
|
|
5401
5399
|
}
|
|
5402
5400
|
function isNonEmptyURL(url) {
|
|
@@ -5422,8 +5420,8 @@ const isAbsolute = function(p) {
|
|
|
5422
5420
|
//#endregion
|
|
5423
5421
|
//#region ../../node_modules/.pnpm/mlly@1.7.4/node_modules/mlly/dist/index.mjs
|
|
5424
5422
|
const BUILTIN_MODULES = new Set(builtinModules);
|
|
5425
|
-
function normalizeSlash(path$
|
|
5426
|
-
return path$
|
|
5423
|
+
function normalizeSlash(path$2) {
|
|
5424
|
+
return path$2.replace(/\\/g, "/");
|
|
5427
5425
|
}
|
|
5428
5426
|
/**
|
|
5429
5427
|
* @typedef ErrnoExceptionFields
|
|
@@ -5543,8 +5541,8 @@ codes.ERR_INVALID_PACKAGE_CONFIG = createError(
|
|
|
5543
5541
|
* @param {string} [base]
|
|
5544
5542
|
* @param {string} [message]
|
|
5545
5543
|
*/
|
|
5546
|
-
(path$
|
|
5547
|
-
return `Invalid package config ${path$
|
|
5544
|
+
(path$2, base, message) => {
|
|
5545
|
+
return `Invalid package config ${path$2}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
|
|
5548
5546
|
},
|
|
5549
5547
|
Error
|
|
5550
5548
|
);
|
|
@@ -5574,8 +5572,8 @@ codes.ERR_MODULE_NOT_FOUND = createError(
|
|
|
5574
5572
|
* @param {string} base
|
|
5575
5573
|
* @param {boolean} [exactUrl]
|
|
5576
5574
|
*/
|
|
5577
|
-
(path$
|
|
5578
|
-
return `Cannot find ${exactUrl ? "module" : "package"} '${path$
|
|
5575
|
+
(path$2, base, exactUrl = false) => {
|
|
5576
|
+
return `Cannot find ${exactUrl ? "module" : "package"} '${path$2}' imported from ${base}`;
|
|
5579
5577
|
},
|
|
5580
5578
|
Error
|
|
5581
5579
|
);
|
|
@@ -5613,8 +5611,8 @@ codes.ERR_UNKNOWN_FILE_EXTENSION = createError(
|
|
|
5613
5611
|
* @param {string} extension
|
|
5614
5612
|
* @param {string} path
|
|
5615
5613
|
*/
|
|
5616
|
-
(extension, path$
|
|
5617
|
-
return `Unknown file extension "${extension}" for ${path$
|
|
5614
|
+
(extension, path$2) => {
|
|
5615
|
+
return `Unknown file extension "${extension}" for ${path$2}`;
|
|
5618
5616
|
},
|
|
5619
5617
|
TypeError
|
|
5620
5618
|
);
|
|
@@ -5983,9 +5981,9 @@ function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
|
|
|
5983
5981
|
* @param {string} path
|
|
5984
5982
|
* @returns {Stats | undefined}
|
|
5985
5983
|
*/
|
|
5986
|
-
function tryStatSync(path$
|
|
5984
|
+
function tryStatSync(path$2) {
|
|
5987
5985
|
try {
|
|
5988
|
-
return statSync(path$
|
|
5986
|
+
return statSync(path$2);
|
|
5989
5987
|
} catch {}
|
|
5990
5988
|
}
|
|
5991
5989
|
/**
|
|
@@ -6716,8 +6714,8 @@ function hasNodeJsAls(workerConfig) {
|
|
|
6716
6714
|
*/
|
|
6717
6715
|
const nodeJsBuiltins = new Set([...builtinModules, ...builtinModules.map((m) => `node:${m}`)]);
|
|
6718
6716
|
const NODEJS_MODULES_RE = /* @__PURE__ */ new RegExp(`^(node:)?(${builtinModules.join("|")})$`);
|
|
6719
|
-
function isNodeAlsModule(path$
|
|
6720
|
-
return /^(node:)?async_hooks$/.test(path$
|
|
6717
|
+
function isNodeAlsModule(path$2) {
|
|
6718
|
+
return /^(node:)?async_hooks$/.test(path$2);
|
|
6721
6719
|
}
|
|
6722
6720
|
function assertHasNodeJsCompat(nodeJsCompat) {
|
|
6723
6721
|
assert(nodeJsCompat, `expected nodeJsCompat to be defined`);
|
|
@@ -6748,7 +6746,7 @@ var NodeJsCompatWarnings = class {
|
|
|
6748
6746
|
`;
|
|
6749
6747
|
this.sources.forEach((importers, source) => {
|
|
6750
6748
|
importers.forEach((importer) => {
|
|
6751
|
-
message += ` - "${source}" imported from "${path$
|
|
6749
|
+
message += ` - "${source}" imported from "${path$1.relative(this.resolvedViteConfig.root, importer)}"\n`;
|
|
6752
6750
|
});
|
|
6753
6751
|
});
|
|
6754
6752
|
this.resolvedViteConfig.logger.warn(message, { timestamp: true });
|
|
@@ -6833,7 +6831,7 @@ function getWarningForWorkersConfigs(configs) {
|
|
|
6833
6831
|
if (!("auxiliaryWorkers" in configs) || configs.auxiliaryWorkers.length === 0) {
|
|
6834
6832
|
const nonApplicableLines = getWorkerNonApplicableWarnLines(configs.entryWorker, ` - `);
|
|
6835
6833
|
if (nonApplicableLines.length === 0) return;
|
|
6836
|
-
const lines$1 = [`\n\n\x1b[43mWARNING\x1b[0m: your worker config${configs.entryWorker.config.configPath ? ` (at \`${path$
|
|
6834
|
+
const lines$1 = [`\n\n\x1b[43mWARNING\x1b[0m: your worker config${configs.entryWorker.config.configPath ? ` (at \`${path$1.relative("", configs.entryWorker.config.configPath)}\`)` : ""} contains the following configuration options which are ignored since they are not applicable when using Vite:`];
|
|
6837
6835
|
nonApplicableLines.forEach((line) => lines$1.push(line));
|
|
6838
6836
|
lines$1.push("");
|
|
6839
6837
|
return lines$1.join("\n");
|
|
@@ -6842,7 +6840,7 @@ function getWarningForWorkersConfigs(configs) {
|
|
|
6842
6840
|
const processWorkerConfig = (workerConfig, isEntryWorker = false) => {
|
|
6843
6841
|
const nonApplicableLines = getWorkerNonApplicableWarnLines(workerConfig, ` - `);
|
|
6844
6842
|
if (nonApplicableLines.length > 0) {
|
|
6845
|
-
lines.push(` - (${isEntryWorker ? "entry" : "auxiliary"}) worker${workerConfig.config.name ? ` "${workerConfig.config.name}"` : ""}${workerConfig.config.configPath ? ` (config at \`${path$
|
|
6843
|
+
lines.push(` - (${isEntryWorker ? "entry" : "auxiliary"}) worker${workerConfig.config.name ? ` "${workerConfig.config.name}"` : ""}${workerConfig.config.configPath ? ` (config at \`${path$1.relative("", workerConfig.config.configPath)}\`)` : ""}`);
|
|
6846
6844
|
nonApplicableLines.forEach((line) => lines.push(line));
|
|
6847
6845
|
}
|
|
6848
6846
|
};
|
|
@@ -6869,15 +6867,30 @@ function isNotRelevant(configName) {
|
|
|
6869
6867
|
return nonApplicableWorkerConfigs.notRelevant.includes(configName);
|
|
6870
6868
|
}
|
|
6871
6869
|
function missingFieldErrorMessage(field, configPath, env) {
|
|
6872
|
-
return `No ${field} field provided in '${configPath}'${env ? ` for '${env}' environment` : ""}`;
|
|
6870
|
+
return `No '${field}' field provided${configPath ? ` in '${configPath}'` : ""}${env ? ` for '${env}' environment` : ""}`;
|
|
6873
6871
|
}
|
|
6874
|
-
|
|
6872
|
+
/**
|
|
6873
|
+
* Reads and sanitizes a worker config from a wrangler config file.
|
|
6874
|
+
*/
|
|
6875
|
+
function readWorkerConfigFromFile(configPath, env, opts) {
|
|
6875
6876
|
if (opts?.visitedConfigPaths?.has(configPath)) throw new Error(`Duplicate Wrangler config path found: ${configPath}`);
|
|
6876
|
-
const
|
|
6877
|
+
const result = readWorkerConfig(configPath, env);
|
|
6877
6878
|
opts?.visitedConfigPaths?.add(configPath);
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
|
|
6879
|
+
return result;
|
|
6880
|
+
}
|
|
6881
|
+
/**
|
|
6882
|
+
* Validates required fields and determines whether the config represents
|
|
6883
|
+
* an assets-only worker or a worker with server logic.
|
|
6884
|
+
*
|
|
6885
|
+
* @param config The sanitized worker config (after merging defaults, file config, and config())
|
|
6886
|
+
* @param raw The raw config (before sanitization)
|
|
6887
|
+
* @param nonApplicable The non-applicable config map
|
|
6888
|
+
* @param opts Options for validation
|
|
6889
|
+
*/
|
|
6890
|
+
function resolveWorkerType(config, raw, nonApplicable, opts) {
|
|
6891
|
+
if (!config.name) throw new Error(missingFieldErrorMessage("name", opts?.configPath, opts?.env));
|
|
6892
|
+
if (!config.topLevelName) throw new Error(missingFieldErrorMessage("top-level name", opts?.configPath, opts?.env));
|
|
6893
|
+
if (!config.compatibility_date) throw new Error(missingFieldErrorMessage("compatibility_date", opts?.configPath, opts?.env));
|
|
6881
6894
|
const requiredFields = {
|
|
6882
6895
|
topLevelName: config.topLevelName,
|
|
6883
6896
|
name: config.name,
|
|
@@ -6892,14 +6905,15 @@ function getWorkerConfig(configPath, env, opts) {
|
|
|
6892
6905
|
},
|
|
6893
6906
|
nonApplicable
|
|
6894
6907
|
};
|
|
6895
|
-
if (!config.main) throw new Error(missingFieldErrorMessage(
|
|
6908
|
+
if (!config.main) throw new Error(missingFieldErrorMessage("main", opts?.configPath, opts?.env));
|
|
6909
|
+
const resolvedMain = maybeResolveMain(config.main, opts?.configPath, opts?.root);
|
|
6896
6910
|
return {
|
|
6897
6911
|
type: "worker",
|
|
6898
6912
|
raw,
|
|
6899
6913
|
config: {
|
|
6900
6914
|
...config,
|
|
6901
6915
|
...requiredFields,
|
|
6902
|
-
main:
|
|
6916
|
+
main: resolvedMain
|
|
6903
6917
|
},
|
|
6904
6918
|
nonApplicable
|
|
6905
6919
|
};
|
|
@@ -6917,9 +6931,11 @@ const ENTRY_MODULE_EXTENSIONS = [
|
|
|
6917
6931
|
* Else `main` is returned as is so that it can be resolved by Vite.
|
|
6918
6932
|
* This enables resolving entry modules relative to the Worker config while also supporting virtual modules and package exports.
|
|
6919
6933
|
*/
|
|
6920
|
-
function maybeResolveMain(main, configPath) {
|
|
6934
|
+
function maybeResolveMain(main, configPath, root) {
|
|
6921
6935
|
if (!ENTRY_MODULE_EXTENSIONS.some((extension) => main.endsWith(extension))) return main;
|
|
6922
|
-
const
|
|
6936
|
+
const baseDir = configPath ? path$1.dirname(configPath) : root;
|
|
6937
|
+
if (!baseDir) return main;
|
|
6938
|
+
const resolvedMain = path$1.resolve(baseDir, main);
|
|
6923
6939
|
if (!fs$1.existsSync(resolvedMain)) throw new Error(`The provided Wrangler config main field (${resolvedMain}) doesn't point to an existing file`);
|
|
6924
6940
|
return resolvedMain;
|
|
6925
6941
|
}
|
|
@@ -6930,30 +6946,28 @@ function maybeResolveMain(main, configPath) {
|
|
|
6930
6946
|
* @param root the root of the vite project
|
|
6931
6947
|
* @param requestedConfigPath the requested config path, if any
|
|
6932
6948
|
* @param isForAuxiliaryWorker whether the config path is being requested for an auxiliary worker
|
|
6933
|
-
* @returns a valid path to a config file
|
|
6949
|
+
* @returns a valid path to a config file, or undefined for entry workers when no config is found
|
|
6934
6950
|
*/
|
|
6935
6951
|
function getValidatedWranglerConfigPath(root, requestedConfigPath, isForAuxiliaryWorker = false) {
|
|
6936
6952
|
if (requestedConfigPath) {
|
|
6937
|
-
const configPath
|
|
6938
|
-
const errorMessagePrefix = `The provided configPath (${configPath
|
|
6939
|
-
const fileExtension = path$
|
|
6953
|
+
const configPath = path$1.resolve(root, requestedConfigPath);
|
|
6954
|
+
const errorMessagePrefix = `The provided configPath (${configPath})${isForAuxiliaryWorker ? " requested for one of your auxiliary workers" : ""}`;
|
|
6955
|
+
const fileExtension = path$1.extname(configPath).slice(1);
|
|
6940
6956
|
if (!allowedWranglerConfigExtensions.includes(fileExtension)) {
|
|
6941
6957
|
const foundExtensionMessage = !fileExtension ? "no extension found" : `"${fileExtension}" found`;
|
|
6942
6958
|
throw new Error(`${errorMessagePrefix} doesn't point to a file with the correct file extension. It should point to a jsonc, json or toml file (${foundExtensionMessage} instead)`);
|
|
6943
6959
|
}
|
|
6944
|
-
const mainStat = fs$1.statSync(configPath
|
|
6960
|
+
const mainStat = fs$1.statSync(configPath, { throwIfNoEntry: false });
|
|
6945
6961
|
if (!mainStat) throw new Error(`${errorMessagePrefix} doesn't point to an existing file`);
|
|
6946
6962
|
if (mainStat.isDirectory()) throw new Error(`${errorMessagePrefix} points to a directory. It should point to a file.`);
|
|
6947
|
-
return configPath
|
|
6963
|
+
return configPath;
|
|
6948
6964
|
}
|
|
6949
|
-
|
|
6950
|
-
|
|
6951
|
-
if (!configPath) throw new Error(`No config file found in the ${root} directory. Please add a wrangler.(jsonc|json|toml) file.`);
|
|
6952
|
-
return configPath;
|
|
6965
|
+
if (isForAuxiliaryWorker) return;
|
|
6966
|
+
return findWranglerConfig(root);
|
|
6953
6967
|
}
|
|
6954
6968
|
function findWranglerConfig(root) {
|
|
6955
6969
|
for (const extension of allowedWranglerConfigExtensions) {
|
|
6956
|
-
const configPath = path$
|
|
6970
|
+
const configPath = path$1.join(root, `wrangler.${extension}`);
|
|
6957
6971
|
if (fs$1.existsSync(configPath)) return configPath;
|
|
6958
6972
|
}
|
|
6959
6973
|
}
|
|
@@ -6965,13 +6979,45 @@ const allowedWranglerConfigExtensions = [
|
|
|
6965
6979
|
|
|
6966
6980
|
//#endregion
|
|
6967
6981
|
//#region src/plugin-config.ts
|
|
6982
|
+
function customizeWorkerConfig(resolvedConfig, config) {
|
|
6983
|
+
const configResult = typeof config === "function" ? config(resolvedConfig) : config;
|
|
6984
|
+
if (configResult) return defu(configResult, resolvedConfig);
|
|
6985
|
+
return resolvedConfig;
|
|
6986
|
+
}
|
|
6987
|
+
/**
|
|
6988
|
+
* Resolves the config for a single worker, applying defaults, file config, and config().
|
|
6989
|
+
*/
|
|
6990
|
+
function resolveWorkerConfig({ configPath, env, config, visitedConfigPaths, isEntryWorker, root }) {
|
|
6991
|
+
let workerConfig;
|
|
6992
|
+
let raw;
|
|
6993
|
+
let nonApplicable;
|
|
6994
|
+
if (configPath) ({raw, config: workerConfig, nonApplicable} = readWorkerConfigFromFile(configPath, env, { visitedConfigPaths }));
|
|
6995
|
+
else {
|
|
6996
|
+
workerConfig = { ...unstable_defaultWranglerConfig };
|
|
6997
|
+
raw = structuredClone(workerConfig);
|
|
6998
|
+
nonApplicable = {
|
|
6999
|
+
replacedByVite: /* @__PURE__ */ new Set(),
|
|
7000
|
+
notRelevant: /* @__PURE__ */ new Set()
|
|
7001
|
+
};
|
|
7002
|
+
}
|
|
7003
|
+
workerConfig = customizeWorkerConfig(workerConfig, config);
|
|
7004
|
+
workerConfig.compatibility_date ??= unstable_getDevCompatibilityDate(void 0);
|
|
7005
|
+
if (isEntryWorker) workerConfig.name ??= unstable_getWorkerNameFromProject(root);
|
|
7006
|
+
workerConfig.topLevelName ??= workerConfig.name;
|
|
7007
|
+
return resolveWorkerType(workerConfig, raw, nonApplicable, {
|
|
7008
|
+
isEntryWorker,
|
|
7009
|
+
configPath,
|
|
7010
|
+
root,
|
|
7011
|
+
env
|
|
7012
|
+
});
|
|
7013
|
+
}
|
|
6968
7014
|
function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
6969
7015
|
const shared = {
|
|
6970
7016
|
persistState: pluginConfig.persistState ?? true,
|
|
6971
7017
|
inspectorPort: pluginConfig.inspectorPort,
|
|
6972
7018
|
experimental: pluginConfig.experimental ?? {}
|
|
6973
7019
|
};
|
|
6974
|
-
const root = userConfig.root ? path$
|
|
7020
|
+
const root = userConfig.root ? path$1.resolve(userConfig.root) : process.cwd();
|
|
6975
7021
|
const prefixedEnv = vite.loadEnv(viteEnv.mode, root, ["CLOUDFLARE_", "WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_"]);
|
|
6976
7022
|
Object.assign(process.env, prefixedEnv);
|
|
6977
7023
|
if (viteEnv.isPreview) return {
|
|
@@ -6982,7 +7028,11 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
6982
7028
|
};
|
|
6983
7029
|
const configPaths = /* @__PURE__ */ new Set();
|
|
6984
7030
|
const cloudflareEnv = prefixedEnv.CLOUDFLARE_ENV;
|
|
6985
|
-
const entryWorkerResolvedConfig =
|
|
7031
|
+
const entryWorkerResolvedConfig = resolveWorkerConfig({
|
|
7032
|
+
root,
|
|
7033
|
+
configPath: getValidatedWranglerConfigPath(root, pluginConfig.configPath),
|
|
7034
|
+
env: prefixedEnv.CLOUDFLARE_ENV,
|
|
7035
|
+
config: pluginConfig.config,
|
|
6986
7036
|
visitedConfigPaths: configPaths,
|
|
6987
7037
|
isEntryWorker: true
|
|
6988
7038
|
});
|
|
@@ -7002,13 +7052,18 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
7002
7052
|
const environmentNameToWorkerMap = new Map([[entryWorkerEnvironmentName, resolveWorker(entryWorkerConfig)]]);
|
|
7003
7053
|
const auxiliaryWorkersResolvedConfigs = [];
|
|
7004
7054
|
for (const auxiliaryWorker of pluginConfig.auxiliaryWorkers ?? []) {
|
|
7005
|
-
const workerResolvedConfig =
|
|
7055
|
+
const workerResolvedConfig = resolveWorkerConfig({
|
|
7056
|
+
root,
|
|
7057
|
+
configPath: getValidatedWranglerConfigPath(root, auxiliaryWorker.configPath, true),
|
|
7058
|
+
env: cloudflareEnv,
|
|
7059
|
+
config: "config" in auxiliaryWorker ? auxiliaryWorker.config : void 0,
|
|
7060
|
+
visitedConfigPaths: configPaths,
|
|
7061
|
+
isEntryWorker: false
|
|
7062
|
+
});
|
|
7006
7063
|
auxiliaryWorkersResolvedConfigs.push(workerResolvedConfig);
|
|
7007
|
-
|
|
7008
|
-
const workerConfig = workerResolvedConfig.config;
|
|
7009
|
-
const workerEnvironmentName = auxiliaryWorker.viteEnvironment?.name ?? workerNameToEnvironmentName(workerConfig.topLevelName);
|
|
7064
|
+
const workerEnvironmentName = auxiliaryWorker.viteEnvironment?.name ?? workerNameToEnvironmentName(workerResolvedConfig.config.topLevelName);
|
|
7010
7065
|
if (environmentNameToWorkerMap.has(workerEnvironmentName)) throw new Error(`Duplicate Vite environment name found: ${workerEnvironmentName}`);
|
|
7011
|
-
environmentNameToWorkerMap.set(workerEnvironmentName, resolveWorker(
|
|
7066
|
+
environmentNameToWorkerMap.set(workerEnvironmentName, resolveWorker(workerResolvedConfig.config));
|
|
7012
7067
|
}
|
|
7013
7068
|
return {
|
|
7014
7069
|
...shared,
|
|
@@ -8079,12 +8134,12 @@ const additionalModulesPlugin = createPlugin("additional-modules", (ctx) => {
|
|
|
8079
8134
|
}
|
|
8080
8135
|
const referenceId = this.emitFile({
|
|
8081
8136
|
type: "asset",
|
|
8082
|
-
name: path$
|
|
8137
|
+
name: path$1.basename(modulePath),
|
|
8083
8138
|
originalFileName: modulePath,
|
|
8084
8139
|
source
|
|
8085
8140
|
});
|
|
8086
8141
|
const emittedFileName = this.getFileName(referenceId);
|
|
8087
|
-
const relativePath = vite.normalizePath(path$
|
|
8142
|
+
const relativePath = vite.normalizePath(path$1.relative(path$1.dirname(chunk.fileName), emittedFileName));
|
|
8088
8143
|
const importPath = relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
8089
8144
|
magicString.update(match.index, match.index + full.length, importPath);
|
|
8090
8145
|
}
|
|
@@ -8195,9 +8250,9 @@ function constructHeaders({ headers, headersFile, logger }) {
|
|
|
8195
8250
|
|
|
8196
8251
|
//#endregion
|
|
8197
8252
|
//#region ../workers-shared/utils/configuration/validateURL.ts
|
|
8198
|
-
const extractPathname = (path$
|
|
8199
|
-
if (!path$
|
|
8200
|
-
const url = new URL(`//${path$
|
|
8253
|
+
const extractPathname = (path$2 = "/", includeSearch, includeHash) => {
|
|
8254
|
+
if (!path$2.startsWith("/")) path$2 = `/${path$2}`;
|
|
8255
|
+
const url = new URL(`//${path$2}`, "relative://");
|
|
8201
8256
|
return `${url.pathname}${includeSearch ? url.search : ""}${includeHash ? url.hash : ""}`;
|
|
8202
8257
|
};
|
|
8203
8258
|
const URL_REGEX = /^https:\/\/+(?<host>[^/]+)\/?(?<path>.*)/;
|
|
@@ -8254,7 +8309,7 @@ function parseHeaders(input, { maxRules = MAX_HEADER_RULES, maxLineLength = MAX_
|
|
|
8254
8309
|
lineNumber: i$1 + 1,
|
|
8255
8310
|
message: "No headers specified"
|
|
8256
8311
|
});
|
|
8257
|
-
const [path$
|
|
8312
|
+
const [path$2, pathError] = validateUrl(line, false, true);
|
|
8258
8313
|
if (pathError) {
|
|
8259
8314
|
invalid.push({
|
|
8260
8315
|
line,
|
|
@@ -8265,7 +8320,7 @@ function parseHeaders(input, { maxRules = MAX_HEADER_RULES, maxLineLength = MAX_
|
|
|
8265
8320
|
continue;
|
|
8266
8321
|
}
|
|
8267
8322
|
rule = {
|
|
8268
|
-
path: path$
|
|
8323
|
+
path: path$2,
|
|
8269
8324
|
line,
|
|
8270
8325
|
headers: {},
|
|
8271
8326
|
unsetHeaders: []
|
|
@@ -8553,13 +8608,13 @@ var require_ignore = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/igno
|
|
|
8553
8608
|
const throwError = (message, Ctor) => {
|
|
8554
8609
|
throw new Ctor(message);
|
|
8555
8610
|
};
|
|
8556
|
-
const checkPath = (path$
|
|
8557
|
-
if (!isString$1(path$
|
|
8558
|
-
if (!path$
|
|
8559
|
-
if (checkPath.isNotRelative(path$
|
|
8611
|
+
const checkPath = (path$2, originalPath, doThrow) => {
|
|
8612
|
+
if (!isString$1(path$2)) return doThrow(`path must be a string, but got \`${originalPath}\``, TypeError);
|
|
8613
|
+
if (!path$2) return doThrow(`path must not be empty`, TypeError);
|
|
8614
|
+
if (checkPath.isNotRelative(path$2)) return doThrow(`path should be a \`path.relative()\`d string, but got "${originalPath}"`, RangeError);
|
|
8560
8615
|
return true;
|
|
8561
8616
|
};
|
|
8562
|
-
const isNotRelative = (path$
|
|
8617
|
+
const isNotRelative = (path$2) => REGEX_TEST_INVALID_PATH.test(path$2);
|
|
8563
8618
|
checkPath.isNotRelative = isNotRelative;
|
|
8564
8619
|
checkPath.convert = (p) => p;
|
|
8565
8620
|
var Ignore = class {
|
|
@@ -8595,13 +8650,13 @@ var require_ignore = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/igno
|
|
|
8595
8650
|
addPattern(pattern) {
|
|
8596
8651
|
return this.add(pattern);
|
|
8597
8652
|
}
|
|
8598
|
-
_testOne(path$
|
|
8653
|
+
_testOne(path$2, checkUnignored) {
|
|
8599
8654
|
let ignored = false;
|
|
8600
8655
|
let unignored = false;
|
|
8601
8656
|
this._rules.forEach((rule) => {
|
|
8602
8657
|
const { negative } = rule;
|
|
8603
8658
|
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) return;
|
|
8604
|
-
if (rule.regex.test(path$
|
|
8659
|
+
if (rule.regex.test(path$2)) {
|
|
8605
8660
|
ignored = !negative;
|
|
8606
8661
|
unignored = negative;
|
|
8607
8662
|
}
|
|
@@ -8612,33 +8667,33 @@ var require_ignore = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/igno
|
|
|
8612
8667
|
};
|
|
8613
8668
|
}
|
|
8614
8669
|
_test(originalPath, cache$1, checkUnignored, slices) {
|
|
8615
|
-
const path$
|
|
8616
|
-
checkPath(path$
|
|
8617
|
-
return this._t(path$
|
|
8670
|
+
const path$2 = originalPath && checkPath.convert(originalPath);
|
|
8671
|
+
checkPath(path$2, originalPath, this._allowRelativePaths ? RETURN_FALSE : throwError);
|
|
8672
|
+
return this._t(path$2, cache$1, checkUnignored, slices);
|
|
8618
8673
|
}
|
|
8619
|
-
_t(path$
|
|
8620
|
-
if (path$
|
|
8621
|
-
if (!slices) slices = path$
|
|
8674
|
+
_t(path$2, cache$1, checkUnignored, slices) {
|
|
8675
|
+
if (path$2 in cache$1) return cache$1[path$2];
|
|
8676
|
+
if (!slices) slices = path$2.split(SLASH);
|
|
8622
8677
|
slices.pop();
|
|
8623
|
-
if (!slices.length) return cache$1[path$
|
|
8678
|
+
if (!slices.length) return cache$1[path$2] = this._testOne(path$2, checkUnignored);
|
|
8624
8679
|
const parent = this._t(slices.join(SLASH) + SLASH, cache$1, checkUnignored, slices);
|
|
8625
|
-
return cache$1[path$
|
|
8680
|
+
return cache$1[path$2] = parent.ignored ? parent : this._testOne(path$2, checkUnignored);
|
|
8626
8681
|
}
|
|
8627
|
-
ignores(path$
|
|
8628
|
-
return this._test(path$
|
|
8682
|
+
ignores(path$2) {
|
|
8683
|
+
return this._test(path$2, this._ignoreCache, false).ignored;
|
|
8629
8684
|
}
|
|
8630
8685
|
createFilter() {
|
|
8631
|
-
return (path$
|
|
8686
|
+
return (path$2) => !this.ignores(path$2);
|
|
8632
8687
|
}
|
|
8633
8688
|
filter(paths) {
|
|
8634
8689
|
return makeArray(paths).filter(this.createFilter());
|
|
8635
8690
|
}
|
|
8636
|
-
test(path$
|
|
8637
|
-
return this._test(path$
|
|
8691
|
+
test(path$2) {
|
|
8692
|
+
return this._test(path$2, this._testCache, true);
|
|
8638
8693
|
}
|
|
8639
8694
|
};
|
|
8640
8695
|
const factory = (options) => new Ignore(options);
|
|
8641
|
-
const isPathValid = (path$
|
|
8696
|
+
const isPathValid = (path$2) => checkPath(path$2 && checkPath.convert(path$2), path$2, RETURN_FALSE);
|
|
8642
8697
|
factory.isPathValid = isPathValid;
|
|
8643
8698
|
factory.default = factory;
|
|
8644
8699
|
module.exports = factory;
|
|
@@ -8647,7 +8702,7 @@ var require_ignore = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/igno
|
|
|
8647
8702
|
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
8648
8703
|
checkPath.convert = makePosix;
|
|
8649
8704
|
const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
8650
|
-
checkPath.isNotRelative = (path$
|
|
8705
|
+
checkPath.isNotRelative = (path$2) => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path$2) || isNotRelative(path$2);
|
|
8651
8706
|
}
|
|
8652
8707
|
}) });
|
|
8653
8708
|
|
|
@@ -10002,11 +10057,11 @@ var Mime = class {
|
|
|
10002
10057
|
}
|
|
10003
10058
|
return this;
|
|
10004
10059
|
}
|
|
10005
|
-
getType(path$
|
|
10006
|
-
if (typeof path$
|
|
10007
|
-
const last = path$
|
|
10060
|
+
getType(path$2) {
|
|
10061
|
+
if (typeof path$2 !== "string") return null;
|
|
10062
|
+
const last = path$2.replace(/^.*[/\\]/s, "").toLowerCase();
|
|
10008
10063
|
const ext = last.replace(/^.*\./s, "").toLowerCase();
|
|
10009
|
-
const hasPath = last.length < path$
|
|
10064
|
+
const hasPath = last.length < path$2.length;
|
|
10010
10065
|
if (!(ext.length < last.length - 1) && hasPath) return null;
|
|
10011
10066
|
return __classPrivateFieldGet(this, _Mime_extensionToType, "f").get(ext) ?? null;
|
|
10012
10067
|
}
|
|
@@ -10328,8 +10383,8 @@ function getErrorMap() {
|
|
|
10328
10383
|
return overrideErrorMap;
|
|
10329
10384
|
}
|
|
10330
10385
|
const makeIssue = (params) => {
|
|
10331
|
-
const { data: data$1, path: path$
|
|
10332
|
-
const fullPath = [...path$
|
|
10386
|
+
const { data: data$1, path: path$2, errorMaps, issueData } = params;
|
|
10387
|
+
const fullPath = [...path$2, ...issueData.path || []];
|
|
10333
10388
|
const fullIssue = {
|
|
10334
10389
|
...issueData,
|
|
10335
10390
|
path: fullPath
|
|
@@ -10426,11 +10481,11 @@ var errorUtil;
|
|
|
10426
10481
|
errorUtil$1.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
|
|
10427
10482
|
})(errorUtil || (errorUtil = {}));
|
|
10428
10483
|
var ParseInputLazyPath = class {
|
|
10429
|
-
constructor(parent, value, path$
|
|
10484
|
+
constructor(parent, value, path$2, key) {
|
|
10430
10485
|
this._cachedPath = [];
|
|
10431
10486
|
this.parent = parent;
|
|
10432
10487
|
this.data = value;
|
|
10433
|
-
this._path = path$
|
|
10488
|
+
this._path = path$2;
|
|
10434
10489
|
this._key = key;
|
|
10435
10490
|
}
|
|
10436
10491
|
get path() {
|
|
@@ -13592,10 +13647,10 @@ function getAssetsConfig(resolvedPluginConfig, entryWorkerConfig, resolvedConfig
|
|
|
13592
13647
|
};
|
|
13593
13648
|
}
|
|
13594
13649
|
function getRedirectsConfigPath(config) {
|
|
13595
|
-
return path$
|
|
13650
|
+
return path$1.join(config.publicDir, REDIRECTS_FILENAME);
|
|
13596
13651
|
}
|
|
13597
13652
|
function getHeadersConfigPath(config) {
|
|
13598
|
-
return path$
|
|
13653
|
+
return path$1.join(config.publicDir, HEADERS_FILENAME);
|
|
13599
13654
|
}
|
|
13600
13655
|
|
|
13601
13656
|
//#endregion
|
|
@@ -13712,7 +13767,7 @@ function createBuildApp(resolvedPluginConfig) {
|
|
|
13712
13767
|
return async (builder) => {
|
|
13713
13768
|
const clientEnvironment = builder.environments.client;
|
|
13714
13769
|
assert(clientEnvironment, `No "client" environment`);
|
|
13715
|
-
const defaultHtmlPath = path$
|
|
13770
|
+
const defaultHtmlPath = path$1.resolve(builder.config.root, "index.html");
|
|
13716
13771
|
const hasClientEntry = clientEnvironment.config.build.rollupOptions.input || fs$1.existsSync(defaultHtmlPath);
|
|
13717
13772
|
if (resolvedPluginConfig.type === "assets-only") {
|
|
13718
13773
|
if (hasClientEntry) await builder.build(clientEnvironment);
|
|
@@ -13728,32 +13783,32 @@ function createBuildApp(resolvedPluginConfig) {
|
|
|
13728
13783
|
const { entryWorkerEnvironmentName } = resolvedPluginConfig;
|
|
13729
13784
|
const entryWorkerEnvironment = builder.environments[entryWorkerEnvironmentName];
|
|
13730
13785
|
assert(entryWorkerEnvironment, `No "${entryWorkerEnvironmentName}" environment`);
|
|
13731
|
-
const entryWorkerBuildDirectory = path$
|
|
13786
|
+
const entryWorkerBuildDirectory = path$1.resolve(builder.config.root, entryWorkerEnvironment.config.build.outDir);
|
|
13732
13787
|
const importedAssetPaths = getImportedAssetPaths(loadViteManifest(entryWorkerBuildDirectory));
|
|
13733
13788
|
if (hasClientEntry) await builder.build(clientEnvironment);
|
|
13734
13789
|
else if (importedAssetPaths.size || getHasPublicAssets(builder.config)) await fallbackBuild(builder, clientEnvironment);
|
|
13735
13790
|
else {
|
|
13736
|
-
const entryWorkerConfigPath = path$
|
|
13791
|
+
const entryWorkerConfigPath = path$1.join(entryWorkerBuildDirectory, "wrangler.json");
|
|
13737
13792
|
const workerConfig = JSON.parse(fs$1.readFileSync(entryWorkerConfigPath, "utf-8"));
|
|
13738
13793
|
workerConfig.assets = void 0;
|
|
13739
13794
|
fs$1.writeFileSync(entryWorkerConfigPath, JSON.stringify(workerConfig));
|
|
13740
13795
|
return;
|
|
13741
13796
|
}
|
|
13742
|
-
const clientBuildDirectory = path$
|
|
13797
|
+
const clientBuildDirectory = path$1.resolve(builder.config.root, clientEnvironment.config.build.outDir);
|
|
13743
13798
|
const movedAssetPaths = [];
|
|
13744
13799
|
for (const assetPath of importedAssetPaths) {
|
|
13745
|
-
const src = path$
|
|
13746
|
-
const dest = path$
|
|
13800
|
+
const src = path$1.join(entryWorkerBuildDirectory, assetPath);
|
|
13801
|
+
const dest = path$1.join(clientBuildDirectory, assetPath);
|
|
13747
13802
|
if (!fs$1.existsSync(src)) continue;
|
|
13748
13803
|
if (fs$1.existsSync(dest)) fs$1.unlinkSync(src);
|
|
13749
13804
|
else {
|
|
13750
|
-
const destDir = path$
|
|
13805
|
+
const destDir = path$1.dirname(dest);
|
|
13751
13806
|
fs$1.mkdirSync(destDir, { recursive: true });
|
|
13752
13807
|
fs$1.renameSync(src, dest);
|
|
13753
13808
|
movedAssetPaths.push(dest);
|
|
13754
13809
|
}
|
|
13755
13810
|
}
|
|
13756
|
-
if (movedAssetPaths.length) builder.config.logger.info([`${colors.green("✓")} ${movedAssetPaths.length} asset${movedAssetPaths.length > 1 ? "s" : ""} moved from "${entryWorkerEnvironmentName}" to "client" build output.`, ...movedAssetPaths.map((assetPath) => colors.dim(path$
|
|
13811
|
+
if (movedAssetPaths.length) builder.config.logger.info([`${colors.green("✓")} ${movedAssetPaths.length} asset${movedAssetPaths.length > 1 ? "s" : ""} moved from "${entryWorkerEnvironmentName}" to "client" build output.`, ...movedAssetPaths.map((assetPath) => colors.dim(path$1.relative(builder.config.root, assetPath)))].join("\n"));
|
|
13757
13812
|
};
|
|
13758
13813
|
}
|
|
13759
13814
|
function getHasPublicAssets({ publicDir }) {
|
|
@@ -13770,11 +13825,11 @@ async function fallbackBuild(builder, environment) {
|
|
|
13770
13825
|
output: { entryFileNames: CLIENT_FALLBACK_ENTRY_NAME }
|
|
13771
13826
|
};
|
|
13772
13827
|
await builder.build(environment);
|
|
13773
|
-
const fallbackEntryPath = path$
|
|
13828
|
+
const fallbackEntryPath = path$1.resolve(builder.config.root, environment.config.build.outDir, CLIENT_FALLBACK_ENTRY_NAME);
|
|
13774
13829
|
fs$1.unlinkSync(fallbackEntryPath);
|
|
13775
13830
|
}
|
|
13776
13831
|
function loadViteManifest(directory) {
|
|
13777
|
-
const contents = fs$1.readFileSync(path$
|
|
13832
|
+
const contents = fs$1.readFileSync(path$1.resolve(directory, ".vite", "manifest.json"), "utf-8");
|
|
13778
13833
|
return JSON.parse(contents);
|
|
13779
13834
|
}
|
|
13780
13835
|
function getImportedAssetPaths(viteManifest) {
|
|
@@ -13976,12 +14031,12 @@ function getLocalDevVarsForPreview(configPath, cloudflareEnv) {
|
|
|
13976
14031
|
*/
|
|
13977
14032
|
function hasLocalDevVarsFileChanged({ configPaths, cloudflareEnv }, changedFilePath) {
|
|
13978
14033
|
return [...configPaths].some((configPath) => {
|
|
13979
|
-
const configDir = path$
|
|
14034
|
+
const configDir = path$1.dirname(configPath);
|
|
13980
14035
|
return [
|
|
13981
14036
|
".dev.vars",
|
|
13982
14037
|
".env",
|
|
13983
14038
|
...cloudflareEnv ? [`.dev.vars.${cloudflareEnv}`, `.env.${cloudflareEnv}`] : []
|
|
13984
|
-
].some((localDevFile) => changedFilePath === path$
|
|
14039
|
+
].some((localDevFile) => changedFilePath === path$1.join(configDir, localDevFile));
|
|
13985
14040
|
});
|
|
13986
14041
|
}
|
|
13987
14042
|
|
|
@@ -14551,11 +14606,11 @@ const getQueryString = (params) => {
|
|
|
14551
14606
|
};
|
|
14552
14607
|
const getUrl = (config, options) => {
|
|
14553
14608
|
const encoder = config.ENCODE_PATH || encodeURI;
|
|
14554
|
-
const path$
|
|
14609
|
+
const path$2 = options.url.replace("{api-version}", config.VERSION).replace(/{(.*?)}/g, (substring, group) => {
|
|
14555
14610
|
if (options.path?.hasOwnProperty(group)) return encoder(String(options.path[group]));
|
|
14556
14611
|
return substring;
|
|
14557
14612
|
});
|
|
14558
|
-
const url = `${config.BASE}${path$
|
|
14613
|
+
const url = `${config.BASE}${path$2}`;
|
|
14559
14614
|
if (options.query) return `${url}${getQueryString(options.query)}`;
|
|
14560
14615
|
return url;
|
|
14561
14616
|
};
|
|
@@ -14896,7 +14951,7 @@ async function constructBuildCommand(options, logger) {
|
|
|
14896
14951
|
];
|
|
14897
14952
|
if (options.args) for (const arg in options.args) buildCmd.push("--build-arg", `${arg}=${options.args[arg]}`);
|
|
14898
14953
|
if (options.setNetworkToHost) buildCmd.push("--network", "host");
|
|
14899
|
-
const dockerfile = readFileSync
|
|
14954
|
+
const dockerfile = readFileSync(options.pathToDockerfile, "utf-8");
|
|
14900
14955
|
buildCmd.push("-f", "-");
|
|
14901
14956
|
buildCmd.push(options.buildContext);
|
|
14902
14957
|
logger?.debug(`Building image with command: ${buildCmd.join(" ")}`);
|
|
@@ -14972,7 +15027,7 @@ async function dockerLoginImageRegistry(pathToDocker, domain) {
|
|
|
14972
15027
|
expiration_minutes: 15,
|
|
14973
15028
|
permissions: [ImageRegistryPermissions.PUSH, ImageRegistryPermissions.PULL]
|
|
14974
15029
|
});
|
|
14975
|
-
const child = spawn
|
|
15030
|
+
const child = spawn(pathToDocker, [
|
|
14976
15031
|
"login",
|
|
14977
15032
|
"--password-stdin",
|
|
14978
15033
|
"--username",
|
|
@@ -15001,6 +15056,9 @@ const MF_DEV_CONTAINER_PREFIX = "cloudflare-dev";
|
|
|
15001
15056
|
|
|
15002
15057
|
//#endregion
|
|
15003
15058
|
//#region ../containers-shared/src/knobs.ts
|
|
15059
|
+
const getCloudflareContainerRegistry = () => {
|
|
15060
|
+
return process.env.CLOUDFLARE_CONTAINER_REGISTRY ?? (process.env.WRANGLER_API_ENVIRONMENT === "staging" ? "staging.registry.cloudflare.com" : "registry.cloudflare.com");
|
|
15061
|
+
};
|
|
15004
15062
|
/** Prefixes with the cloudflare-dev namespace. The name should be the container's DO classname, and the tag a build uuid. */
|
|
15005
15063
|
const getDevContainerImageName = (name, tag) => {
|
|
15006
15064
|
return `${MF_DEV_CONTAINER_PREFIX}/${name.toLowerCase()}:${tag}`;
|
|
@@ -15098,12 +15156,12 @@ const verifyDockerInstalled = async (dockerPath, isDev = true) => {
|
|
|
15098
15156
|
Other container tooling that is compatible with the Docker CLI and engine may work, but is not yet guaranteed to do so. You can specify an executable with the environment variable WRANGLER_DOCKER_BIN and a socket with DOCKER_HOST.${isDev ? "\nTo suppress this error if you do not intend on triggering any container instances, set dev.enable_containers to false in your Wrangler config or passing in --enable-containers=false." : ""}`);
|
|
15099
15157
|
};
|
|
15100
15158
|
function isDir(inputPath) {
|
|
15101
|
-
return statSync
|
|
15159
|
+
return statSync(inputPath).isDirectory();
|
|
15102
15160
|
}
|
|
15103
15161
|
/** returns true if it is a dockerfile, false if it is a registry link, throws if neither */
|
|
15104
15162
|
const isDockerfile = (image, configPath) => {
|
|
15105
|
-
const baseDir = configPath ? path
|
|
15106
|
-
const maybeDockerfile = path
|
|
15163
|
+
const baseDir = configPath ? path.dirname(configPath) : process.cwd();
|
|
15164
|
+
const maybeDockerfile = path.resolve(baseDir, image);
|
|
15107
15165
|
if (existsSync(maybeDockerfile)) {
|
|
15108
15166
|
if (isDir(maybeDockerfile)) throw new UserError(`${image} is a directory, you should specify a path to the Dockerfile`);
|
|
15109
15167
|
return true;
|
|
@@ -15234,11 +15292,33 @@ async function cleanupDuplicateImageTags(dockerPath, imageTag) {
|
|
|
15234
15292
|
} catch {}
|
|
15235
15293
|
}
|
|
15236
15294
|
|
|
15295
|
+
//#endregion
|
|
15296
|
+
//#region ../containers-shared/src/client/models/ExternalRegistryKind.ts
|
|
15297
|
+
/* istanbul ignore file */
|
|
15298
|
+
/**
|
|
15299
|
+
* The type of external registry that is being configured.
|
|
15300
|
+
*/
|
|
15301
|
+
let ExternalRegistryKind = /* @__PURE__ */ function(ExternalRegistryKind$1) {
|
|
15302
|
+
ExternalRegistryKind$1["ECR"] = "ECR";
|
|
15303
|
+
return ExternalRegistryKind$1;
|
|
15304
|
+
}({});
|
|
15305
|
+
|
|
15237
15306
|
//#endregion
|
|
15238
15307
|
//#region ../containers-shared/src/images.ts
|
|
15239
|
-
async function pullImage(dockerPath, options) {
|
|
15308
|
+
async function pullImage(dockerPath, options, logger, isVite) {
|
|
15240
15309
|
const domain = new URL(`http://${options.image_uri}`).hostname;
|
|
15241
|
-
|
|
15310
|
+
const isExternalRegistry = domain !== getCloudflareContainerRegistry();
|
|
15311
|
+
try {
|
|
15312
|
+
await dockerLoginImageRegistry(dockerPath, domain);
|
|
15313
|
+
} catch (e) {
|
|
15314
|
+
if (!isExternalRegistry) {
|
|
15315
|
+
if (isVite) throw new UserError(`Using images from the Cloudflare-managed registry is not currently supported with the Vite plugin.
|
|
15316
|
+
You should use a Dockerfile or a supported external registry and authenticate to that registry separately using \`docker login\` or similar.
|
|
15317
|
+
Supported external registries are currently: ${Object.values(ExternalRegistryKind).join(", ")}.`);
|
|
15318
|
+
throw e;
|
|
15319
|
+
}
|
|
15320
|
+
logger?.warn("Unable to retrieve configured registry credentials from Cloudflare.\nUnless this is a public image, you will need to run `wrangler containers registries configure` before deploying.\nAttempting to pull image anyway...");
|
|
15321
|
+
}
|
|
15242
15322
|
const pull = runDockerCmd(dockerPath, [
|
|
15243
15323
|
"pull",
|
|
15244
15324
|
options.image_uri,
|
|
@@ -15286,7 +15366,7 @@ async function prepareContainerImagesForDev(args) {
|
|
|
15286
15366
|
await build.ready;
|
|
15287
15367
|
onContainerImagePreparationEnd({ containerOptions: options });
|
|
15288
15368
|
} else {
|
|
15289
|
-
const pull = await pullImage(dockerPath, options);
|
|
15369
|
+
const pull = await pullImage(dockerPath, options, args.logger, args.isVite);
|
|
15290
15370
|
onContainerImagePreparationStart({
|
|
15291
15371
|
containerOptions: options,
|
|
15292
15372
|
abort: () => {
|
|
@@ -15370,7 +15450,7 @@ const INTERNAL_WORKERS_COMPATIBILITY_DATE = "2024-10-04";
|
|
|
15370
15450
|
const PUBLIC_DIR_PREFIX = "/__vite_public_dir__";
|
|
15371
15451
|
function getPersistenceRoot(root, persistState) {
|
|
15372
15452
|
if (persistState === false) return;
|
|
15373
|
-
return path$
|
|
15453
|
+
return path$1.resolve(root, typeof persistState === "object" ? persistState.path : ".wrangler/state", "v3");
|
|
15374
15454
|
}
|
|
15375
15455
|
const miniflareModulesRoot = process.platform === "win32" ? "Z:\\" : "/";
|
|
15376
15456
|
const ROUTER_WORKER_PATH = "./workers/router-worker.js";
|
|
@@ -15378,15 +15458,6 @@ const ASSET_WORKER_PATH = "./workers/asset-worker.js";
|
|
|
15378
15458
|
const VITE_PROXY_WORKER_PATH = "./workers/vite-proxy-worker.js";
|
|
15379
15459
|
const RUNNER_PATH = "./workers/runner-worker.js";
|
|
15380
15460
|
const WRAPPER_PATH = "__VITE_WORKER_ENTRY__";
|
|
15381
|
-
function logUnknownTails(tails, userWorkers, log) {
|
|
15382
|
-
for (const tailService of tails ?? []) {
|
|
15383
|
-
let name;
|
|
15384
|
-
if (typeof tailService === "string") name = tailService;
|
|
15385
|
-
else if (typeof tailService === "object" && "name" in tailService && typeof tailService.name === "string") name = tailService.name;
|
|
15386
|
-
else continue;
|
|
15387
|
-
if (!userWorkers.some((w) => w.name === name)) log(colors.dim(colors.yellow(`Tail consumer "${name}" was not found in your config. Make sure you add it to the config or run it in another dev session if you'd like to simulate receiving tail events locally.`)));
|
|
15388
|
-
}
|
|
15389
|
-
}
|
|
15390
15461
|
/** Map that maps worker configPaths to their existing remote proxy session data (if any) */
|
|
15391
15462
|
const remoteProxySessionsDataMap = /* @__PURE__ */ new Map();
|
|
15392
15463
|
async function getDevMiniflareOptions(ctx, viteDevServer) {
|
|
@@ -15400,7 +15471,7 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
|
|
|
15400
15471
|
modulesRoot: miniflareModulesRoot,
|
|
15401
15472
|
modules: [{
|
|
15402
15473
|
type: "ESModule",
|
|
15403
|
-
path: path$
|
|
15474
|
+
path: path$1.join(miniflareModulesRoot, ROUTER_WORKER_PATH),
|
|
15404
15475
|
contents: fs$1.readFileSync(fileURLToPath(new URL(ROUTER_WORKER_PATH, import.meta.url)))
|
|
15405
15476
|
}],
|
|
15406
15477
|
bindings: { CONFIG: { has_user_worker: resolvedPluginConfig.type === "workers" } },
|
|
@@ -15415,7 +15486,7 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
|
|
|
15415
15486
|
modulesRoot: miniflareModulesRoot,
|
|
15416
15487
|
modules: [{
|
|
15417
15488
|
type: "ESModule",
|
|
15418
|
-
path: path$
|
|
15489
|
+
path: path$1.join(miniflareModulesRoot, ASSET_WORKER_PATH),
|
|
15419
15490
|
contents: fs$1.readFileSync(fileURLToPath(new URL(ASSET_WORKER_PATH, import.meta.url)))
|
|
15420
15491
|
}],
|
|
15421
15492
|
bindings: {
|
|
@@ -15430,8 +15501,8 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
|
|
|
15430
15501
|
const publicDirInRoot = publicDir.startsWith(withTrailingSlash(root));
|
|
15431
15502
|
const publicPath = withTrailingSlash(publicDir.slice(root.length));
|
|
15432
15503
|
if (publicDirInRoot && pathname.startsWith(publicPath)) return Response$1.json(null);
|
|
15433
|
-
const publicDirFilePath = path$
|
|
15434
|
-
const rootDirFilePath = path$
|
|
15504
|
+
const publicDirFilePath = path$1.join(publicDir, pathname);
|
|
15505
|
+
const rootDirFilePath = path$1.join(root, pathname);
|
|
15435
15506
|
for (const resolvedPath of [publicDirFilePath, rootDirFilePath]) try {
|
|
15436
15507
|
if ((await fsp.stat(resolvedPath)).isFile()) return Response$1.json(resolvedPath === publicDirFilePath ? `${PUBLIC_DIR_PREFIX}${pathname}` : pathname);
|
|
15437
15508
|
} catch (error) {}
|
|
@@ -15442,7 +15513,7 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
|
|
|
15442
15513
|
const { pathname } = new URL(request$1.url);
|
|
15443
15514
|
const { root, publicDir } = resolvedViteConfig;
|
|
15444
15515
|
const isInPublicDir = pathname.startsWith(PUBLIC_DIR_PREFIX);
|
|
15445
|
-
const resolvedPath = isInPublicDir ? path$
|
|
15516
|
+
const resolvedPath = isInPublicDir ? path$1.join(publicDir, pathname.slice(20)) : path$1.join(root, pathname);
|
|
15446
15517
|
try {
|
|
15447
15518
|
let html = await fsp.readFile(resolvedPath, "utf-8");
|
|
15448
15519
|
if (!isInPublicDir) html = await viteDevServer.transformIndexHtml(resolvedPath, html);
|
|
@@ -15459,7 +15530,7 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
|
|
|
15459
15530
|
modulesRoot: miniflareModulesRoot,
|
|
15460
15531
|
modules: [{
|
|
15461
15532
|
type: "ESModule",
|
|
15462
|
-
path: path$
|
|
15533
|
+
path: path$1.join(miniflareModulesRoot, VITE_PROXY_WORKER_PATH),
|
|
15463
15534
|
contents: fs$1.readFileSync(fileURLToPath(new URL(VITE_PROXY_WORKER_PATH, import.meta.url)))
|
|
15464
15535
|
}],
|
|
15465
15536
|
serviceBindings: {
|
|
@@ -15474,7 +15545,8 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
|
|
|
15474
15545
|
const preExistingRemoteProxySession = worker.config.configPath ? remoteProxySessionsDataMap.get(worker.config.configPath) : void 0;
|
|
15475
15546
|
const remoteProxySessionData = !resolvedPluginConfig.remoteBindings ? null : await maybeStartOrUpdateRemoteProxySession({
|
|
15476
15547
|
name: worker.config.name,
|
|
15477
|
-
bindings: bindings ?? {}
|
|
15548
|
+
bindings: bindings ?? {},
|
|
15549
|
+
account_id: worker.config.account_id
|
|
15478
15550
|
}, preExistingRemoteProxySession ?? null);
|
|
15479
15551
|
if (worker.config.configPath && remoteProxySessionData) remoteProxySessionsDataMap.set(worker.config.configPath, remoteProxySessionData);
|
|
15480
15552
|
let containerBuildId;
|
|
@@ -15489,27 +15561,45 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
|
|
|
15489
15561
|
});
|
|
15490
15562
|
for (const option of options ?? []) containerTagToOptionsMap.set(option.image_tag, option);
|
|
15491
15563
|
}
|
|
15492
|
-
const
|
|
15564
|
+
const { externalWorkers: externalWorkers$1, workerOptions } = unstable_getMiniflareWorkerOptions({
|
|
15493
15565
|
...worker.config,
|
|
15494
15566
|
assets: void 0
|
|
15495
15567
|
}, resolvedPluginConfig.cloudflareEnv, {
|
|
15496
15568
|
remoteProxyConnectionString: remoteProxySessionData?.session?.remoteProxyConnectionString,
|
|
15497
15569
|
containerBuildId
|
|
15498
15570
|
});
|
|
15499
|
-
const
|
|
15500
|
-
|
|
15571
|
+
const wrappers = [
|
|
15572
|
+
`import { createWorkerEntrypointWrapper, createDurableObjectWrapper, createWorkflowEntrypointWrapper } from "${RUNNER_PATH}";`,
|
|
15573
|
+
`export { __VITE_RUNNER_OBJECT__ } from "${RUNNER_PATH}";`,
|
|
15574
|
+
`export default createWorkerEntrypointWrapper("default");`
|
|
15575
|
+
];
|
|
15576
|
+
const exportTypes = ctx.workerNameToExportTypesMap.get(worker.config.name);
|
|
15577
|
+
assert(exportTypes, `Expected exportTypes to be defined`);
|
|
15578
|
+
for (const [name, type] of Object.entries(exportTypes)) wrappers.push(`export const ${name} = create${type}Wrapper("${name}");`);
|
|
15501
15579
|
return {
|
|
15502
15580
|
externalWorkers: externalWorkers$1,
|
|
15503
15581
|
worker: {
|
|
15504
15582
|
...workerOptions,
|
|
15505
|
-
name:
|
|
15583
|
+
name: worker.config.name,
|
|
15584
|
+
modulesRoot: miniflareModulesRoot,
|
|
15585
|
+
modules: [{
|
|
15586
|
+
type: "ESModule",
|
|
15587
|
+
path: path$1.join(miniflareModulesRoot, WRAPPER_PATH),
|
|
15588
|
+
contents: wrappers.join("\n")
|
|
15589
|
+
}, {
|
|
15590
|
+
type: "ESModule",
|
|
15591
|
+
path: path$1.join(miniflareModulesRoot, RUNNER_PATH),
|
|
15592
|
+
contents: fs$1.readFileSync(fileURLToPath(new URL(RUNNER_PATH, import.meta.url)))
|
|
15593
|
+
}],
|
|
15594
|
+
unsafeUseModuleFallbackService: true,
|
|
15506
15595
|
unsafeInspectorProxy: inputInspectorPort !== false,
|
|
15507
15596
|
unsafeDirectSockets: environmentName === resolvedPluginConfig.entryWorkerEnvironmentName ? [{
|
|
15508
15597
|
serviceName: VITE_PROXY_WORKER_NAME,
|
|
15509
|
-
entrypoint: void 0,
|
|
15510
15598
|
proxy: true
|
|
15511
|
-
}]
|
|
15512
|
-
|
|
15599
|
+
}, ...Object.entries(exportTypes).filter(([_, type]) => type === "WorkerEntrypoint").map(([entrypoint]) => ({
|
|
15600
|
+
entrypoint,
|
|
15601
|
+
proxy: true
|
|
15602
|
+
}))] : [],
|
|
15513
15603
|
unsafeEvalBinding: "__VITE_UNSAFE_EVAL__",
|
|
15514
15604
|
serviceBindings: {
|
|
15515
15605
|
...workerOptions.serviceBindings,
|
|
@@ -15522,6 +15612,14 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
|
|
|
15522
15612
|
const result = await viteDevServer.environments[environmentName].hot.handleInvoke(payload);
|
|
15523
15613
|
return Response$1.json(result);
|
|
15524
15614
|
}
|
|
15615
|
+
},
|
|
15616
|
+
durableObjects: {
|
|
15617
|
+
...workerOptions.durableObjects,
|
|
15618
|
+
__VITE_RUNNER_OBJECT__: {
|
|
15619
|
+
className: "__VITE_RUNNER_OBJECT__",
|
|
15620
|
+
unsafeUniqueKey: kUnsafeEphemeralUniqueKey,
|
|
15621
|
+
unsafePreventEviction: true
|
|
15622
|
+
}
|
|
15525
15623
|
}
|
|
15526
15624
|
}
|
|
15527
15625
|
};
|
|
@@ -15541,38 +15639,7 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
|
|
|
15541
15639
|
workers: [
|
|
15542
15640
|
...assetWorkers,
|
|
15543
15641
|
...externalWorkers,
|
|
15544
|
-
...userWorkers
|
|
15545
|
-
const wrappers = [
|
|
15546
|
-
`import { createWorkerEntrypointWrapper, createDurableObjectWrapper, createWorkflowEntrypointWrapper } from "${RUNNER_PATH}";`,
|
|
15547
|
-
`export { __VITE_RUNNER_OBJECT__ } from "${RUNNER_PATH}";`,
|
|
15548
|
-
`export default createWorkerEntrypointWrapper("default");`
|
|
15549
|
-
];
|
|
15550
|
-
const exportTypes = ctx.workerNameToExportTypesMap.get(workerOptions.name);
|
|
15551
|
-
assert(exportTypes, `Expected exportTypes to be defined`);
|
|
15552
|
-
for (const [name, type] of Object.entries(exportTypes)) wrappers.push(`export const ${name} = create${type}Wrapper("${name}");`);
|
|
15553
|
-
logUnknownTails(workerOptions.tails, userWorkers, viteDevServer.config.logger.warn);
|
|
15554
|
-
return {
|
|
15555
|
-
...workerOptions,
|
|
15556
|
-
durableObjects: {
|
|
15557
|
-
...workerOptions.durableObjects,
|
|
15558
|
-
__VITE_RUNNER_OBJECT__: {
|
|
15559
|
-
className: "__VITE_RUNNER_OBJECT__",
|
|
15560
|
-
unsafeUniqueKey: kUnsafeEphemeralUniqueKey,
|
|
15561
|
-
unsafePreventEviction: true
|
|
15562
|
-
}
|
|
15563
|
-
},
|
|
15564
|
-
modules: [{
|
|
15565
|
-
type: "ESModule",
|
|
15566
|
-
path: path$2.join(miniflareModulesRoot, WRAPPER_PATH),
|
|
15567
|
-
contents: wrappers.join("\n")
|
|
15568
|
-
}, {
|
|
15569
|
-
type: "ESModule",
|
|
15570
|
-
path: path$2.join(miniflareModulesRoot, RUNNER_PATH),
|
|
15571
|
-
contents: fs$1.readFileSync(fileURLToPath(new URL(RUNNER_PATH, import.meta.url)))
|
|
15572
|
-
}],
|
|
15573
|
-
unsafeUseModuleFallbackService: true
|
|
15574
|
-
};
|
|
15575
|
-
})
|
|
15642
|
+
...userWorkers
|
|
15576
15643
|
],
|
|
15577
15644
|
async unsafeModuleFallbackService(request$1) {
|
|
15578
15645
|
const rawSpecifier = new URL(request$1.url).searchParams.get("rawSpecifier");
|
|
@@ -15601,8 +15668,8 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
|
|
|
15601
15668
|
}
|
|
15602
15669
|
function getPreviewModules(main, modulesRules) {
|
|
15603
15670
|
assert(modulesRules, `Unexpected error: 'modulesRules' is undefined`);
|
|
15604
|
-
const rootPath = path$
|
|
15605
|
-
const entryPath = path$
|
|
15671
|
+
const rootPath = path$1.dirname(main);
|
|
15672
|
+
const entryPath = path$1.basename(main);
|
|
15606
15673
|
return {
|
|
15607
15674
|
rootPath,
|
|
15608
15675
|
modules: [{
|
|
@@ -15611,9 +15678,9 @@ function getPreviewModules(main, modulesRules) {
|
|
|
15611
15678
|
}, ...modulesRules.flatMap(({ type, include }) => globSync(include, {
|
|
15612
15679
|
cwd: rootPath,
|
|
15613
15680
|
ignore: entryPath
|
|
15614
|
-
}).map((path$
|
|
15681
|
+
}).map((path$2) => ({
|
|
15615
15682
|
type,
|
|
15616
|
-
path: path$
|
|
15683
|
+
path: path$2
|
|
15617
15684
|
})))]
|
|
15618
15685
|
};
|
|
15619
15686
|
}
|
|
@@ -15626,7 +15693,8 @@ async function getPreviewMiniflareOptions(ctx, vitePreviewServer) {
|
|
|
15626
15693
|
const preExistingRemoteProxySessionData = workerConfig.configPath ? remoteProxySessionsDataMap.get(workerConfig.configPath) : void 0;
|
|
15627
15694
|
const remoteProxySessionData = !resolvedPluginConfig.remoteBindings ? null : await maybeStartOrUpdateRemoteProxySession({
|
|
15628
15695
|
name: workerConfig.name,
|
|
15629
|
-
bindings: bindings ?? {}
|
|
15696
|
+
bindings: bindings ?? {},
|
|
15697
|
+
account_id: workerConfig.account_id
|
|
15630
15698
|
}, preExistingRemoteProxySessionData ?? null);
|
|
15631
15699
|
if (workerConfig.configPath && remoteProxySessionData) remoteProxySessionsDataMap.set(workerConfig.configPath, remoteProxySessionData);
|
|
15632
15700
|
let containerBuildId;
|
|
@@ -15647,7 +15715,6 @@ async function getPreviewMiniflareOptions(ctx, vitePreviewServer) {
|
|
|
15647
15715
|
});
|
|
15648
15716
|
const { externalWorkers } = miniflareWorkerOptions;
|
|
15649
15717
|
const { modulesRules,...workerOptions } = miniflareWorkerOptions.workerOptions;
|
|
15650
|
-
logUnknownTails(workerOptions.tails, resolvedPluginConfig.workers, vitePreviewServer.config.logger.warn);
|
|
15651
15718
|
return [{
|
|
15652
15719
|
...workerOptions,
|
|
15653
15720
|
name: workerOptions.name ?? workerConfig.name,
|
|
@@ -15824,7 +15891,9 @@ const devPlugin = createPlugin("dev", (ctx) => {
|
|
|
15824
15891
|
dockerPath: getDockerPath(),
|
|
15825
15892
|
containerOptions: [...containerTagToOptionsMap.values()],
|
|
15826
15893
|
onContainerImagePreparationStart: () => {},
|
|
15827
|
-
onContainerImagePreparationEnd: () => {}
|
|
15894
|
+
onContainerImagePreparationEnd: () => {},
|
|
15895
|
+
logger: viteDevServer.config.logger,
|
|
15896
|
+
isVite: true
|
|
15828
15897
|
});
|
|
15829
15898
|
containerImageTags = new Set(containerTagToOptionsMap.keys());
|
|
15830
15899
|
viteDevServer.config.logger.info(colors.dim(colors.yellow("\n⚡️ Containers successfully built. To rebuild your containers during development, restart the Vite dev server (r + enter).")));
|
|
@@ -15938,11 +16007,11 @@ const nodeJsCompatWarningsPlugin = createPlugin("nodejs-compat-warnings", (ctx)
|
|
|
15938
16007
|
if (workerConfig && !nodeJsCompat) return { optimizeDeps: { esbuildOptions: { plugins: [{
|
|
15939
16008
|
name: "vite-plugin-cloudflare:nodejs-compat-warnings-resolver",
|
|
15940
16009
|
setup(build) {
|
|
15941
|
-
build.onResolve({ filter: NODEJS_MODULES_RE }, ({ path: path$
|
|
15942
|
-
if (hasNodeJsAls(workerConfig) && isNodeAlsModule(path$
|
|
15943
|
-
nodeJsCompatWarningsMap.get(workerConfig)?.registerImport(path$
|
|
16010
|
+
build.onResolve({ filter: NODEJS_MODULES_RE }, ({ path: path$2, importer }) => {
|
|
16011
|
+
if (hasNodeJsAls(workerConfig) && isNodeAlsModule(path$2)) return;
|
|
16012
|
+
nodeJsCompatWarningsMap.get(workerConfig)?.registerImport(path$2, importer);
|
|
15944
16013
|
return {
|
|
15945
|
-
path: path$
|
|
16014
|
+
path: path$2,
|
|
15946
16015
|
external: true
|
|
15947
16016
|
};
|
|
15948
16017
|
});
|
|
@@ -16043,7 +16112,7 @@ const outputConfigPlugin = createPlugin("output-config", (ctx) => {
|
|
|
16043
16112
|
function getAssetsDirectory(workerOutputDirectory, resolvedViteConfig) {
|
|
16044
16113
|
const clientOutputDirectory = resolvedViteConfig.environments.client?.build.outDir;
|
|
16045
16114
|
assert(clientOutputDirectory, "Unexpected error: client output directory is undefined");
|
|
16046
|
-
return path$
|
|
16115
|
+
return path$1.relative(path$1.resolve(resolvedViteConfig.root, workerOutputDirectory), path$1.resolve(resolvedViteConfig.root, clientOutputDirectory));
|
|
16047
16116
|
}
|
|
16048
16117
|
|
|
16049
16118
|
//#endregion
|
|
@@ -16071,7 +16140,9 @@ const previewPlugin = createPlugin("preview", (ctx) => {
|
|
|
16071
16140
|
dockerPath: getDockerPath(),
|
|
16072
16141
|
containerOptions: [...containerTagToOptionsMap.values()],
|
|
16073
16142
|
onContainerImagePreparationStart: () => {},
|
|
16074
|
-
onContainerImagePreparationEnd: () => {}
|
|
16143
|
+
onContainerImagePreparationEnd: () => {},
|
|
16144
|
+
logger: vitePreviewServer.config.logger,
|
|
16145
|
+
isVite: true
|
|
16075
16146
|
});
|
|
16076
16147
|
const containerImageTags = new Set(containerTagToOptionsMap.keys());
|
|
16077
16148
|
vitePreviewServer.config.logger.info(colors.dim(colors.yellow("\n⚡️ Containers successfully built.\n")));
|