@cloudflare/vite-plugin 1.22.1 → 1.23.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 +3 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +443 -589
- package/dist/index.mjs.map +1 -1
- package/dist/{package-Cm02hKUb.mjs → package-BnDqs-gP.mjs} +3 -3
- package/dist/package-BnDqs-gP.mjs.map +1 -0
- package/dist/workers/asset-worker.js +1 -1
- package/dist/workers/runner-worker.js +1 -1
- package/package.json +8 -8
- package/dist/package-Cm02hKUb.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import assert from "node:assert";
|
|
|
3
3
|
import { CoreHeaders, Log, LogLevel, Miniflare, Request as Request$1, Response as Response$1, coupleWebSocket, getDefaultDevRegistryPath, getNodeCompat, getWorkerRegistry, kUnsafeEphemeralUniqueKey } from "miniflare";
|
|
4
4
|
import * as wrangler from "wrangler";
|
|
5
5
|
import * as nodePath from "node:path";
|
|
6
|
-
import
|
|
6
|
+
import path3, { relative, resolve } from "node:path";
|
|
7
7
|
import * as util$1 from "node:util";
|
|
8
8
|
import { format, inspect } from "node:util";
|
|
9
9
|
import * as vite from "vite";
|
|
@@ -1776,12 +1776,12 @@ var PluginContext = class {
|
|
|
1776
1776
|
return this.#resolvedViteConfig;
|
|
1777
1777
|
}
|
|
1778
1778
|
isChildEnvironment(environmentName) {
|
|
1779
|
-
if (this.resolvedPluginConfig.type
|
|
1779
|
+
if (this.resolvedPluginConfig.type === "preview") return false;
|
|
1780
1780
|
for (const childEnvironmentNames of this.resolvedPluginConfig.environmentNameToChildEnvironmentNamesMap.values()) if (childEnvironmentNames.includes(environmentName)) return true;
|
|
1781
1781
|
return false;
|
|
1782
1782
|
}
|
|
1783
1783
|
#getWorker(environmentName) {
|
|
1784
|
-
if (this.resolvedPluginConfig.type
|
|
1784
|
+
if (this.resolvedPluginConfig.type === "preview") return;
|
|
1785
1785
|
const worker = this.resolvedPluginConfig.environmentNameToWorkerMap.get(environmentName);
|
|
1786
1786
|
if (worker) return worker;
|
|
1787
1787
|
for (const [parentEnvironmentName, childEnvironmentNames] of this.resolvedPluginConfig.environmentNameToChildEnvironmentNamesMap) if (childEnvironmentNames.includes(environmentName)) return this.resolvedPluginConfig.environmentNameToWorkerMap.get(parentEnvironmentName);
|
|
@@ -1790,11 +1790,8 @@ var PluginContext = class {
|
|
|
1790
1790
|
return this.#getWorker(environmentName)?.config;
|
|
1791
1791
|
}
|
|
1792
1792
|
get allWorkerConfigs() {
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
case "preview": return this.resolvedPluginConfig.workers;
|
|
1796
|
-
default: return [];
|
|
1797
|
-
}
|
|
1793
|
+
if (this.resolvedPluginConfig.type === "preview") return this.resolvedPluginConfig.workers;
|
|
1794
|
+
return Array.from(this.resolvedPluginConfig.environmentNameToWorkerMap.values()).map((worker) => worker.config);
|
|
1798
1795
|
}
|
|
1799
1796
|
get entryWorkerConfig() {
|
|
1800
1797
|
if (this.resolvedPluginConfig.type !== "workers") return;
|
|
@@ -1931,7 +1928,7 @@ var PATH_TO_DEPLOY_CONFIG = ".wrangler/deploy/config.json";
|
|
|
1931
1928
|
//#region ../workers-utils/dist/chunk-4233U5MA.mjs
|
|
1932
1929
|
function getLocalWorkerdCompatibilityDate({ projectPath = process.cwd() } = {}) {
|
|
1933
1930
|
try {
|
|
1934
|
-
const miniflareEntry = module$1.createRequire(
|
|
1931
|
+
const miniflareEntry = module$1.createRequire(path3.join(projectPath, "package.json")).resolve("miniflare");
|
|
1935
1932
|
const workerdDate = module$1.createRequire(miniflareEntry)("workerd").compatibilityDate;
|
|
1936
1933
|
return {
|
|
1937
1934
|
date: toSafeCompatibilityDate(new Date(workerdDate)),
|
|
@@ -2226,7 +2223,7 @@ __name(constructWranglerConfig, "constructWranglerConfig");
|
|
|
2226
2223
|
|
|
2227
2224
|
//#endregion
|
|
2228
2225
|
//#region ../workers-utils/dist/chunk-AT3LIX2I.mjs
|
|
2229
|
-
var UserError
|
|
2226
|
+
var UserError = class extends Error {
|
|
2230
2227
|
static {
|
|
2231
2228
|
__name(this, "UserError");
|
|
2232
2229
|
}
|
|
@@ -2237,7 +2234,7 @@ var UserError$1 = class extends Error {
|
|
|
2237
2234
|
this.telemetryMessage = options?.telemetryMessage === true ? message : options?.telemetryMessage;
|
|
2238
2235
|
}
|
|
2239
2236
|
};
|
|
2240
|
-
var DeprecationError = class extends UserError
|
|
2237
|
+
var DeprecationError = class extends UserError {
|
|
2241
2238
|
static {
|
|
2242
2239
|
__name(this, "DeprecationError");
|
|
2243
2240
|
}
|
|
@@ -2246,7 +2243,7 @@ var DeprecationError = class extends UserError$1 {
|
|
|
2246
2243
|
${message}`, options);
|
|
2247
2244
|
}
|
|
2248
2245
|
};
|
|
2249
|
-
var FatalError = class extends UserError
|
|
2246
|
+
var FatalError = class extends UserError {
|
|
2250
2247
|
constructor(message, code, options) {
|
|
2251
2248
|
super(message, options);
|
|
2252
2249
|
this.code = code;
|
|
@@ -2255,7 +2252,7 @@ var FatalError = class extends UserError$1 {
|
|
|
2255
2252
|
__name(this, "FatalError");
|
|
2256
2253
|
}
|
|
2257
2254
|
};
|
|
2258
|
-
var CommandLineArgsError = class extends UserError
|
|
2255
|
+
var CommandLineArgsError = class extends UserError {
|
|
2259
2256
|
static {
|
|
2260
2257
|
__name(this, "CommandLineArgsError");
|
|
2261
2258
|
}
|
|
@@ -2981,10 +2978,10 @@ function parseTree(text, errors = [], options = ParseOptions.DEFAULT) {
|
|
|
2981
2978
|
return result;
|
|
2982
2979
|
}
|
|
2983
2980
|
__name(parseTree, "parseTree");
|
|
2984
|
-
function findNodeAtLocation(root, path4
|
|
2981
|
+
function findNodeAtLocation(root, path4) {
|
|
2985
2982
|
if (!root) return;
|
|
2986
2983
|
let node = root;
|
|
2987
|
-
for (let segment of path4
|
|
2984
|
+
for (let segment of path4) if (typeof segment === "string") {
|
|
2988
2985
|
if (node.type !== "object" || !Array.isArray(node.children)) return;
|
|
2989
2986
|
let found = false;
|
|
2990
2987
|
for (const propertyNode of node.children) if (Array.isArray(propertyNode.children) && propertyNode.children[0].value === segment && propertyNode.children.length === 2) {
|
|
@@ -3211,13 +3208,13 @@ function getNodeType(value) {
|
|
|
3211
3208
|
}
|
|
3212
3209
|
__name(getNodeType, "getNodeType");
|
|
3213
3210
|
function setProperty(text, originalPath, value, options) {
|
|
3214
|
-
const path4
|
|
3211
|
+
const path4 = originalPath.slice();
|
|
3215
3212
|
const root = parseTree(text, []);
|
|
3216
3213
|
let parent = void 0;
|
|
3217
3214
|
let lastSegment = void 0;
|
|
3218
|
-
while (path4
|
|
3219
|
-
lastSegment = path4
|
|
3220
|
-
parent = findNodeAtLocation(root, path4
|
|
3215
|
+
while (path4.length > 0) {
|
|
3216
|
+
lastSegment = path4.pop();
|
|
3217
|
+
parent = findNodeAtLocation(root, path4);
|
|
3221
3218
|
if (parent === void 0 && value !== void 0) if (typeof lastSegment === "string") value = { [lastSegment]: value };
|
|
3222
3219
|
else value = [value];
|
|
3223
3220
|
else break;
|
|
@@ -3459,8 +3456,8 @@ function format2(documentText, range, options) {
|
|
|
3459
3456
|
return format$1(documentText, range, options);
|
|
3460
3457
|
}
|
|
3461
3458
|
__name(format2, "format");
|
|
3462
|
-
function modify(text, path4
|
|
3463
|
-
return setProperty(text, path4
|
|
3459
|
+
function modify(text, path4, value, options) {
|
|
3460
|
+
return setProperty(text, path4, value, options);
|
|
3464
3461
|
}
|
|
3465
3462
|
__name(modify, "modify");
|
|
3466
3463
|
function applyEdits(text, edits) {
|
|
@@ -4198,7 +4195,7 @@ var dist_default = {
|
|
|
4198
4195
|
TomlDate,
|
|
4199
4196
|
TomlError
|
|
4200
4197
|
};
|
|
4201
|
-
var ParseError = class extends UserError
|
|
4198
|
+
var ParseError = class extends UserError {
|
|
4202
4199
|
static {
|
|
4203
4200
|
__name(this, "ParseError");
|
|
4204
4201
|
}
|
|
@@ -4507,15 +4504,15 @@ function locatePathSync(paths, { cwd = process2.cwd(), type = "file", allowSymli
|
|
|
4507
4504
|
cwd = toPath(cwd);
|
|
4508
4505
|
const statFunction = allowSymlinks ? fs.statSync : fs.lstatSync;
|
|
4509
4506
|
for (const path_ of paths) try {
|
|
4510
|
-
if (matchType(type, statFunction(
|
|
4507
|
+
if (matchType(type, statFunction(path3.resolve(cwd, path_)))) return path_;
|
|
4511
4508
|
} catch {}
|
|
4512
4509
|
}
|
|
4513
4510
|
__name(locatePathSync, "locatePathSync");
|
|
4514
4511
|
var toPath2 = /* @__PURE__ */ __name((urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath, "toPath");
|
|
4515
4512
|
var findUpStop = Symbol("findUpStop");
|
|
4516
4513
|
function findUpMultipleSync(name, options = {}) {
|
|
4517
|
-
let directory =
|
|
4518
|
-
const { root } =
|
|
4514
|
+
let directory = path3.resolve(toPath2(options.cwd) || "");
|
|
4515
|
+
const { root } = path3.parse(directory);
|
|
4519
4516
|
const stopAt = options.stopAt || root;
|
|
4520
4517
|
const limit = options.limit || Number.POSITIVE_INFINITY;
|
|
4521
4518
|
const paths = [name].flat();
|
|
@@ -4532,9 +4529,9 @@ function findUpMultipleSync(name, options = {}) {
|
|
|
4532
4529
|
cwd: directory
|
|
4533
4530
|
});
|
|
4534
4531
|
if (foundPath === findUpStop) break;
|
|
4535
|
-
if (foundPath) matches.push(
|
|
4532
|
+
if (foundPath) matches.push(path3.resolve(directory, foundPath));
|
|
4536
4533
|
if (directory === stopAt || matches.length >= limit) break;
|
|
4537
|
-
directory =
|
|
4534
|
+
directory = path3.dirname(directory);
|
|
4538
4535
|
}
|
|
4539
4536
|
return matches;
|
|
4540
4537
|
}
|
|
@@ -4587,7 +4584,7 @@ function resolveWranglerConfigPath({ config, script }, options) {
|
|
|
4587
4584
|
deployConfigPath: void 0,
|
|
4588
4585
|
redirected: false
|
|
4589
4586
|
};
|
|
4590
|
-
return findWranglerConfig$1(script !== void 0 ?
|
|
4587
|
+
return findWranglerConfig$1(script !== void 0 ? path3.dirname(script) : process.cwd(), options);
|
|
4591
4588
|
}
|
|
4592
4589
|
__name(resolveWranglerConfigPath, "resolveWranglerConfigPath");
|
|
4593
4590
|
function findWranglerConfig$1(referencePath = process.cwd(), { useRedirectIfAvailable = false } = {}) {
|
|
@@ -4618,26 +4615,26 @@ function findRedirectedWranglerConfig(cwd, userConfigPath) {
|
|
|
4618
4615
|
const deployConfigFile = readFileSync$1(deployConfigPath);
|
|
4619
4616
|
try {
|
|
4620
4617
|
const deployConfig = parseJSONC(deployConfigFile, deployConfigPath);
|
|
4621
|
-
redirectedConfigPath = deployConfig.configPath &&
|
|
4618
|
+
redirectedConfigPath = deployConfig.configPath && path3.resolve(path3.dirname(deployConfigPath), deployConfig.configPath);
|
|
4622
4619
|
} catch (e) {
|
|
4623
|
-
throw new UserError
|
|
4620
|
+
throw new UserError(`Failed to parse the deploy configuration file at ${path3.relative(".", deployConfigPath)}`, { cause: e });
|
|
4624
4621
|
}
|
|
4625
|
-
if (!redirectedConfigPath) throw new UserError
|
|
4626
|
-
A deploy configuration file was found at "${
|
|
4622
|
+
if (!redirectedConfigPath) throw new UserError(esm_default`
|
|
4623
|
+
A deploy configuration file was found at "${path3.relative(".", deployConfigPath)}".
|
|
4627
4624
|
But this is not valid - the required "configPath" property was not found.
|
|
4628
4625
|
Instead this file contains:
|
|
4629
4626
|
\`\`\`
|
|
4630
4627
|
${deployConfigFile}
|
|
4631
4628
|
\`\`\`
|
|
4632
4629
|
`);
|
|
4633
|
-
if (!existsSync(redirectedConfigPath)) throw new UserError
|
|
4634
|
-
There is a deploy configuration at "${
|
|
4635
|
-
But the redirected configuration path it points to, "${
|
|
4630
|
+
if (!existsSync(redirectedConfigPath)) throw new UserError(esm_default`
|
|
4631
|
+
There is a deploy configuration at "${path3.relative(".", deployConfigPath)}".
|
|
4632
|
+
But the redirected configuration path it points to, "${path3.relative(".", redirectedConfigPath)}", does not exist.
|
|
4636
4633
|
`);
|
|
4637
4634
|
if (userConfigPath) {
|
|
4638
|
-
if (
|
|
4639
|
-
Found both a user configuration file at "${
|
|
4640
|
-
and a deploy configuration file at "${
|
|
4635
|
+
if (path3.join(path3.dirname(userConfigPath), PATH_TO_DEPLOY_CONFIG) !== deployConfigPath) throw new UserError(esm_default`
|
|
4636
|
+
Found both a user configuration file at "${path3.relative(".", userConfigPath)}"
|
|
4637
|
+
and a deploy configuration file at "${path3.relative(".", deployConfigPath)}".
|
|
4641
4638
|
But these do not share the same base path so it is not clear which should be used.
|
|
4642
4639
|
`);
|
|
4643
4640
|
}
|
|
@@ -4696,7 +4693,7 @@ var require_XDGAppPaths = __commonJS({ "../../node_modules/.pnpm/xdg-app-paths@8
|
|
|
4696
4693
|
}
|
|
4697
4694
|
__name(typeOf, "typeOf");
|
|
4698
4695
|
function Adapt(adapter_) {
|
|
4699
|
-
var meta = adapter_.meta,
|
|
4696
|
+
var meta = adapter_.meta, path4 = adapter_.path, xdg = adapter_.xdg;
|
|
4700
4697
|
return { XDGAppPaths: new (/* @__PURE__ */ function() {
|
|
4701
4698
|
function XDGAppPaths_2(options_) {
|
|
4702
4699
|
if (options_ === void 0) options_ = {};
|
|
@@ -4714,7 +4711,7 @@ var require_XDGAppPaths = __commonJS({ "../../node_modules/.pnpm/xdg-app-paths@8
|
|
|
4714
4711
|
meta.pkgMainFilename(),
|
|
4715
4712
|
meta.mainFilename()
|
|
4716
4713
|
];
|
|
4717
|
-
var name =
|
|
4714
|
+
var name = path4.parse(((_c = namePriorityList.find(function(e) {
|
|
4718
4715
|
return isString2(e);
|
|
4719
4716
|
})) !== null && _c !== void 0 ? _c : "$eval") + suffix).name;
|
|
4720
4717
|
XDGAppPaths.$name = /* @__PURE__ */ __name(function $name() {
|
|
@@ -4734,28 +4731,28 @@ var require_XDGAppPaths = __commonJS({ "../../node_modules/.pnpm/xdg-app-paths@8
|
|
|
4734
4731
|
}
|
|
4735
4732
|
__name(finalPathSegment, "finalPathSegment");
|
|
4736
4733
|
XDGAppPaths.cache = /* @__PURE__ */ __name(function cache$2(dirOptions) {
|
|
4737
|
-
return
|
|
4734
|
+
return path4.join(xdg.cache(), finalPathSegment(dirOptions));
|
|
4738
4735
|
}, "cache");
|
|
4739
4736
|
XDGAppPaths.config = /* @__PURE__ */ __name(function config(dirOptions) {
|
|
4740
|
-
return
|
|
4737
|
+
return path4.join(xdg.config(), finalPathSegment(dirOptions));
|
|
4741
4738
|
}, "config");
|
|
4742
4739
|
XDGAppPaths.data = /* @__PURE__ */ __name(function data$1(dirOptions) {
|
|
4743
|
-
return
|
|
4740
|
+
return path4.join(xdg.data(), finalPathSegment(dirOptions));
|
|
4744
4741
|
}, "data");
|
|
4745
4742
|
XDGAppPaths.runtime = /* @__PURE__ */ __name(function runtime(dirOptions) {
|
|
4746
|
-
return xdg.runtime() ?
|
|
4743
|
+
return xdg.runtime() ? path4.join(xdg.runtime(), finalPathSegment(dirOptions)) : void 0;
|
|
4747
4744
|
}, "runtime");
|
|
4748
4745
|
XDGAppPaths.state = /* @__PURE__ */ __name(function state(dirOptions) {
|
|
4749
|
-
return
|
|
4746
|
+
return path4.join(xdg.state(), finalPathSegment(dirOptions));
|
|
4750
4747
|
}, "state");
|
|
4751
4748
|
XDGAppPaths.configDirs = /* @__PURE__ */ __name(function configDirs(dirOptions) {
|
|
4752
4749
|
return xdg.configDirs().map(function(s) {
|
|
4753
|
-
return
|
|
4750
|
+
return path4.join(s, finalPathSegment(dirOptions));
|
|
4754
4751
|
});
|
|
4755
4752
|
}, "configDirs");
|
|
4756
4753
|
XDGAppPaths.dataDirs = /* @__PURE__ */ __name(function dataDirs(dirOptions) {
|
|
4757
4754
|
return xdg.dataDirs().map(function(s) {
|
|
4758
|
-
return
|
|
4755
|
+
return path4.join(s, finalPathSegment(dirOptions));
|
|
4759
4756
|
});
|
|
4760
4757
|
}, "dataDirs");
|
|
4761
4758
|
return XDGAppPaths;
|
|
@@ -4775,7 +4772,7 @@ var require_XDG = __commonJS({ "../../node_modules/.pnpm/xdg-portable@10.6.0/nod
|
|
|
4775
4772
|
exports$1.__esModule = true;
|
|
4776
4773
|
exports$1.Adapt = void 0;
|
|
4777
4774
|
function Adapt(adapter_) {
|
|
4778
|
-
var env$1 = adapter_.env, osPaths = adapter_.osPaths,
|
|
4775
|
+
var env$1 = adapter_.env, osPaths = adapter_.osPaths, path4 = adapter_.path;
|
|
4779
4776
|
var isMacOS = /^darwin$/i.test(adapter_.process.platform);
|
|
4780
4777
|
var isWinOS = /^win/i.test(adapter_.process.platform);
|
|
4781
4778
|
function baseDir() {
|
|
@@ -4783,7 +4780,7 @@ var require_XDG = __commonJS({ "../../node_modules/.pnpm/xdg-portable@10.6.0/nod
|
|
|
4783
4780
|
}
|
|
4784
4781
|
__name(baseDir, "baseDir");
|
|
4785
4782
|
function valOrPath(val, pathSegments) {
|
|
4786
|
-
return val ||
|
|
4783
|
+
return val || path4.join.apply(path4, pathSegments);
|
|
4787
4784
|
}
|
|
4788
4785
|
__name(valOrPath, "valOrPath");
|
|
4789
4786
|
var linux = /* @__PURE__ */ __name(function() {
|
|
@@ -4897,11 +4894,11 @@ var require_XDG = __commonJS({ "../../node_modules/.pnpm/xdg-portable@10.6.0/nod
|
|
|
4897
4894
|
XDG.state = extension.state;
|
|
4898
4895
|
XDG.configDirs = /* @__PURE__ */ __name(function configDirs() {
|
|
4899
4896
|
var pathList = env$1.get("XDG_CONFIG_DIRS");
|
|
4900
|
-
return __spreadArray([extension.config()], pathList ? pathList.split(
|
|
4897
|
+
return __spreadArray([extension.config()], pathList ? pathList.split(path4.delimiter) : []);
|
|
4901
4898
|
}, "configDirs");
|
|
4902
4899
|
XDG.dataDirs = /* @__PURE__ */ __name(function dataDirs() {
|
|
4903
4900
|
var pathList = env$1.get("XDG_DATA_DIRS");
|
|
4904
|
-
return __spreadArray([extension.data()], pathList ? pathList.split(
|
|
4901
|
+
return __spreadArray([extension.data()], pathList ? pathList.split(path4.delimiter) : []);
|
|
4905
4902
|
}, "dataDirs");
|
|
4906
4903
|
return XDG;
|
|
4907
4904
|
}
|
|
@@ -4924,7 +4921,7 @@ var require_OSPaths = __commonJS({ "../../node_modules/.pnpm/os-paths@7.4.0/node
|
|
|
4924
4921
|
}
|
|
4925
4922
|
__name(isEmpty, "isEmpty");
|
|
4926
4923
|
function Adapt(adapter_) {
|
|
4927
|
-
var env$1 = adapter_.env, os2 = adapter_.os,
|
|
4924
|
+
var env$1 = adapter_.env, os2 = adapter_.os, path4 = adapter_.path;
|
|
4928
4925
|
var isWinOS = /^win/i.test(adapter_.process.platform);
|
|
4929
4926
|
function normalizePath$1(path_) {
|
|
4930
4927
|
return path_ ? adapter_.path.normalize(adapter_.path.join(path_, ".")) : void 0;
|
|
@@ -4936,7 +4933,7 @@ var require_OSPaths = __commonJS({ "../../node_modules/.pnpm/os-paths@7.4.0/node
|
|
|
4936
4933
|
typeof os2.homedir === "function" ? os2.homedir() : void 0,
|
|
4937
4934
|
env$1.get("USERPROFILE"),
|
|
4938
4935
|
env$1.get("HOME"),
|
|
4939
|
-
env$1.get("HOMEDRIVE") || env$1.get("HOMEPATH") ?
|
|
4936
|
+
env$1.get("HOMEDRIVE") || env$1.get("HOMEPATH") ? path4.join(env$1.get("HOMEDRIVE") || "", env$1.get("HOMEPATH") || "") : void 0
|
|
4940
4937
|
].find(function(v) {
|
|
4941
4938
|
return !isEmpty(v);
|
|
4942
4939
|
}));
|
|
@@ -4947,7 +4944,7 @@ var require_OSPaths = __commonJS({ "../../node_modules/.pnpm/os-paths@7.4.0/node
|
|
|
4947
4944
|
__name(home, "home");
|
|
4948
4945
|
function temp() {
|
|
4949
4946
|
function joinPathToBase(base, segments) {
|
|
4950
|
-
return base ?
|
|
4947
|
+
return base ? path4.join.apply(path4, __spreadArray([base], segments)) : void 0;
|
|
4951
4948
|
}
|
|
4952
4949
|
__name(joinPathToBase, "joinPathToBase");
|
|
4953
4950
|
function posix$1() {
|
|
@@ -5052,14 +5049,14 @@ var require_node = __commonJS({ "../../node_modules/.pnpm/os-paths@7.4.0/node_mo
|
|
|
5052
5049
|
exports$1.__esModule = true;
|
|
5053
5050
|
exports$1.adapter = void 0;
|
|
5054
5051
|
var os2 = __importStar$1(__require("os"));
|
|
5055
|
-
var
|
|
5052
|
+
var path4 = __importStar$1(__require("path"));
|
|
5056
5053
|
exports$1.adapter = {
|
|
5057
5054
|
atImportPermissions: { env: true },
|
|
5058
5055
|
env: { get: /* @__PURE__ */ __name(function(s) {
|
|
5059
5056
|
return process.env[s];
|
|
5060
5057
|
}, "get") },
|
|
5061
5058
|
os: os2,
|
|
5062
|
-
path:
|
|
5059
|
+
path: path4,
|
|
5063
5060
|
process
|
|
5064
5061
|
};
|
|
5065
5062
|
} });
|
|
@@ -5103,7 +5100,7 @@ var require_node2 = __commonJS({ "../../node_modules/.pnpm/xdg-portable@10.6.0/n
|
|
|
5103
5100
|
};
|
|
5104
5101
|
exports$1.__esModule = true;
|
|
5105
5102
|
exports$1.adapter = void 0;
|
|
5106
|
-
var
|
|
5103
|
+
var path4 = __importStar$1(__require("path"));
|
|
5107
5104
|
var os_paths_1 = __importDefault$2(require_mod_cjs());
|
|
5108
5105
|
exports$1.adapter = {
|
|
5109
5106
|
atImportPermissions: { env: true },
|
|
@@ -5111,7 +5108,7 @@ var require_node2 = __commonJS({ "../../node_modules/.pnpm/xdg-portable@10.6.0/n
|
|
|
5111
5108
|
return process.env[s];
|
|
5112
5109
|
}, "get") },
|
|
5113
5110
|
osPaths: os_paths_1["default"],
|
|
5114
|
-
path:
|
|
5111
|
+
path: path4,
|
|
5115
5112
|
process
|
|
5116
5113
|
};
|
|
5117
5114
|
} });
|
|
@@ -5155,7 +5152,7 @@ var require_node3 = __commonJS({ "../../node_modules/.pnpm/xdg-app-paths@8.3.0/n
|
|
|
5155
5152
|
};
|
|
5156
5153
|
exports$1.__esModule = true;
|
|
5157
5154
|
exports$1.adapter = void 0;
|
|
5158
|
-
var
|
|
5155
|
+
var path4 = __importStar$1(__require("path"));
|
|
5159
5156
|
var xdg_portable_1 = __importDefault$2(require_mod_cjs2());
|
|
5160
5157
|
exports$1.adapter = {
|
|
5161
5158
|
atImportPermissions: {
|
|
@@ -5171,7 +5168,7 @@ var require_node3 = __commonJS({ "../../node_modules/.pnpm/xdg-app-paths@8.3.0/n
|
|
|
5171
5168
|
return process.pkg ? process.execPath : void 0;
|
|
5172
5169
|
}, "pkgMainFilename")
|
|
5173
5170
|
},
|
|
5174
|
-
path:
|
|
5171
|
+
path: path4,
|
|
5175
5172
|
process,
|
|
5176
5173
|
xdg: xdg_portable_1["default"]
|
|
5177
5174
|
};
|
|
@@ -5284,174 +5281,6 @@ var PatchConfigError = class extends Error {
|
|
|
5284
5281
|
__name(this, "PatchConfigError");
|
|
5285
5282
|
}
|
|
5286
5283
|
};
|
|
5287
|
-
var ApplicationRollout$1;
|
|
5288
|
-
((ApplicationRollout2) => {
|
|
5289
|
-
((kind2) => {
|
|
5290
|
-
kind2["FULL_AUTO"] = "full_auto";
|
|
5291
|
-
kind2["FULL_MANUAL"] = "full_manual";
|
|
5292
|
-
kind2["DURABLE_OBJECTS_AUTO"] = "durable_objects_auto";
|
|
5293
|
-
})(ApplicationRollout2.kind || (ApplicationRollout2.kind = {}));
|
|
5294
|
-
((strategy2) => {
|
|
5295
|
-
strategy2["ROLLING"] = "rolling";
|
|
5296
|
-
})(ApplicationRollout2.strategy || (ApplicationRollout2.strategy = {}));
|
|
5297
|
-
((status2) => {
|
|
5298
|
-
status2["PENDING"] = "pending";
|
|
5299
|
-
status2["PROGRESSING"] = "progressing";
|
|
5300
|
-
status2["COMPLETED"] = "completed";
|
|
5301
|
-
status2["REVERTED"] = "reverted";
|
|
5302
|
-
status2["REPLACED"] = "replaced";
|
|
5303
|
-
})(ApplicationRollout2.status || (ApplicationRollout2.status = {}));
|
|
5304
|
-
})(ApplicationRollout$1 || (ApplicationRollout$1 = {}));
|
|
5305
|
-
var BadRequestWithCodeError$1;
|
|
5306
|
-
((BadRequestWithCodeError2) => {
|
|
5307
|
-
((error2) => {
|
|
5308
|
-
error2["VALIDATE_INPUT"] = "VALIDATE_INPUT";
|
|
5309
|
-
})(BadRequestWithCodeError2.error || (BadRequestWithCodeError2.error = {}));
|
|
5310
|
-
})(BadRequestWithCodeError$1 || (BadRequestWithCodeError$1 = {}));
|
|
5311
|
-
var CreateApplicationRolloutRequest$1;
|
|
5312
|
-
((CreateApplicationRolloutRequest2) => {
|
|
5313
|
-
((strategy2) => {
|
|
5314
|
-
strategy2["ROLLING"] = "rolling";
|
|
5315
|
-
})(CreateApplicationRolloutRequest2.strategy || (CreateApplicationRolloutRequest2.strategy = {}));
|
|
5316
|
-
((step_percentage2) => {
|
|
5317
|
-
step_percentage2[step_percentage2["_5"] = 5] = "_5";
|
|
5318
|
-
step_percentage2[step_percentage2["_10"] = 10] = "_10";
|
|
5319
|
-
step_percentage2[step_percentage2["_20"] = 20] = "_20";
|
|
5320
|
-
step_percentage2[step_percentage2["_25"] = 25] = "_25";
|
|
5321
|
-
step_percentage2[step_percentage2["_50"] = 50] = "_50";
|
|
5322
|
-
step_percentage2[step_percentage2["_100"] = 100] = "_100";
|
|
5323
|
-
})(CreateApplicationRolloutRequest2.step_percentage || (CreateApplicationRolloutRequest2.step_percentage = {}));
|
|
5324
|
-
((kind2) => {
|
|
5325
|
-
kind2["FULL_AUTO"] = "full_auto";
|
|
5326
|
-
kind2["FULL_MANUAL"] = "full_manual";
|
|
5327
|
-
})(CreateApplicationRolloutRequest2.kind || (CreateApplicationRolloutRequest2.kind = {}));
|
|
5328
|
-
})(CreateApplicationRolloutRequest$1 || (CreateApplicationRolloutRequest$1 = {}));
|
|
5329
|
-
var DeploymentNotFoundError$1;
|
|
5330
|
-
((DeploymentNotFoundError2) => {
|
|
5331
|
-
((error2) => {
|
|
5332
|
-
error2["DEPLOYMENT_NOT_FOUND"] = "DEPLOYMENT_NOT_FOUND";
|
|
5333
|
-
})(DeploymentNotFoundError2.error || (DeploymentNotFoundError2.error = {}));
|
|
5334
|
-
})(DeploymentNotFoundError$1 || (DeploymentNotFoundError$1 = {}));
|
|
5335
|
-
var ImageRegistryAlreadyExistsError$1;
|
|
5336
|
-
((ImageRegistryAlreadyExistsError2) => {
|
|
5337
|
-
((error2) => {
|
|
5338
|
-
error2["IMAGE_REGISTRY_ALREADY_EXISTS"] = "IMAGE_REGISTRY_ALREADY_EXISTS";
|
|
5339
|
-
})(ImageRegistryAlreadyExistsError2.error || (ImageRegistryAlreadyExistsError2.error = {}));
|
|
5340
|
-
})(ImageRegistryAlreadyExistsError$1 || (ImageRegistryAlreadyExistsError$1 = {}));
|
|
5341
|
-
var ImageRegistryIsPublic$1;
|
|
5342
|
-
((ImageRegistryIsPublic2) => {
|
|
5343
|
-
((error2) => {
|
|
5344
|
-
error2["IMAGE_REGISTRY_IS_PUBLIC"] = "IMAGE_REGISTRY_IS_PUBLIC";
|
|
5345
|
-
})(ImageRegistryIsPublic2.error || (ImageRegistryIsPublic2.error = {}));
|
|
5346
|
-
})(ImageRegistryIsPublic$1 || (ImageRegistryIsPublic$1 = {}));
|
|
5347
|
-
var ImageRegistryNotAllowedError$1;
|
|
5348
|
-
((ImageRegistryNotAllowedError2) => {
|
|
5349
|
-
((error2) => {
|
|
5350
|
-
error2["IMAGE_REGISTRY_NOT_ALLOWED"] = "IMAGE_REGISTRY_NOT_ALLOWED";
|
|
5351
|
-
})(ImageRegistryNotAllowedError2.error || (ImageRegistryNotAllowedError2.error = {}));
|
|
5352
|
-
})(ImageRegistryNotAllowedError$1 || (ImageRegistryNotAllowedError$1 = {}));
|
|
5353
|
-
var ImageRegistryNotFoundError$1;
|
|
5354
|
-
((ImageRegistryNotFoundError2) => {
|
|
5355
|
-
((error2) => {
|
|
5356
|
-
error2["IMAGE_REGISTRY_NOT_FOUND"] = "IMAGE_REGISTRY_NOT_FOUND";
|
|
5357
|
-
})(ImageRegistryNotFoundError2.error || (ImageRegistryNotFoundError2.error = {}));
|
|
5358
|
-
})(ImageRegistryNotFoundError$1 || (ImageRegistryNotFoundError$1 = {}));
|
|
5359
|
-
var ImageRegistryProtocolAlreadyExists$1;
|
|
5360
|
-
((ImageRegistryProtocolAlreadyExists2) => {
|
|
5361
|
-
((error2) => {
|
|
5362
|
-
error2["IMAGE_REGISTRY_PROTOCOL_ALREADY_EXISTS"] = "IMAGE_REGISTRY_PROTOCOL_ALREADY_EXISTS";
|
|
5363
|
-
})(ImageRegistryProtocolAlreadyExists2.error || (ImageRegistryProtocolAlreadyExists2.error = {}));
|
|
5364
|
-
})(ImageRegistryProtocolAlreadyExists$1 || (ImageRegistryProtocolAlreadyExists$1 = {}));
|
|
5365
|
-
var ImageRegistryProtocolIsReferencedError$1;
|
|
5366
|
-
((ImageRegistryProtocolIsReferencedError2) => {
|
|
5367
|
-
((error2) => {
|
|
5368
|
-
error2["IMAGE_REGISTRY_PROTO_IS_REFERENCED"] = "IMAGE_REGISTRY_PROTO_IS_REFERENCED";
|
|
5369
|
-
})(ImageRegistryProtocolIsReferencedError2.error || (ImageRegistryProtocolIsReferencedError2.error = {}));
|
|
5370
|
-
})(ImageRegistryProtocolIsReferencedError$1 || (ImageRegistryProtocolIsReferencedError$1 = {}));
|
|
5371
|
-
var ImageRegistryProtocolNotFound$1;
|
|
5372
|
-
((ImageRegistryProtocolNotFound2) => {
|
|
5373
|
-
((error2) => {
|
|
5374
|
-
error2["IMAGE_REGISTRY_PROTOCOL_NOT_FOUND"] = "IMAGE_REGISTRY_PROTOCOL_NOT_FOUND";
|
|
5375
|
-
})(ImageRegistryProtocolNotFound2.error || (ImageRegistryProtocolNotFound2.error = {}));
|
|
5376
|
-
})(ImageRegistryProtocolNotFound$1 || (ImageRegistryProtocolNotFound$1 = {}));
|
|
5377
|
-
var ProvisionerConfiguration$1;
|
|
5378
|
-
((ProvisionerConfiguration2) => {
|
|
5379
|
-
((type2) => {
|
|
5380
|
-
type2["NONE"] = "none";
|
|
5381
|
-
type2["CLOUDINIT"] = "cloudinit";
|
|
5382
|
-
})(ProvisionerConfiguration2.type || (ProvisionerConfiguration2.type = {}));
|
|
5383
|
-
})(ProvisionerConfiguration$1 || (ProvisionerConfiguration$1 = {}));
|
|
5384
|
-
var RolloutStep$1;
|
|
5385
|
-
((RolloutStep2) => {
|
|
5386
|
-
((status2) => {
|
|
5387
|
-
status2["PENDING"] = "pending";
|
|
5388
|
-
status2["PROGRESSING"] = "progressing";
|
|
5389
|
-
status2["REVERTING"] = "reverting";
|
|
5390
|
-
status2["COMPLETED"] = "completed";
|
|
5391
|
-
status2["REVERTED"] = "reverted";
|
|
5392
|
-
})(RolloutStep2.status || (RolloutStep2.status = {}));
|
|
5393
|
-
})(RolloutStep$1 || (RolloutStep$1 = {}));
|
|
5394
|
-
var SecretNameAlreadyExists$1;
|
|
5395
|
-
((SecretNameAlreadyExists2) => {
|
|
5396
|
-
((error2) => {
|
|
5397
|
-
error2["SECRET_NAME_ALREADY_EXISTS"] = "SECRET_NAME_ALREADY_EXISTS";
|
|
5398
|
-
})(SecretNameAlreadyExists2.error || (SecretNameAlreadyExists2.error = {}));
|
|
5399
|
-
})(SecretNameAlreadyExists$1 || (SecretNameAlreadyExists$1 = {}));
|
|
5400
|
-
var SecretNotFound$1;
|
|
5401
|
-
((SecretNotFound2) => {
|
|
5402
|
-
((error2) => {
|
|
5403
|
-
error2["SECRET_NAME_NOT_FOUND"] = "SECRET_NAME_NOT_FOUND";
|
|
5404
|
-
})(SecretNotFound2.error || (SecretNotFound2.error = {}));
|
|
5405
|
-
})(SecretNotFound$1 || (SecretNotFound$1 = {}));
|
|
5406
|
-
var SSHPublicKeyNotFoundError$1;
|
|
5407
|
-
((SSHPublicKeyNotFoundError2) => {
|
|
5408
|
-
((error2) => {
|
|
5409
|
-
error2["SSH_PUBLIC_KEY_NOT_FOUND"] = "SSH_PUBLIC_KEY_NOT_FOUND";
|
|
5410
|
-
})(SSHPublicKeyNotFoundError2.error || (SSHPublicKeyNotFoundError2.error = {}));
|
|
5411
|
-
})(SSHPublicKeyNotFoundError$1 || (SSHPublicKeyNotFoundError$1 = {}));
|
|
5412
|
-
var UpdateApplicationRolloutRequest$1;
|
|
5413
|
-
((UpdateApplicationRolloutRequest2) => {
|
|
5414
|
-
((action2) => {
|
|
5415
|
-
action2["NEXT"] = "next";
|
|
5416
|
-
action2["PREVIOUS"] = "previous";
|
|
5417
|
-
action2["REVERT"] = "revert";
|
|
5418
|
-
})(UpdateApplicationRolloutRequest2.action || (UpdateApplicationRolloutRequest2.action = {}));
|
|
5419
|
-
})(UpdateApplicationRolloutRequest$1 || (UpdateApplicationRolloutRequest$1 = {}));
|
|
5420
|
-
var UserError2 = class extends Error {
|
|
5421
|
-
static {
|
|
5422
|
-
__name(this, "UserError");
|
|
5423
|
-
}
|
|
5424
|
-
telemetryMessage;
|
|
5425
|
-
constructor(message, options) {
|
|
5426
|
-
super(message, options);
|
|
5427
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
5428
|
-
this.telemetryMessage = options?.telemetryMessage === true ? message : options?.telemetryMessage;
|
|
5429
|
-
}
|
|
5430
|
-
};
|
|
5431
|
-
function isDir$1(inputPath) {
|
|
5432
|
-
return statSync(inputPath).isDirectory();
|
|
5433
|
-
}
|
|
5434
|
-
__name(isDir$1, "isDir");
|
|
5435
|
-
var isDockerfile$1 = /* @__PURE__ */ __name((image, configPath) => {
|
|
5436
|
-
const baseDir = configPath ? path4.dirname(configPath) : process.cwd();
|
|
5437
|
-
const maybeDockerfile = path4.resolve(baseDir, image);
|
|
5438
|
-
if (existsSync(maybeDockerfile)) {
|
|
5439
|
-
if (isDir$1(maybeDockerfile)) throw new UserError2(`${image} is a directory, you should specify a path to the Dockerfile`);
|
|
5440
|
-
return true;
|
|
5441
|
-
}
|
|
5442
|
-
const errorPrefix = `The image "${image}" does not appear to be a valid path to a Dockerfile, or a valid image registry path:
|
|
5443
|
-
`;
|
|
5444
|
-
try {
|
|
5445
|
-
new URL(`https://${image}`);
|
|
5446
|
-
} catch (e) {
|
|
5447
|
-
if (e instanceof Error) throw new UserError2(errorPrefix + e.message);
|
|
5448
|
-
throw e;
|
|
5449
|
-
}
|
|
5450
|
-
const imageParts = image.split("/");
|
|
5451
|
-
if (!imageParts[imageParts.length - 1]?.includes(":")) throw new UserError2(errorPrefix + `If this is an image registry path, it needs to include at least a tag ':' (e.g: docker.io/httpd:1)`);
|
|
5452
|
-
if (image.includes("://")) throw new UserError2(errorPrefix + `Image reference should not include the protocol part (e.g: docker.io/httpd:1, not https://docker.io/httpd:1)`);
|
|
5453
|
-
return false;
|
|
5454
|
-
}, "isDockerfile");
|
|
5455
5284
|
var MAX_WORKFLOW_NAME_LENGTH = 64;
|
|
5456
5285
|
var ALLOWED_WORKFLOW_NAME_REGEX = new RegExp("^[a-zA-Z0-9_][a-zA-Z0-9-_]*$");
|
|
5457
5286
|
function isValidWorkflowName(name) {
|
|
@@ -5465,9 +5294,9 @@ __export(mod_esm_exports, { default: () => mod_esm_default });
|
|
|
5465
5294
|
var import_mod_cjs = __toESM(require_mod_cjs3(), 1);
|
|
5466
5295
|
__reExport(mod_esm_exports, __toESM(require_mod_cjs3(), 1));
|
|
5467
5296
|
var mod_esm_default = import_mod_cjs.default;
|
|
5468
|
-
function isDirectory(
|
|
5297
|
+
function isDirectory(path4) {
|
|
5469
5298
|
try {
|
|
5470
|
-
return fs.statSync(
|
|
5299
|
+
return fs.statSync(path4).isDirectory();
|
|
5471
5300
|
} catch {
|
|
5472
5301
|
return false;
|
|
5473
5302
|
}
|
|
@@ -5475,7 +5304,7 @@ function isDirectory(configPath) {
|
|
|
5475
5304
|
__name(isDirectory, "isDirectory");
|
|
5476
5305
|
function getGlobalWranglerConfigPath() {
|
|
5477
5306
|
const configDir = mod_esm_default(".wrangler").config();
|
|
5478
|
-
const legacyConfigDir =
|
|
5307
|
+
const legacyConfigDir = path3.join(os.homedir(), ".wrangler");
|
|
5479
5308
|
if (isDirectory(legacyConfigDir)) return legacyConfigDir;
|
|
5480
5309
|
else return configDir;
|
|
5481
5310
|
}
|
|
@@ -5486,7 +5315,7 @@ function getBooleanEnvironmentVariableFactory(options) {
|
|
|
5486
5315
|
switch (process.env[options.variableName]?.toLowerCase()) {
|
|
5487
5316
|
case "true": return true;
|
|
5488
5317
|
case "false": return false;
|
|
5489
|
-
default: throw new UserError
|
|
5318
|
+
default: throw new UserError(`Expected ${options.variableName} to be "true" or "false", but got ${JSON.stringify(process.env[options.variableName])}`);
|
|
5490
5319
|
}
|
|
5491
5320
|
};
|
|
5492
5321
|
}
|
|
@@ -5512,7 +5341,7 @@ function getProcessEnv(variableName, choices) {
|
|
|
5512
5341
|
}
|
|
5513
5342
|
__name(getProcessEnv, "getProcessEnv");
|
|
5514
5343
|
function assertOneOf(choices, value) {
|
|
5515
|
-
if (Array.isArray(choices) && !choices.includes(value)) throw new UserError
|
|
5344
|
+
if (Array.isArray(choices) && !choices.includes(value)) throw new UserError(`Expected ${JSON.stringify(value)} to be one of ${JSON.stringify(choices)}`);
|
|
5516
5345
|
}
|
|
5517
5346
|
__name(assertOneOf, "assertOneOf");
|
|
5518
5347
|
var getC3CommandFromEnv = getEnvironmentVariableFactory({
|
|
@@ -5532,7 +5361,7 @@ var getCloudflareComplianceRegionFromEnv = getEnvironmentVariableFactory({
|
|
|
5532
5361
|
});
|
|
5533
5362
|
var getCloudflareComplianceRegion = /* @__PURE__ */ __name((complianceConfig) => {
|
|
5534
5363
|
const complianceRegionFromEnv = getCloudflareComplianceRegionFromEnv();
|
|
5535
|
-
if (complianceRegionFromEnv !== void 0 && complianceConfig?.compliance_region !== void 0 && complianceRegionFromEnv !== complianceConfig.compliance_region) throw new UserError
|
|
5364
|
+
if (complianceRegionFromEnv !== void 0 && complianceConfig?.compliance_region !== void 0 && complianceRegionFromEnv !== complianceConfig.compliance_region) throw new UserError(dedent`
|
|
5536
5365
|
The compliance region has been set to different values in two places:
|
|
5537
5366
|
- \`CLOUDFLARE_COMPLIANCE_REGION\` environment variable: \`${complianceRegionFromEnv}\`
|
|
5538
5367
|
- \`compliance_region\` configuration property: \`${complianceConfig.compliance_region}\`
|
|
@@ -5571,7 +5400,7 @@ var getBuildPlatformFromEnv = getEnvironmentVariableFactory({ variableName: "WRA
|
|
|
5571
5400
|
var getRegistryPath = getEnvironmentVariableFactory({
|
|
5572
5401
|
variableName: "WRANGLER_REGISTRY_PATH",
|
|
5573
5402
|
defaultValue() {
|
|
5574
|
-
return
|
|
5403
|
+
return path3.join(getGlobalWranglerConfigPath(), "registry");
|
|
5575
5404
|
}
|
|
5576
5405
|
});
|
|
5577
5406
|
var getD1ExtraLocationChoices = getEnvironmentVariableFactory({ variableName: "WRANGLER_D1_EXTRA_LOCATION_CHOICES" });
|
|
@@ -5695,9 +5524,9 @@ Please add "${field}" to "env.${envName}".`);
|
|
|
5695
5524
|
return rawEnv[field] ?? defaultValue;
|
|
5696
5525
|
}
|
|
5697
5526
|
__name(notInheritable, "notInheritable");
|
|
5698
|
-
function unwindPropertyPath(root,
|
|
5527
|
+
function unwindPropertyPath(root, path4) {
|
|
5699
5528
|
let container = root;
|
|
5700
|
-
const parts =
|
|
5529
|
+
const parts = path4.split(".");
|
|
5701
5530
|
for (let i$1 = 0; i$1 < parts.length - 1; i$1++) {
|
|
5702
5531
|
if (!hasProperty(container, parts[i$1])) return;
|
|
5703
5532
|
container = container[parts[i$1]];
|
|
@@ -5910,7 +5739,7 @@ function isPagesConfig(rawConfig) {
|
|
|
5910
5739
|
}
|
|
5911
5740
|
__name(isPagesConfig, "isPagesConfig");
|
|
5912
5741
|
function normalizeAndValidateConfig(rawConfig, configPath, userConfigPath, args, preserveOriginalMain = false) {
|
|
5913
|
-
const diagnostics = new Diagnostics(`Processing ${configPath ?
|
|
5742
|
+
const diagnostics = new Diagnostics(`Processing ${configPath ? path3.relative(process.cwd(), configPath) : "wrangler"} configuration:`);
|
|
5914
5743
|
validateOptionalProperty(diagnostics, "", "legacy_env", rawConfig.legacy_env, "boolean");
|
|
5915
5744
|
validateOptionalProperty(diagnostics, "", "send_metrics", rawConfig.send_metrics, "boolean");
|
|
5916
5745
|
validateOptionalProperty(diagnostics, "", "keep_vars", rawConfig.keep_vars, "boolean");
|
|
@@ -6001,7 +5830,7 @@ function applyPythonConfig(config, args) {
|
|
|
6001
5830
|
type: "PythonModule",
|
|
6002
5831
|
globs: ["**/*.py"]
|
|
6003
5832
|
});
|
|
6004
|
-
if (!config.compatibility_flags.includes("python_workers")) throw new UserError
|
|
5833
|
+
if (!config.compatibility_flags.includes("python_workers")) throw new UserError("The `python_workers` compatibility flag is required to use Python.");
|
|
6005
5834
|
}
|
|
6006
5835
|
}
|
|
6007
5836
|
__name(applyPythonConfig, "applyPythonConfig");
|
|
@@ -6014,34 +5843,34 @@ function normalizeAndValidateBuild(diagnostics, rawEnv, rawBuild, configPath) {
|
|
|
6014
5843
|
else validateOptionalProperty(diagnostics, "build", "watch_dir", watch_dir, "string");
|
|
6015
5844
|
return {
|
|
6016
5845
|
command,
|
|
6017
|
-
watch_dir: command && configPath ? Array.isArray(watch_dir) ? watch_dir.map((dir) =>
|
|
5846
|
+
watch_dir: command && configPath ? Array.isArray(watch_dir) ? watch_dir.map((dir) => path3.relative(process.cwd(), path3.join(path3.dirname(configPath), `${dir}`))) : path3.relative(process.cwd(), path3.join(path3.dirname(configPath), `${watch_dir}`)) : watch_dir,
|
|
6018
5847
|
cwd
|
|
6019
5848
|
};
|
|
6020
5849
|
}
|
|
6021
5850
|
__name(normalizeAndValidateBuild, "normalizeAndValidateBuild");
|
|
6022
5851
|
function normalizeAndValidateMainField(configPath, rawMain) {
|
|
6023
|
-
const configDir =
|
|
5852
|
+
const configDir = path3.dirname(configPath ?? "wrangler.toml");
|
|
6024
5853
|
if (rawMain !== void 0) if (typeof rawMain === "string") {
|
|
6025
|
-
const directory =
|
|
6026
|
-
return
|
|
5854
|
+
const directory = path3.resolve(configDir);
|
|
5855
|
+
return path3.resolve(directory, rawMain);
|
|
6027
5856
|
} else return rawMain;
|
|
6028
5857
|
else return;
|
|
6029
5858
|
}
|
|
6030
5859
|
__name(normalizeAndValidateMainField, "normalizeAndValidateMainField");
|
|
6031
5860
|
function normalizeAndValidateBaseDirField(configPath, rawDir) {
|
|
6032
|
-
const configDir =
|
|
5861
|
+
const configDir = path3.dirname(configPath ?? "wrangler.toml");
|
|
6033
5862
|
if (rawDir !== void 0) if (typeof rawDir === "string") {
|
|
6034
|
-
const directory =
|
|
6035
|
-
return
|
|
5863
|
+
const directory = path3.resolve(configDir);
|
|
5864
|
+
return path3.resolve(directory, rawDir);
|
|
6036
5865
|
} else return rawDir;
|
|
6037
5866
|
else return;
|
|
6038
5867
|
}
|
|
6039
5868
|
__name(normalizeAndValidateBaseDirField, "normalizeAndValidateBaseDirField");
|
|
6040
5869
|
function normalizeAndValidatePagesBuildOutputDir(configPath, rawPagesDir) {
|
|
6041
|
-
const configDir =
|
|
5870
|
+
const configDir = path3.dirname(configPath ?? "wrangler.toml");
|
|
6042
5871
|
if (rawPagesDir !== void 0) if (typeof rawPagesDir === "string") {
|
|
6043
|
-
const directory =
|
|
6044
|
-
return
|
|
5872
|
+
const directory = path3.resolve(configDir);
|
|
5873
|
+
return path3.resolve(directory, rawPagesDir);
|
|
6045
5874
|
} else return rawPagesDir;
|
|
6046
5875
|
else return;
|
|
6047
5876
|
}
|
|
@@ -6094,7 +5923,7 @@ function normalizeAndValidateSite(diagnostics, configPath, rawConfig, mainEntryP
|
|
|
6094
5923
|
validateOptionalProperty(diagnostics, "site", "entry-point", rawConfig.site["entry-point"], "string");
|
|
6095
5924
|
deprecated(diagnostics, rawConfig, `site.entry-point`, `Delete the \`site.entry-point\` field, then add the top level \`main\` field to your configuration file:
|
|
6096
5925
|
\`\`\`
|
|
6097
|
-
main = "${
|
|
5926
|
+
main = "${path3.join(String(rawConfig.site["entry-point"]) || "workers-site", path3.extname(String(rawConfig.site["entry-point"]) || "workers-site") ? "" : "index.js")}"
|
|
6098
5927
|
\`\`\``, false, void 0, "warning");
|
|
6099
5928
|
let siteEntryPoint = rawConfig.site["entry-point"];
|
|
6100
5929
|
if (!mainEntryPoint && !siteEntryPoint) {
|
|
@@ -6107,7 +5936,7 @@ main = "workers-site/index.js"
|
|
|
6107
5936
|
} else if (mainEntryPoint && siteEntryPoint) diagnostics.errors.push(`Don't define both the \`main\` and \`site.entry-point\` fields in your configuration.
|
|
6108
5937
|
They serve the same purpose: to point to the entry-point of your worker.
|
|
6109
5938
|
Delete the deprecated \`site.entry-point\` field from your config.`);
|
|
6110
|
-
if (configPath && siteEntryPoint) siteEntryPoint =
|
|
5939
|
+
if (configPath && siteEntryPoint) siteEntryPoint = path3.relative(process.cwd(), path3.join(path3.dirname(configPath), siteEntryPoint));
|
|
6111
5940
|
return {
|
|
6112
5941
|
bucket,
|
|
6113
5942
|
"entry-point": siteEntryPoint,
|
|
@@ -6139,7 +5968,7 @@ function normalizeAndValidateModulePaths(diagnostics, configPath, field, rawMapp
|
|
|
6139
5968
|
if (rawMapping === void 0) return;
|
|
6140
5969
|
const mapping = {};
|
|
6141
5970
|
for (const [name, filePath] of Object.entries(rawMapping)) if (isString$2(diagnostics, `${field}['${name}']`, filePath, void 0)) {
|
|
6142
|
-
if (configPath) mapping[name] = configPath ?
|
|
5971
|
+
if (configPath) mapping[name] = configPath ? path3.relative(process.cwd(), path3.join(path3.dirname(configPath), filePath)) : filePath;
|
|
6143
5972
|
}
|
|
6144
5973
|
return mapping;
|
|
6145
5974
|
}
|
|
@@ -6369,7 +6198,7 @@ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, isDisp
|
|
|
6369
6198
|
__name(normalizeAndValidateEnvironment, "normalizeAndValidateEnvironment");
|
|
6370
6199
|
function validateAndNormalizeTsconfig(diagnostics, topLevelEnv, rawEnv, configPath) {
|
|
6371
6200
|
const tsconfig = inheritable(diagnostics, topLevelEnv, rawEnv, "tsconfig", isString$2, void 0);
|
|
6372
|
-
return configPath && tsconfig ?
|
|
6201
|
+
return configPath && tsconfig ? path3.relative(process.cwd(), path3.join(path3.dirname(configPath), tsconfig)) : tsconfig;
|
|
6373
6202
|
}
|
|
6374
6203
|
__name(validateAndNormalizeTsconfig, "validateAndNormalizeTsconfig");
|
|
6375
6204
|
var validateAndNormalizeRules = /* @__PURE__ */ __name((diagnostics, topLevelEnv, rawEnv, envName) => {
|
|
@@ -6809,10 +6638,10 @@ function validateContainerApp(envName, topLevelName, configPath) {
|
|
|
6809
6638
|
let resolvedImage = containerAppOptional.image ?? containerAppOptional.configuration?.image;
|
|
6810
6639
|
let resolvedBuildContextPath = void 0;
|
|
6811
6640
|
try {
|
|
6812
|
-
if (isDockerfile
|
|
6813
|
-
const baseDir = configPath ?
|
|
6814
|
-
resolvedImage =
|
|
6815
|
-
resolvedBuildContextPath = containerAppOptional.image_build_context ?
|
|
6641
|
+
if (isDockerfile(resolvedImage, configPath)) {
|
|
6642
|
+
const baseDir = configPath ? path3.dirname(configPath) : process.cwd();
|
|
6643
|
+
resolvedImage = path3.resolve(baseDir, resolvedImage);
|
|
6644
|
+
resolvedBuildContextPath = containerAppOptional.image_build_context ? path3.resolve(baseDir, containerAppOptional.image_build_context) : path3.dirname(resolvedImage);
|
|
6816
6645
|
}
|
|
6817
6646
|
} catch (err) {
|
|
6818
6647
|
if (err instanceof Error && err.message) diagnostics.errors.push(err.message);
|
|
@@ -7545,7 +7374,10 @@ var validateRateLimitBinding = /* @__PURE__ */ __name((diagnostics, field, value
|
|
|
7545
7374
|
return isValid$1;
|
|
7546
7375
|
}, "validateRateLimitBinding");
|
|
7547
7376
|
function normalizeAndValidateLimits(diagnostics, topLevelEnv, rawEnv) {
|
|
7548
|
-
if (rawEnv.limits)
|
|
7377
|
+
if (rawEnv.limits) {
|
|
7378
|
+
validateOptionalProperty(diagnostics, "limits", "cpu_ms", rawEnv.limits.cpu_ms, "number");
|
|
7379
|
+
validateOptionalProperty(diagnostics, "limits", "subrequests", rawEnv.limits.subrequests, "number");
|
|
7380
|
+
}
|
|
7549
7381
|
return inheritable(diagnostics, topLevelEnv, rawEnv, "limits", () => true, void 0);
|
|
7550
7382
|
}
|
|
7551
7383
|
__name(normalizeAndValidateLimits, "normalizeAndValidateLimits");
|
|
@@ -7689,6 +7521,27 @@ function isRemoteValid(targetObject, fieldPath, diagnostics) {
|
|
|
7689
7521
|
return true;
|
|
7690
7522
|
}
|
|
7691
7523
|
__name(isRemoteValid, "isRemoteValid");
|
|
7524
|
+
function isDockerfile(imagePath, configPath) {
|
|
7525
|
+
const baseDir = configPath ? path3.dirname(configPath) : process.cwd();
|
|
7526
|
+
const maybeDockerfile = path3.resolve(baseDir, imagePath);
|
|
7527
|
+
if (fs.existsSync(maybeDockerfile)) {
|
|
7528
|
+
if (isDirectory(maybeDockerfile)) throw new UserError(`${imagePath} is a directory, you should specify a path to the Dockerfile`);
|
|
7529
|
+
return true;
|
|
7530
|
+
}
|
|
7531
|
+
const errorPrefix = `The image "${imagePath}" does not appear to be a valid path to a Dockerfile, or a valid image registry path:
|
|
7532
|
+
`;
|
|
7533
|
+
try {
|
|
7534
|
+
new URL(`https://${imagePath}`);
|
|
7535
|
+
} catch (e) {
|
|
7536
|
+
if (e instanceof Error) throw new UserError(errorPrefix + e.message);
|
|
7537
|
+
throw e;
|
|
7538
|
+
}
|
|
7539
|
+
const imageParts = imagePath.split("/");
|
|
7540
|
+
if (!imageParts[imageParts.length - 1]?.includes(":")) throw new UserError(errorPrefix + `If this is an image registry path, it needs to include at least a tag ':' (e.g: docker.io/httpd:1)`);
|
|
7541
|
+
if (imagePath.includes("://")) throw new UserError(errorPrefix + `Image reference should not include the protocol part (e.g: docker.io/httpd:1, not https://docker.io/httpd:1)`);
|
|
7542
|
+
return false;
|
|
7543
|
+
}
|
|
7544
|
+
__name(isDockerfile, "isDockerfile");
|
|
7692
7545
|
var supportedPagesConfigFields = [
|
|
7693
7546
|
"pages_build_output_dir",
|
|
7694
7547
|
"name",
|
|
@@ -7817,10 +7670,14 @@ const defuArrayFn = createDefu((object, key, currentValue) => {
|
|
|
7817
7670
|
function getDeployConfigPath(root) {
|
|
7818
7671
|
return nodePath.resolve(root, ".wrangler", "deploy", "config.json");
|
|
7819
7672
|
}
|
|
7820
|
-
function getWorkerConfigs(root) {
|
|
7673
|
+
function getWorkerConfigs(root, isPrerender) {
|
|
7821
7674
|
const deployConfigPath = getDeployConfigPath(root);
|
|
7822
7675
|
const deployConfig = JSON.parse(fs$1.readFileSync(deployConfigPath, "utf-8"));
|
|
7823
|
-
return [
|
|
7676
|
+
return [
|
|
7677
|
+
...isPrerender && deployConfig.prerenderWorkerConfigPath ? [{ configPath: deployConfig.prerenderWorkerConfigPath }] : [],
|
|
7678
|
+
{ configPath: deployConfig.configPath },
|
|
7679
|
+
...deployConfig.auxiliaryWorkers
|
|
7680
|
+
].map(({ configPath }) => {
|
|
7824
7681
|
const resolvedConfigPath = nodePath.resolve(nodePath.dirname(deployConfigPath), configPath);
|
|
7825
7682
|
return wrangler.unstable_readConfig({ config: resolvedConfigPath });
|
|
7826
7683
|
});
|
|
@@ -7835,25 +7692,30 @@ function writeDeployConfig(resolvedPluginConfig, resolvedViteConfig) {
|
|
|
7835
7692
|
if (resolvedPluginConfig.type === "assets-only") {
|
|
7836
7693
|
const clientOutputDirectory = resolvedViteConfig.environments.client?.build.outDir;
|
|
7837
7694
|
assert(clientOutputDirectory, "Unexpected error: client environment output directory is undefined");
|
|
7695
|
+
const prerenderOutputDirectory = resolvedPluginConfig.prerenderWorkerEnvironmentName ? resolvedViteConfig.environments[resolvedPluginConfig.prerenderWorkerEnvironmentName]?.build.outDir : void 0;
|
|
7838
7696
|
const deployConfig = {
|
|
7839
7697
|
configPath: getRelativePathToWorkerConfig(deployConfigDirectory, resolvedViteConfig.root, clientOutputDirectory),
|
|
7840
|
-
auxiliaryWorkers: []
|
|
7698
|
+
auxiliaryWorkers: [],
|
|
7699
|
+
prerenderWorkerConfigPath: prerenderOutputDirectory ? getRelativePathToWorkerConfig(deployConfigDirectory, resolvedViteConfig.root, prerenderOutputDirectory) : void 0
|
|
7841
7700
|
};
|
|
7842
7701
|
fs$1.writeFileSync(deployConfigPath, JSON.stringify(deployConfig));
|
|
7843
7702
|
} else {
|
|
7844
7703
|
let entryWorkerConfigPath;
|
|
7704
|
+
let prerenderWorkerConfigPath;
|
|
7845
7705
|
const auxiliaryWorkers = [];
|
|
7846
7706
|
for (const environmentName of resolvedPluginConfig.environmentNameToWorkerMap.keys()) {
|
|
7847
7707
|
const outputDirectory = resolvedViteConfig.environments[environmentName]?.build.outDir;
|
|
7848
7708
|
assert(outputDirectory, `Unexpected error: ${environmentName} environment output directory is undefined`);
|
|
7849
7709
|
const configPath = getRelativePathToWorkerConfig(deployConfigDirectory, resolvedViteConfig.root, outputDirectory);
|
|
7850
7710
|
if (environmentName === resolvedPluginConfig.entryWorkerEnvironmentName) entryWorkerConfigPath = configPath;
|
|
7711
|
+
else if (environmentName === resolvedPluginConfig.prerenderWorkerEnvironmentName) prerenderWorkerConfigPath = configPath;
|
|
7851
7712
|
else auxiliaryWorkers.push({ configPath });
|
|
7852
7713
|
}
|
|
7853
7714
|
assert(entryWorkerConfigPath, `Unexpected error: entryWorkerConfigPath is undefined`);
|
|
7854
7715
|
const deployConfig = {
|
|
7855
7716
|
configPath: entryWorkerConfigPath,
|
|
7856
|
-
auxiliaryWorkers
|
|
7717
|
+
auxiliaryWorkers,
|
|
7718
|
+
prerenderWorkerConfigPath
|
|
7857
7719
|
};
|
|
7858
7720
|
fs$1.writeFileSync(deployConfigPath, JSON.stringify(deployConfig));
|
|
7859
7721
|
}
|
|
@@ -13229,7 +13091,7 @@ function read(jsonPath, { base, specifier }) {
|
|
|
13229
13091
|
/** @type {string | undefined} */
|
|
13230
13092
|
let string;
|
|
13231
13093
|
try {
|
|
13232
|
-
string = fs.readFileSync(
|
|
13094
|
+
string = fs.readFileSync(path3.toNamespacedPath(jsonPath), "utf8");
|
|
13233
13095
|
} catch (error) {
|
|
13234
13096
|
const exception = error;
|
|
13235
13097
|
if (exception.code !== "ENOENT") throw exception;
|
|
@@ -13435,7 +13297,7 @@ function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
|
|
|
13435
13297
|
const packagePath = fileURLToPath(new URL$1(".", packageJsonUrl));
|
|
13436
13298
|
const basePath = fileURLToPath(base);
|
|
13437
13299
|
if (!main) process2.emitWarning(`No "main" or "exports" field defined in the package.json for ${packagePath} resolving the main entry point "${urlPath.slice(packagePath.length)}", imported from ${basePath}.\nDefault "index" lookups for the main are deprecated for ES modules.`, "DeprecationWarning", "DEP0151");
|
|
13438
|
-
else if (
|
|
13300
|
+
else if (path3.resolve(packagePath, main) !== urlPath) process2.emitWarning(`Package ${packagePath} has a "main" field set to "${main}", excluding the full filename and extension to the resolved file at "${urlPath.slice(packagePath.length)}", imported from ${basePath}.\n Automatic extension resolution of the "main" field is deprecated for ES modules.`, "DeprecationWarning", "DEP0151");
|
|
13439
13301
|
}
|
|
13440
13302
|
/**
|
|
13441
13303
|
* @param {string} path
|
|
@@ -13542,7 +13404,7 @@ function finalizeResolution(resolved, base, preserveSymlinks) {
|
|
|
13542
13404
|
{
|
|
13543
13405
|
const real = realpathSync(filePath);
|
|
13544
13406
|
const { search, hash } = resolved;
|
|
13545
|
-
resolved = pathToFileURL(real + (filePath.endsWith(
|
|
13407
|
+
resolved = pathToFileURL(real + (filePath.endsWith(path3.sep) ? "/" : ""));
|
|
13546
13408
|
resolved.search = search;
|
|
13547
13409
|
resolved.hash = hash;
|
|
13548
13410
|
}
|
|
@@ -14038,6 +13900,148 @@ function resolvePathSync(id, options) {
|
|
|
14038
13900
|
return fileURLToPath$1(resolveSync(id, options));
|
|
14039
13901
|
}
|
|
14040
13902
|
|
|
13903
|
+
//#endregion
|
|
13904
|
+
//#region src/shared.ts
|
|
13905
|
+
const UNKNOWN_HOST = "http://localhost";
|
|
13906
|
+
const INIT_PATH = "/__vite_plugin_cloudflare_init__";
|
|
13907
|
+
const GET_EXPORT_TYPES_PATH = "/__vite_plugin_cloudflare_get_export_types__";
|
|
13908
|
+
const WORKER_ENTRY_PATH_HEADER = "__VITE_WORKER_ENTRY_PATH__";
|
|
13909
|
+
const IS_ENTRY_WORKER_HEADER = "__VITE_IS_ENTRY_WORKER__";
|
|
13910
|
+
const ENVIRONMENT_NAME_HEADER = "__VITE_ENVIRONMENT_NAME__";
|
|
13911
|
+
const IS_PARENT_ENVIRONMENT_HEADER = "__VITE_IS_PARENT_ENVIRONMENT__";
|
|
13912
|
+
const virtualPrefix = "virtual:cloudflare/";
|
|
13913
|
+
const VIRTUAL_WORKER_ENTRY = `${virtualPrefix}worker-entry`;
|
|
13914
|
+
const VIRTUAL_EXPORT_TYPES = `${virtualPrefix}export-types`;
|
|
13915
|
+
|
|
13916
|
+
//#endregion
|
|
13917
|
+
//#region src/plugins/virtual-modules.ts
|
|
13918
|
+
const VIRTUAL_USER_ENTRY = `${virtualPrefix}user-entry`;
|
|
13919
|
+
const VIRTUAL_CLIENT_FALLBACK_ENTRY = `${virtualPrefix}client-fallback-entry`;
|
|
13920
|
+
const VIRTUAL_NODEJS_GLOBAL_INJECT_PREFIX = `${virtualPrefix}nodejs-global-inject/`;
|
|
13921
|
+
const virtualCloudflareResolveRE = /^virtual:cloudflare\//;
|
|
13922
|
+
const virtualCloudflareLoadRE = /^\0virtual:cloudflare\//;
|
|
13923
|
+
/**
|
|
13924
|
+
* Plugin to provide virtual modules
|
|
13925
|
+
*/
|
|
13926
|
+
const virtualModulesPlugin = createPlugin("virtual-modules", (ctx) => {
|
|
13927
|
+
return {
|
|
13928
|
+
applyToEnvironment(environment) {
|
|
13929
|
+
return !ctx.isChildEnvironment(environment.name) && ctx.getWorkerConfig(environment.name) !== void 0;
|
|
13930
|
+
},
|
|
13931
|
+
resolveId: {
|
|
13932
|
+
filter: { id: virtualCloudflareResolveRE },
|
|
13933
|
+
async handler(source) {
|
|
13934
|
+
if (!virtualCloudflareResolveRE.test(source)) return;
|
|
13935
|
+
if (source === VIRTUAL_USER_ENTRY) {
|
|
13936
|
+
const workerConfig = ctx.getWorkerConfig(this.environment.name);
|
|
13937
|
+
assert(workerConfig, "Expected `workerConfig` to be defined");
|
|
13938
|
+
const main = await this.resolve(workerConfig.main);
|
|
13939
|
+
if (!main) throw new Error(`Failed to resolve main entry file "${workerConfig.main}" for environment "${this.environment.name}"`);
|
|
13940
|
+
return main;
|
|
13941
|
+
}
|
|
13942
|
+
return `\0${source}`;
|
|
13943
|
+
}
|
|
13944
|
+
},
|
|
13945
|
+
load: {
|
|
13946
|
+
filter: { id: virtualCloudflareLoadRE },
|
|
13947
|
+
handler(id) {
|
|
13948
|
+
if (id === `\0${VIRTUAL_WORKER_ENTRY}`) {
|
|
13949
|
+
const nodeJsCompat = ctx.getNodeJsCompat(this.environment.name);
|
|
13950
|
+
return `
|
|
13951
|
+
${nodeJsCompat ? nodeJsCompat.injectGlobalCode() : ""}
|
|
13952
|
+
import { getExportTypes } from "${VIRTUAL_EXPORT_TYPES}";
|
|
13953
|
+
import * as mod from "${VIRTUAL_USER_ENTRY}";
|
|
13954
|
+
export * from "${VIRTUAL_USER_ENTRY}";
|
|
13955
|
+
export default mod.default ?? {};
|
|
13956
|
+
if (import.meta.hot) {
|
|
13957
|
+
import.meta.hot.accept((module) => {
|
|
13958
|
+
const exportTypes = getExportTypes(module);
|
|
13959
|
+
import.meta.hot.send("vite-plugin-cloudflare:worker-export-types", exportTypes);
|
|
13960
|
+
});
|
|
13961
|
+
}
|
|
13962
|
+
`;
|
|
13963
|
+
}
|
|
13964
|
+
if (id === `\0${VIRTUAL_EXPORT_TYPES}`) return `
|
|
13965
|
+
import {
|
|
13966
|
+
WorkerEntrypoint,
|
|
13967
|
+
DurableObject,
|
|
13968
|
+
WorkflowEntrypoint,
|
|
13969
|
+
} from "cloudflare:workers";
|
|
13970
|
+
|
|
13971
|
+
const baseClasses = new Map([
|
|
13972
|
+
["WorkerEntrypoint", WorkerEntrypoint],
|
|
13973
|
+
["DurableObject", DurableObject],
|
|
13974
|
+
["WorkflowEntrypoint", WorkflowEntrypoint],
|
|
13975
|
+
]);
|
|
13976
|
+
|
|
13977
|
+
export function getExportTypes(module) {
|
|
13978
|
+
const exportTypes = {};
|
|
13979
|
+
|
|
13980
|
+
for (const [key, value] of Object.entries(module)) {
|
|
13981
|
+
if (key === "default") {
|
|
13982
|
+
continue;
|
|
13983
|
+
}
|
|
13984
|
+
|
|
13985
|
+
let exportType;
|
|
13986
|
+
|
|
13987
|
+
if (typeof value === "function") {
|
|
13988
|
+
for (const [type, baseClass] of baseClasses) {
|
|
13989
|
+
if (baseClass.prototype.isPrototypeOf(value.prototype)) {
|
|
13990
|
+
exportType = type;
|
|
13991
|
+
break;
|
|
13992
|
+
}
|
|
13993
|
+
}
|
|
13994
|
+
|
|
13995
|
+
if (!exportType) {
|
|
13996
|
+
exportType = "DurableObject";
|
|
13997
|
+
}
|
|
13998
|
+
} else if (typeof value === "object" && value !== null) {
|
|
13999
|
+
exportType = "WorkerEntrypoint";
|
|
14000
|
+
}
|
|
14001
|
+
|
|
14002
|
+
exportTypes[key] = exportType;
|
|
14003
|
+
}
|
|
14004
|
+
|
|
14005
|
+
return exportTypes;
|
|
14006
|
+
}
|
|
14007
|
+
`;
|
|
14008
|
+
if (id.startsWith(`\0${VIRTUAL_NODEJS_GLOBAL_INJECT_PREFIX}`)) {
|
|
14009
|
+
const nodeJsCompat = ctx.getNodeJsCompat(this.environment.name);
|
|
14010
|
+
assertHasNodeJsCompat(nodeJsCompat);
|
|
14011
|
+
return nodeJsCompat.getGlobalVirtualModule(id.slice(1));
|
|
14012
|
+
}
|
|
14013
|
+
}
|
|
14014
|
+
}
|
|
14015
|
+
};
|
|
14016
|
+
});
|
|
14017
|
+
const virtualClientFallbackResolveRE = /^virtual:cloudflare\/client-fallback-entry$/;
|
|
14018
|
+
const virtualClientFallbackLoadRE = /^\0virtual:cloudflare\/client-fallback-entry$/;
|
|
14019
|
+
/**
|
|
14020
|
+
* Plugin to provide a virtual fallback entry file for the `client` environment.
|
|
14021
|
+
* This is used as the entry file for the client build when only the `public` directory is present.
|
|
14022
|
+
*/
|
|
14023
|
+
const virtualClientFallbackPlugin = createPlugin("virtual-client-fallback", () => {
|
|
14024
|
+
return {
|
|
14025
|
+
applyToEnvironment(environment) {
|
|
14026
|
+
return environment.name === "client";
|
|
14027
|
+
},
|
|
14028
|
+
resolveId: {
|
|
14029
|
+
filter: { id: virtualClientFallbackResolveRE },
|
|
14030
|
+
handler(source) {
|
|
14031
|
+
if (!virtualClientFallbackResolveRE.test(source)) return;
|
|
14032
|
+
return `\0${VIRTUAL_CLIENT_FALLBACK_ENTRY}`;
|
|
14033
|
+
}
|
|
14034
|
+
},
|
|
14035
|
+
load: {
|
|
14036
|
+
filter: { id: virtualClientFallbackLoadRE },
|
|
14037
|
+
handler(id) {
|
|
14038
|
+
if (!virtualClientFallbackLoadRE.test(id)) return;
|
|
14039
|
+
return "";
|
|
14040
|
+
}
|
|
14041
|
+
}
|
|
14042
|
+
};
|
|
14043
|
+
});
|
|
14044
|
+
|
|
14041
14045
|
//#endregion
|
|
14042
14046
|
//#region src/nodejs-compat.ts
|
|
14043
14047
|
var NodeJsCompat = class {
|
|
@@ -14085,7 +14089,6 @@ var NodeJsCompat = class {
|
|
|
14085
14089
|
#getInjects() {
|
|
14086
14090
|
const injectsByModule = /* @__PURE__ */ new Map();
|
|
14087
14091
|
const virtualModulePathToSpecifier = /* @__PURE__ */ new Map();
|
|
14088
|
-
const virtualModulePrefix = `\0_nodejs_global_inject-`;
|
|
14089
14092
|
for (const [injectedName, moduleSpecifier] of Object.entries(this.#env.inject)) {
|
|
14090
14093
|
const [module$2, exportName, importName] = Array.isArray(moduleSpecifier) ? [
|
|
14091
14094
|
moduleSpecifier[0],
|
|
@@ -14098,7 +14101,7 @@ var NodeJsCompat = class {
|
|
|
14098
14101
|
];
|
|
14099
14102
|
if (!injectsByModule.has(module$2)) {
|
|
14100
14103
|
injectsByModule.set(module$2, []);
|
|
14101
|
-
virtualModulePathToSpecifier.set(`${
|
|
14104
|
+
virtualModulePathToSpecifier.set(`${VIRTUAL_NODEJS_GLOBAL_INJECT_PREFIX}${module$2}`, module$2);
|
|
14102
14105
|
}
|
|
14103
14106
|
const injects = injectsByModule.get(module$2);
|
|
14104
14107
|
assert(injects, `expected injects for "${module$2}" to be defined`);
|
|
@@ -14484,7 +14487,7 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
14484
14487
|
const shared = {
|
|
14485
14488
|
persistState: pluginConfig.persistState ?? true,
|
|
14486
14489
|
inspectorPort: pluginConfig.inspectorPort,
|
|
14487
|
-
experimental: pluginConfig.experimental
|
|
14490
|
+
experimental: { headersAndRedirectsDevModeSupport: pluginConfig.experimental?.headersAndRedirectsDevModeSupport }
|
|
14488
14491
|
};
|
|
14489
14492
|
const root = userConfig.root ? nodePath.resolve(userConfig.root) : process.cwd();
|
|
14490
14493
|
const prefixedEnv = vite.loadEnv(viteEnv.mode, root, ["CLOUDFLARE_", "WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_"]);
|
|
@@ -14493,34 +14496,57 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
14493
14496
|
...shared,
|
|
14494
14497
|
remoteBindings: pluginConfig.remoteBindings ?? true,
|
|
14495
14498
|
type: "preview",
|
|
14496
|
-
workers: getWorkerConfigs(root)
|
|
14499
|
+
workers: getWorkerConfigs(root, !!process.env.CLOUDFLARE_VITE_BUILD)
|
|
14497
14500
|
};
|
|
14498
14501
|
const configPaths = /* @__PURE__ */ new Set();
|
|
14499
14502
|
const cloudflareEnv = prefixedEnv.CLOUDFLARE_ENV;
|
|
14503
|
+
const validateAndAddEnvironmentName = createEnvironmentNameValidator();
|
|
14500
14504
|
const entryWorkerResolvedConfig = resolveWorkerConfig({
|
|
14501
14505
|
root,
|
|
14502
14506
|
configPath: getValidatedWranglerConfigPath(root, pluginConfig.configPath),
|
|
14503
|
-
env:
|
|
14507
|
+
env: cloudflareEnv,
|
|
14504
14508
|
configCustomizer: pluginConfig.config,
|
|
14505
14509
|
visitedConfigPaths: configPaths
|
|
14506
14510
|
});
|
|
14511
|
+
const environmentNameToWorkerMap = /* @__PURE__ */ new Map();
|
|
14512
|
+
const environmentNameToChildEnvironmentNamesMap = /* @__PURE__ */ new Map();
|
|
14513
|
+
const prerenderWorkerConfig = pluginConfig.experimental?.prerenderWorker;
|
|
14514
|
+
let prerenderWorkerEnvironmentName;
|
|
14515
|
+
if (prerenderWorkerConfig && viteEnv.command === "build") {
|
|
14516
|
+
const workerResolvedConfig = resolveWorkerConfig({
|
|
14517
|
+
root,
|
|
14518
|
+
configPath: getValidatedWranglerConfigPath(root, prerenderWorkerConfig.configPath, true),
|
|
14519
|
+
env: cloudflareEnv,
|
|
14520
|
+
configCustomizer: "config" in prerenderWorkerConfig ? prerenderWorkerConfig.config : void 0,
|
|
14521
|
+
entryWorkerConfig: entryWorkerResolvedConfig.config,
|
|
14522
|
+
visitedConfigPaths: configPaths
|
|
14523
|
+
});
|
|
14524
|
+
prerenderWorkerEnvironmentName = prerenderWorkerConfig.viteEnvironment?.name ?? workerNameToEnvironmentName(workerResolvedConfig.config.topLevelName);
|
|
14525
|
+
validateAndAddEnvironmentName(prerenderWorkerEnvironmentName);
|
|
14526
|
+
environmentNameToWorkerMap.set(prerenderWorkerEnvironmentName, resolveWorker(workerResolvedConfig.config));
|
|
14527
|
+
const prerenderWorkerChildEnvironments = prerenderWorkerConfig.viteEnvironment?.childEnvironments;
|
|
14528
|
+
if (prerenderWorkerChildEnvironments) {
|
|
14529
|
+
for (const childName of prerenderWorkerChildEnvironments) validateAndAddEnvironmentName(childName);
|
|
14530
|
+
environmentNameToChildEnvironmentNamesMap.set(prerenderWorkerEnvironmentName, prerenderWorkerChildEnvironments);
|
|
14531
|
+
}
|
|
14532
|
+
}
|
|
14507
14533
|
if (entryWorkerResolvedConfig.type === "assets-only") return {
|
|
14508
14534
|
...shared,
|
|
14509
14535
|
type: "assets-only",
|
|
14510
14536
|
cloudflareEnv,
|
|
14511
14537
|
config: entryWorkerResolvedConfig.config,
|
|
14538
|
+
environmentNameToWorkerMap,
|
|
14539
|
+
environmentNameToChildEnvironmentNamesMap,
|
|
14540
|
+
prerenderWorkerEnvironmentName,
|
|
14512
14541
|
configPaths,
|
|
14513
14542
|
remoteBindings: pluginConfig.remoteBindings ?? true,
|
|
14514
14543
|
rawConfigs: { entryWorker: entryWorkerResolvedConfig }
|
|
14515
14544
|
};
|
|
14516
|
-
const entryWorkerConfig = entryWorkerResolvedConfig.config;
|
|
14517
|
-
const entryWorkerEnvironmentName = pluginConfig.viteEnvironment?.name ?? workerNameToEnvironmentName(entryWorkerConfig.topLevelName);
|
|
14518
|
-
const validateAndAddEnvironmentName = createEnvironmentNameValidator();
|
|
14519
|
-
validateAndAddEnvironmentName(entryWorkerEnvironmentName);
|
|
14520
14545
|
let staticRouting;
|
|
14521
|
-
if (Array.isArray(
|
|
14522
|
-
const
|
|
14523
|
-
|
|
14546
|
+
if (Array.isArray(entryWorkerResolvedConfig.config.assets?.run_worker_first)) staticRouting = parseStaticRouting(entryWorkerResolvedConfig.config.assets.run_worker_first);
|
|
14547
|
+
const entryWorkerEnvironmentName = pluginConfig.viteEnvironment?.name ?? workerNameToEnvironmentName(entryWorkerResolvedConfig.config.topLevelName);
|
|
14548
|
+
validateAndAddEnvironmentName(entryWorkerEnvironmentName);
|
|
14549
|
+
environmentNameToWorkerMap.set(entryWorkerEnvironmentName, resolveWorker(entryWorkerResolvedConfig.config));
|
|
14524
14550
|
const entryWorkerChildEnvironments = pluginConfig.viteEnvironment?.childEnvironments;
|
|
14525
14551
|
if (entryWorkerChildEnvironments) {
|
|
14526
14552
|
for (const childName of entryWorkerChildEnvironments) validateAndAddEnvironmentName(childName);
|
|
@@ -14533,7 +14559,7 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
14533
14559
|
configPath: getValidatedWranglerConfigPath(root, auxiliaryWorker.configPath, true),
|
|
14534
14560
|
env: cloudflareEnv,
|
|
14535
14561
|
configCustomizer: "config" in auxiliaryWorker ? auxiliaryWorker.config : void 0,
|
|
14536
|
-
entryWorkerConfig,
|
|
14562
|
+
entryWorkerConfig: entryWorkerResolvedConfig.config,
|
|
14537
14563
|
visitedConfigPaths: configPaths
|
|
14538
14564
|
});
|
|
14539
14565
|
auxiliaryWorkersResolvedConfigs.push(workerResolvedConfig);
|
|
@@ -14553,6 +14579,7 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
14553
14579
|
configPaths,
|
|
14554
14580
|
environmentNameToWorkerMap,
|
|
14555
14581
|
environmentNameToChildEnvironmentNamesMap,
|
|
14582
|
+
prerenderWorkerEnvironmentName,
|
|
14556
14583
|
entryWorkerEnvironmentName,
|
|
14557
14584
|
staticRouting,
|
|
14558
14585
|
remoteBindings: pluginConfig.remoteBindings ?? true,
|
|
@@ -15592,16 +15619,19 @@ const additionalModulesPlugin = createPlugin("additional-modules", (ctx) => {
|
|
|
15592
15619
|
applyToEnvironment(environment) {
|
|
15593
15620
|
return ctx.getWorkerConfig(environment.name) !== void 0;
|
|
15594
15621
|
},
|
|
15595
|
-
|
|
15596
|
-
|
|
15597
|
-
|
|
15598
|
-
|
|
15599
|
-
|
|
15600
|
-
|
|
15601
|
-
|
|
15602
|
-
|
|
15603
|
-
|
|
15604
|
-
|
|
15622
|
+
resolveId: {
|
|
15623
|
+
filter: { id: moduleRuleFilters },
|
|
15624
|
+
async handler(source, importer, options) {
|
|
15625
|
+
const additionalModuleType = matchAdditionalModule(source);
|
|
15626
|
+
if (!additionalModuleType) return;
|
|
15627
|
+
const resolved = await this.resolve(cleanUrl(source), importer, options);
|
|
15628
|
+
if (!resolved) throw new Error(`Import "${source}" not found. Does the file exist?`);
|
|
15629
|
+
additionalModulePaths.add(resolved.id);
|
|
15630
|
+
return {
|
|
15631
|
+
external: true,
|
|
15632
|
+
id: createModuleReference(additionalModuleType, resolved.id)
|
|
15633
|
+
};
|
|
15634
|
+
}
|
|
15605
15635
|
},
|
|
15606
15636
|
hotUpdate(options) {
|
|
15607
15637
|
if (additionalModulePaths.has(options.file)) {
|
|
@@ -15609,34 +15639,37 @@ const additionalModulesPlugin = createPlugin("additional-modules", (ctx) => {
|
|
|
15609
15639
|
return [];
|
|
15610
15640
|
}
|
|
15611
15641
|
},
|
|
15612
|
-
|
|
15613
|
-
|
|
15614
|
-
|
|
15615
|
-
|
|
15616
|
-
magicString
|
|
15617
|
-
const
|
|
15618
|
-
|
|
15619
|
-
|
|
15620
|
-
|
|
15621
|
-
source
|
|
15622
|
-
|
|
15623
|
-
|
|
15642
|
+
renderChunk: {
|
|
15643
|
+
filter: { code: { include: additionalModuleRE } },
|
|
15644
|
+
async handler(code, chunk) {
|
|
15645
|
+
const matches = code.matchAll(additionalModuleGlobalRE);
|
|
15646
|
+
let magicString;
|
|
15647
|
+
for (const match of matches) {
|
|
15648
|
+
magicString ??= new MagicString(code);
|
|
15649
|
+
const [full, _, modulePath] = match;
|
|
15650
|
+
assert(modulePath, `Unexpected error: module path not found in reference ${full}.`);
|
|
15651
|
+
let source;
|
|
15652
|
+
try {
|
|
15653
|
+
source = await fsp.readFile(modulePath);
|
|
15654
|
+
} catch {
|
|
15655
|
+
throw new Error(`Import "${modulePath}" not found. Does the file exist?`);
|
|
15656
|
+
}
|
|
15657
|
+
const referenceId = this.emitFile({
|
|
15658
|
+
type: "asset",
|
|
15659
|
+
name: nodePath.basename(modulePath),
|
|
15660
|
+
originalFileName: modulePath,
|
|
15661
|
+
source
|
|
15662
|
+
});
|
|
15663
|
+
const emittedFileName = this.getFileName(referenceId);
|
|
15664
|
+
const relativePath = vite.normalizePath(nodePath.relative(nodePath.dirname(chunk.fileName), emittedFileName));
|
|
15665
|
+
const importPath = relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
15666
|
+
magicString.update(match.index, match.index + full.length, importPath);
|
|
15624
15667
|
}
|
|
15625
|
-
|
|
15626
|
-
|
|
15627
|
-
|
|
15628
|
-
|
|
15629
|
-
|
|
15630
|
-
});
|
|
15631
|
-
const emittedFileName = this.getFileName(referenceId);
|
|
15632
|
-
const relativePath = vite.normalizePath(nodePath.relative(nodePath.dirname(chunk.fileName), emittedFileName));
|
|
15633
|
-
const importPath = relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
15634
|
-
magicString.update(match.index, match.index + full.length, importPath);
|
|
15635
|
-
}
|
|
15636
|
-
if (magicString) return {
|
|
15637
|
-
code: magicString.toString(),
|
|
15638
|
-
map: this.environment.config.build.sourcemap ? magicString.generateMap({ hires: "boundary" }) : null
|
|
15639
|
-
};
|
|
15668
|
+
if (magicString) return {
|
|
15669
|
+
code: magicString.toString(),
|
|
15670
|
+
map: this.environment.config.build.sourcemap ? magicString.generateMap({ hires: "boundary" }) : null
|
|
15671
|
+
};
|
|
15672
|
+
}
|
|
15640
15673
|
}
|
|
15641
15674
|
};
|
|
15642
15675
|
});
|
|
@@ -15650,23 +15683,20 @@ const additionalModuleGlobalRE = new RegExp(ADDITIONAL_MODULE_PATTERN, "g");
|
|
|
15650
15683
|
const moduleRules = [
|
|
15651
15684
|
{
|
|
15652
15685
|
type: "CompiledWasm",
|
|
15653
|
-
|
|
15686
|
+
pattern: /\.wasm(\?module)?$/
|
|
15654
15687
|
},
|
|
15655
15688
|
{
|
|
15656
15689
|
type: "Data",
|
|
15657
|
-
|
|
15690
|
+
pattern: /\.bin$/
|
|
15658
15691
|
},
|
|
15659
15692
|
{
|
|
15660
15693
|
type: "Text",
|
|
15661
|
-
|
|
15662
|
-
".txt",
|
|
15663
|
-
".html",
|
|
15664
|
-
".sql"
|
|
15665
|
-
]
|
|
15694
|
+
pattern: /\.(txt|html|sql)$/
|
|
15666
15695
|
}
|
|
15667
15696
|
];
|
|
15697
|
+
const moduleRuleFilters = moduleRules.map((rule) => rule.pattern);
|
|
15668
15698
|
function matchAdditionalModule(source) {
|
|
15669
|
-
for (const rule of moduleRules)
|
|
15699
|
+
for (const rule of moduleRules) if (rule.pattern.test(source)) return rule.type;
|
|
15670
15700
|
return null;
|
|
15671
15701
|
}
|
|
15672
15702
|
function createModuleReference(type, id) {
|
|
@@ -21355,126 +21385,9 @@ var require_picocolors = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnp
|
|
|
21355
21385
|
module.exports.createColors = createColors;
|
|
21356
21386
|
}) });
|
|
21357
21387
|
|
|
21358
|
-
//#endregion
|
|
21359
|
-
//#region src/shared.ts
|
|
21360
|
-
var import_picocolors$4 = /* @__PURE__ */ __toESM$1(require_picocolors(), 1);
|
|
21361
|
-
const UNKNOWN_HOST = "http://localhost";
|
|
21362
|
-
const INIT_PATH = "/__vite_plugin_cloudflare_init__";
|
|
21363
|
-
const GET_EXPORT_TYPES_PATH = "/__vite_plugin_cloudflare_get_export_types__";
|
|
21364
|
-
const WORKER_ENTRY_PATH_HEADER = "__VITE_WORKER_ENTRY_PATH__";
|
|
21365
|
-
const IS_ENTRY_WORKER_HEADER = "__VITE_IS_ENTRY_WORKER__";
|
|
21366
|
-
const ENVIRONMENT_NAME_HEADER = "__VITE_ENVIRONMENT_NAME__";
|
|
21367
|
-
const IS_PARENT_ENVIRONMENT_HEADER = "__VITE_IS_PARENT_ENVIRONMENT__";
|
|
21368
|
-
const virtualPrefix = "virtual:cloudflare/";
|
|
21369
|
-
const VIRTUAL_WORKER_ENTRY = `${virtualPrefix}worker-entry`;
|
|
21370
|
-
const VIRTUAL_EXPORT_TYPES = `${virtualPrefix}export-types`;
|
|
21371
|
-
|
|
21372
|
-
//#endregion
|
|
21373
|
-
//#region src/plugins/virtual-modules.ts
|
|
21374
|
-
const VIRTUAL_USER_ENTRY = `${virtualPrefix}user-entry`;
|
|
21375
|
-
const VIRTUAL_CLIENT_FALLBACK_ENTRY = `${virtualPrefix}client-fallback-entry`;
|
|
21376
|
-
/**
|
|
21377
|
-
* Plugin to provide virtual modules
|
|
21378
|
-
*/
|
|
21379
|
-
const virtualModulesPlugin = createPlugin("virtual-modules", (ctx) => {
|
|
21380
|
-
return {
|
|
21381
|
-
applyToEnvironment(environment) {
|
|
21382
|
-
return !ctx.isChildEnvironment(environment.name) && ctx.getWorkerConfig(environment.name) !== void 0;
|
|
21383
|
-
},
|
|
21384
|
-
async resolveId(source) {
|
|
21385
|
-
if (source === VIRTUAL_WORKER_ENTRY || source === VIRTUAL_EXPORT_TYPES) return `\0${source}`;
|
|
21386
|
-
if (source === VIRTUAL_USER_ENTRY) {
|
|
21387
|
-
const workerConfig = ctx.getWorkerConfig(this.environment.name);
|
|
21388
|
-
assert(workerConfig, "Expected `workerConfig` to be defined");
|
|
21389
|
-
const main = await this.resolve(workerConfig.main);
|
|
21390
|
-
if (!main) throw new Error(`Failed to resolve main entry file "${workerConfig.main}" for environment "${this.environment.name}"`);
|
|
21391
|
-
return main;
|
|
21392
|
-
}
|
|
21393
|
-
},
|
|
21394
|
-
load(id) {
|
|
21395
|
-
if (id === `\0${VIRTUAL_WORKER_ENTRY}`) {
|
|
21396
|
-
const nodeJsCompat = ctx.getNodeJsCompat(this.environment.name);
|
|
21397
|
-
return `
|
|
21398
|
-
${nodeJsCompat ? nodeJsCompat.injectGlobalCode() : ""}
|
|
21399
|
-
import { getExportTypes } from "${VIRTUAL_EXPORT_TYPES}";
|
|
21400
|
-
import * as mod from "${VIRTUAL_USER_ENTRY}";
|
|
21401
|
-
export * from "${VIRTUAL_USER_ENTRY}";
|
|
21402
|
-
export default mod.default ?? {};
|
|
21403
|
-
if (import.meta.hot) {
|
|
21404
|
-
import.meta.hot.accept((module) => {
|
|
21405
|
-
const exportTypes = getExportTypes(module);
|
|
21406
|
-
import.meta.hot.send("vite-plugin-cloudflare:worker-export-types", exportTypes);
|
|
21407
|
-
});
|
|
21408
|
-
}
|
|
21409
|
-
`;
|
|
21410
|
-
}
|
|
21411
|
-
if (id === `\0${VIRTUAL_EXPORT_TYPES}`) return `
|
|
21412
|
-
import {
|
|
21413
|
-
WorkerEntrypoint,
|
|
21414
|
-
DurableObject,
|
|
21415
|
-
WorkflowEntrypoint,
|
|
21416
|
-
} from "cloudflare:workers";
|
|
21417
|
-
|
|
21418
|
-
const baseClasses = new Map([
|
|
21419
|
-
["WorkerEntrypoint", WorkerEntrypoint],
|
|
21420
|
-
["DurableObject", DurableObject],
|
|
21421
|
-
["WorkflowEntrypoint", WorkflowEntrypoint],
|
|
21422
|
-
]);
|
|
21423
|
-
|
|
21424
|
-
export function getExportTypes(module) {
|
|
21425
|
-
const exportTypes = {};
|
|
21426
|
-
|
|
21427
|
-
for (const [key, value] of Object.entries(module)) {
|
|
21428
|
-
if (key === "default") {
|
|
21429
|
-
continue;
|
|
21430
|
-
}
|
|
21431
|
-
|
|
21432
|
-
let exportType;
|
|
21433
|
-
|
|
21434
|
-
if (typeof value === "function") {
|
|
21435
|
-
for (const [type, baseClass] of baseClasses) {
|
|
21436
|
-
if (baseClass.prototype.isPrototypeOf(value.prototype)) {
|
|
21437
|
-
exportType = type;
|
|
21438
|
-
break;
|
|
21439
|
-
}
|
|
21440
|
-
}
|
|
21441
|
-
|
|
21442
|
-
if (!exportType) {
|
|
21443
|
-
exportType = "DurableObject";
|
|
21444
|
-
}
|
|
21445
|
-
} else if (typeof value === "object" && value !== null) {
|
|
21446
|
-
exportType = "WorkerEntrypoint";
|
|
21447
|
-
}
|
|
21448
|
-
|
|
21449
|
-
exportTypes[key] = exportType;
|
|
21450
|
-
}
|
|
21451
|
-
|
|
21452
|
-
return exportTypes;
|
|
21453
|
-
}
|
|
21454
|
-
`;
|
|
21455
|
-
}
|
|
21456
|
-
};
|
|
21457
|
-
});
|
|
21458
|
-
/**
|
|
21459
|
-
* Plugin to provide a virtual fallback entry file for the `client` environment.
|
|
21460
|
-
* This is used as the entry file for the client build when only the `public` directory is present.
|
|
21461
|
-
*/
|
|
21462
|
-
const virtualClientFallbackPlugin = createPlugin("virtual-client-fallback", () => {
|
|
21463
|
-
return {
|
|
21464
|
-
applyToEnvironment(environment) {
|
|
21465
|
-
return environment.name === "client";
|
|
21466
|
-
},
|
|
21467
|
-
resolveId(source) {
|
|
21468
|
-
if (source === VIRTUAL_CLIENT_FALLBACK_ENTRY) return `\0${VIRTUAL_CLIENT_FALLBACK_ENTRY}`;
|
|
21469
|
-
},
|
|
21470
|
-
load(id) {
|
|
21471
|
-
if (id === `\0${VIRTUAL_CLIENT_FALLBACK_ENTRY}`) return ``;
|
|
21472
|
-
}
|
|
21473
|
-
};
|
|
21474
|
-
});
|
|
21475
|
-
|
|
21476
21388
|
//#endregion
|
|
21477
21389
|
//#region src/build.ts
|
|
21390
|
+
var import_picocolors$4 = /* @__PURE__ */ __toESM$1(require_picocolors(), 1);
|
|
21478
21391
|
const CLIENT_FALLBACK_ENTRY_NAME = "__cloudflare_fallback_entry__";
|
|
21479
21392
|
function createBuildApp(resolvedPluginConfig) {
|
|
21480
21393
|
return async (builder) => {
|
|
@@ -21482,24 +21395,24 @@ function createBuildApp(resolvedPluginConfig) {
|
|
|
21482
21395
|
assert(clientEnvironment, `No "client" environment`);
|
|
21483
21396
|
const defaultHtmlPath = nodePath.resolve(builder.config.root, "index.html");
|
|
21484
21397
|
const hasClientEntry = clientEnvironment.config.build.rollupOptions.input || fs$1.existsSync(defaultHtmlPath);
|
|
21485
|
-
if (resolvedPluginConfig.type === "assets-only") {
|
|
21486
|
-
if (hasClientEntry) await builder.build(clientEnvironment);
|
|
21487
|
-
else if (getHasPublicAssets(builder.config)) await fallbackBuild(builder, clientEnvironment);
|
|
21488
|
-
return;
|
|
21489
|
-
}
|
|
21490
21398
|
const workerEnvironments = [...resolvedPluginConfig.environmentNameToWorkerMap.keys()].map((environmentName) => {
|
|
21491
21399
|
const environment = builder.environments[environmentName];
|
|
21492
21400
|
assert(environment, `"${environmentName}" environment not found`);
|
|
21493
21401
|
return environment;
|
|
21494
21402
|
});
|
|
21495
21403
|
await Promise.all(workerEnvironments.map((environment) => builder.build(environment)));
|
|
21404
|
+
if (resolvedPluginConfig.type === "assets-only") {
|
|
21405
|
+
if (hasClientEntry) await builder.build(clientEnvironment);
|
|
21406
|
+
else if (getHasPublicAssets(builder.config) || resolvedPluginConfig.prerenderWorkerEnvironmentName) await fallbackBuild(builder, clientEnvironment);
|
|
21407
|
+
return;
|
|
21408
|
+
}
|
|
21496
21409
|
const { entryWorkerEnvironmentName } = resolvedPluginConfig;
|
|
21497
21410
|
const entryWorkerEnvironment = builder.environments[entryWorkerEnvironmentName];
|
|
21498
21411
|
assert(entryWorkerEnvironment, `No "${entryWorkerEnvironmentName}" environment`);
|
|
21499
21412
|
const entryWorkerBuildDirectory = nodePath.resolve(builder.config.root, entryWorkerEnvironment.config.build.outDir);
|
|
21500
21413
|
const importedAssetPaths = getImportedAssetPaths(loadViteManifest(entryWorkerBuildDirectory));
|
|
21501
21414
|
if (hasClientEntry) await builder.build(clientEnvironment);
|
|
21502
|
-
else if (importedAssetPaths.size || getHasPublicAssets(builder.config)) await fallbackBuild(builder, clientEnvironment);
|
|
21415
|
+
else if (importedAssetPaths.size || getHasPublicAssets(builder.config) || resolvedPluginConfig.prerenderWorkerEnvironmentName) await fallbackBuild(builder, clientEnvironment);
|
|
21503
21416
|
else {
|
|
21504
21417
|
if (!satisfiesViteVersion("7.0.0")) removeAssetsField(entryWorkerBuildDirectory);
|
|
21505
21418
|
return;
|
|
@@ -21697,7 +21610,17 @@ function createCloudflareEnvironmentOptions({ workerConfig, userConfig, mode, en
|
|
|
21697
21610
|
noDiscovery: false,
|
|
21698
21611
|
ignoreOutdatedRequests: true,
|
|
21699
21612
|
entries: vite.normalizePath(workerConfig.main),
|
|
21700
|
-
exclude: [
|
|
21613
|
+
exclude: [
|
|
21614
|
+
...cloudflareBuiltInModules,
|
|
21615
|
+
...nonPrefixedNodeModules,
|
|
21616
|
+
...nonPrefixedNodeModules.map((module$2) => `node:${module$2}`),
|
|
21617
|
+
...[
|
|
21618
|
+
"node:sea",
|
|
21619
|
+
"node:sqlite",
|
|
21620
|
+
"node:test",
|
|
21621
|
+
"node:test/reporters"
|
|
21622
|
+
]
|
|
21623
|
+
],
|
|
21701
21624
|
...isRolldown ? { rolldownOptions: {
|
|
21702
21625
|
platform: "neutral",
|
|
21703
21626
|
resolve: {
|
|
@@ -21707,7 +21630,11 @@ function createCloudflareEnvironmentOptions({ workerConfig, userConfig, mode, en
|
|
|
21707
21630
|
transform: {
|
|
21708
21631
|
target,
|
|
21709
21632
|
define: define$1
|
|
21710
|
-
}
|
|
21633
|
+
},
|
|
21634
|
+
plugins: [vite.esmExternalRequirePlugin({
|
|
21635
|
+
external: [nodeBuiltinsRE],
|
|
21636
|
+
skipDuplicateCheck: true
|
|
21637
|
+
})]
|
|
21711
21638
|
} } : { esbuildOptions: {
|
|
21712
21639
|
platform: "neutral",
|
|
21713
21640
|
conditions: [...defaultConditions, "development"],
|
|
@@ -21841,7 +21768,7 @@ const configPlugin = createPlugin("config", (ctx) => {
|
|
|
21841
21768
|
},
|
|
21842
21769
|
configResolved(resolvedViteConfig) {
|
|
21843
21770
|
ctx.setResolvedViteConfig(resolvedViteConfig);
|
|
21844
|
-
if (ctx.resolvedPluginConfig.type
|
|
21771
|
+
if (ctx.resolvedPluginConfig.type !== "preview") validateWorkerEnvironmentOptions(ctx.resolvedPluginConfig, ctx.resolvedViteConfig);
|
|
21845
21772
|
},
|
|
21846
21773
|
buildStart() {
|
|
21847
21774
|
ctx.setHasShownWorkerConfigWarnings(false);
|
|
@@ -21881,21 +21808,22 @@ const configPlugin = createPlugin("config", (ctx) => {
|
|
|
21881
21808
|
* Generates the environment configuration for all Worker environments.
|
|
21882
21809
|
*/
|
|
21883
21810
|
function getEnvironmentsConfig(ctx, userConfig, mode) {
|
|
21884
|
-
|
|
21885
|
-
|
|
21811
|
+
assertIsNotPreview(ctx);
|
|
21812
|
+
if (!ctx.resolvedPluginConfig.environmentNameToWorkerMap.size) return;
|
|
21886
21813
|
return {
|
|
21887
|
-
...Object.fromEntries([...
|
|
21888
|
-
const childEnvironmentNames =
|
|
21814
|
+
...Object.fromEntries([...ctx.resolvedPluginConfig.environmentNameToWorkerMap].flatMap(([environmentName, worker]) => {
|
|
21815
|
+
const childEnvironmentNames = ctx.resolvedPluginConfig.environmentNameToChildEnvironmentNamesMap.get(environmentName) ?? [];
|
|
21889
21816
|
const sharedOptions = {
|
|
21890
21817
|
workerConfig: worker.config,
|
|
21891
21818
|
userConfig,
|
|
21892
21819
|
mode,
|
|
21893
21820
|
hasNodeJsCompat: ctx.getNodeJsCompat(environmentName) !== void 0
|
|
21894
21821
|
};
|
|
21822
|
+
const isEntryWorker = environmentName === ctx.resolvedPluginConfig.prerenderWorkerEnvironmentName || ctx.resolvedPluginConfig.type === "workers" && environmentName === ctx.resolvedPluginConfig.entryWorkerEnvironmentName;
|
|
21895
21823
|
return [[environmentName, createCloudflareEnvironmentOptions({
|
|
21896
21824
|
...sharedOptions,
|
|
21897
21825
|
environmentName,
|
|
21898
|
-
isEntryWorker
|
|
21826
|
+
isEntryWorker,
|
|
21899
21827
|
isParentEnvironment: true
|
|
21900
21828
|
})], ...childEnvironmentNames.map((childEnvironmentName) => [childEnvironmentName, createCloudflareEnvironmentOptions({
|
|
21901
21829
|
...sharedOptions,
|
|
@@ -22806,23 +22734,6 @@ var ImageRegistriesService = class {
|
|
|
22806
22734
|
}
|
|
22807
22735
|
};
|
|
22808
22736
|
|
|
22809
|
-
//#endregion
|
|
22810
|
-
//#region ../containers-shared/src/error.ts
|
|
22811
|
-
/**
|
|
22812
|
-
* Base class for errors where the user has done something wrong. These are not
|
|
22813
|
-
* reported to Sentry. API errors are intentionally *not* `UserError`s, and are
|
|
22814
|
-
* reported to Sentry. This will help us understand which API errors need better
|
|
22815
|
-
* messaging.
|
|
22816
|
-
*/
|
|
22817
|
-
var UserError = class extends Error {
|
|
22818
|
-
telemetryMessage;
|
|
22819
|
-
constructor(message, options) {
|
|
22820
|
-
super(message, options);
|
|
22821
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
22822
|
-
this.telemetryMessage = options?.telemetryMessage === true ? message : options?.telemetryMessage;
|
|
22823
|
-
}
|
|
22824
|
-
};
|
|
22825
|
-
|
|
22826
22737
|
//#endregion
|
|
22827
22738
|
//#region ../containers-shared/src/build.ts
|
|
22828
22739
|
async function constructBuildCommand(options, logger) {
|
|
@@ -23042,29 +22953,6 @@ const verifyDockerInstalled = async (dockerPath, isDev = true) => {
|
|
|
23042
22953
|
if (!await isDockerRunning(dockerPath)) throw new UserError(`The Docker CLI could not be launched. Please ensure that the Docker CLI is installed and the daemon is running.
|
|
23043
22954
|
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." : ""}`);
|
|
23044
22955
|
};
|
|
23045
|
-
function isDir(inputPath) {
|
|
23046
|
-
return statSync(inputPath).isDirectory();
|
|
23047
|
-
}
|
|
23048
|
-
/** returns true if it is a dockerfile, false if it is a registry link, throws if neither */
|
|
23049
|
-
const isDockerfile = (image, configPath) => {
|
|
23050
|
-
const baseDir = configPath ? path4.dirname(configPath) : process.cwd();
|
|
23051
|
-
const maybeDockerfile = path4.resolve(baseDir, image);
|
|
23052
|
-
if (existsSync(maybeDockerfile)) {
|
|
23053
|
-
if (isDir(maybeDockerfile)) throw new UserError(`${image} is a directory, you should specify a path to the Dockerfile`);
|
|
23054
|
-
return true;
|
|
23055
|
-
}
|
|
23056
|
-
const errorPrefix = `The image "${image}" does not appear to be a valid path to a Dockerfile, or a valid image registry path:\n`;
|
|
23057
|
-
try {
|
|
23058
|
-
new URL(`https://${image}`);
|
|
23059
|
-
} catch (e) {
|
|
23060
|
-
if (e instanceof Error) throw new UserError(errorPrefix + e.message);
|
|
23061
|
-
throw e;
|
|
23062
|
-
}
|
|
23063
|
-
const imageParts = image.split("/");
|
|
23064
|
-
if (!imageParts[imageParts.length - 1]?.includes(":")) throw new UserError(errorPrefix + `If this is an image registry path, it needs to include at least a tag ':' (e.g: docker.io/httpd:1)`);
|
|
23065
|
-
if (image.includes("://")) throw new UserError(errorPrefix + `Image reference should not include the protocol part (e.g: docker.io/httpd:1, not https://docker.io/httpd:1)`);
|
|
23066
|
-
return false;
|
|
23067
|
-
};
|
|
23068
22956
|
/**
|
|
23069
22957
|
* Kills and removes any containers which come from the given image tag
|
|
23070
22958
|
*/
|
|
@@ -23318,7 +23206,7 @@ function getContainerOptions(options) {
|
|
|
23318
23206
|
return containersConfig.map((container) => {
|
|
23319
23207
|
if (isDockerfile(container.image, configPath)) return {
|
|
23320
23208
|
dockerfile: container.image,
|
|
23321
|
-
image_build_context: container.image_build_context ??
|
|
23209
|
+
image_build_context: container.image_build_context ?? path3.dirname(container.image),
|
|
23322
23210
|
image_vars: container.image_vars,
|
|
23323
23211
|
class_name: container.class_name,
|
|
23324
23212
|
image_tag: getDevContainerImageName(container.class_name, containerBuildId)
|
|
@@ -26433,46 +26321,31 @@ const nodeJsCompatPlugin = createPlugin("nodejs-compat", (ctx) => {
|
|
|
26433
26321
|
...isRolldown ? { build: { rolldownOptions: { plugins: [vite.esmExternalRequirePlugin({
|
|
26434
26322
|
external: [...nodeJsCompat.externals],
|
|
26435
26323
|
skipDuplicateCheck: true
|
|
26436
|
-
})] } } } : {}
|
|
26437
|
-
optimizeDeps: {
|
|
26438
|
-
exclude: [
|
|
26439
|
-
...nonPrefixedNodeModules,
|
|
26440
|
-
...nonPrefixedNodeModules.map((module$2) => `node:${module$2}`),
|
|
26441
|
-
...[
|
|
26442
|
-
"node:sea",
|
|
26443
|
-
"node:sqlite",
|
|
26444
|
-
"node:test",
|
|
26445
|
-
"node:test/reporters"
|
|
26446
|
-
]
|
|
26447
|
-
],
|
|
26448
|
-
...isRolldown ? { rolldownOptions: { plugins: [vite.esmExternalRequirePlugin({
|
|
26449
|
-
external: [nodeBuiltinsRE],
|
|
26450
|
-
skipDuplicateCheck: true
|
|
26451
|
-
})] } } : {}
|
|
26452
|
-
}
|
|
26324
|
+
})] } } } : {}
|
|
26453
26325
|
};
|
|
26454
26326
|
},
|
|
26455
26327
|
applyToEnvironment(environment) {
|
|
26456
26328
|
return ctx.getNodeJsCompat(environment.name) !== void 0;
|
|
26457
26329
|
},
|
|
26458
26330
|
enforce: "pre",
|
|
26459
|
-
|
|
26460
|
-
|
|
26461
|
-
|
|
26462
|
-
|
|
26463
|
-
|
|
26464
|
-
|
|
26465
|
-
|
|
26466
|
-
|
|
26467
|
-
|
|
26468
|
-
|
|
26469
|
-
|
|
26470
|
-
|
|
26471
|
-
|
|
26472
|
-
|
|
26473
|
-
|
|
26474
|
-
|
|
26475
|
-
|
|
26331
|
+
resolveId: {
|
|
26332
|
+
filter: { id: [
|
|
26333
|
+
nodeBuiltinsRE,
|
|
26334
|
+
/^unenv\//,
|
|
26335
|
+
/^@cloudflare\/unenv-preset\//
|
|
26336
|
+
] },
|
|
26337
|
+
async handler(source, importer, options) {
|
|
26338
|
+
const nodeJsCompat = ctx.getNodeJsCompat(this.environment.name);
|
|
26339
|
+
assertHasNodeJsCompat(nodeJsCompat);
|
|
26340
|
+
const result = nodeJsCompat.resolveNodeJsImport(source);
|
|
26341
|
+
if (!result) return;
|
|
26342
|
+
if (this.environment.mode === "dev") {
|
|
26343
|
+
assert(this.environment.depsOptimizer, "depsOptimizer is required in dev mode");
|
|
26344
|
+
const { id } = this.environment.depsOptimizer.registerMissingImport(result.unresolved, result.resolved);
|
|
26345
|
+
return this.resolve(id, importer, options);
|
|
26346
|
+
}
|
|
26347
|
+
return this.resolve(result.resolved, importer, options);
|
|
26348
|
+
}
|
|
26476
26349
|
},
|
|
26477
26350
|
async configureServer(viteDevServer) {
|
|
26478
26351
|
await Promise.all(Object.values(viteDevServer.environments).flatMap(async (environment) => {
|
|
@@ -26500,45 +26373,8 @@ const nodeJsCompatWarningsPlugin = createPlugin("nodejs-compat-warnings", (ctx)
|
|
|
26500
26373
|
exitCallback$1 = () => {
|
|
26501
26374
|
for (const nodeJsCompatWarnings of nodeJsCompatWarningsMap.values()) nodeJsCompatWarnings.renderWarnings();
|
|
26502
26375
|
};
|
|
26503
|
-
function resolveId(environmentName, source, importer) {
|
|
26504
|
-
const workerConfig = ctx.getWorkerConfig(environmentName);
|
|
26505
|
-
const nodeJsCompat = ctx.getNodeJsCompat(environmentName);
|
|
26506
|
-
if (workerConfig && !nodeJsCompat) {
|
|
26507
|
-
if (hasNodeJsAls(workerConfig) && isNodeAlsModule(source)) return;
|
|
26508
|
-
const nodeJsCompatWarnings = nodeJsCompatWarningsMap.get(workerConfig);
|
|
26509
|
-
if (source.startsWith("node:") || nonPrefixedNodeModules.includes(source)) {
|
|
26510
|
-
nodeJsCompatWarnings?.registerImport(source, importer);
|
|
26511
|
-
return {
|
|
26512
|
-
id: source,
|
|
26513
|
-
external: true
|
|
26514
|
-
};
|
|
26515
|
-
}
|
|
26516
|
-
}
|
|
26517
|
-
}
|
|
26518
26376
|
return {
|
|
26519
26377
|
enforce: "pre",
|
|
26520
|
-
configEnvironment(environmentName) {
|
|
26521
|
-
const workerConfig = ctx.getWorkerConfig(environmentName);
|
|
26522
|
-
const nodeJsCompat = ctx.getNodeJsCompat(environmentName);
|
|
26523
|
-
if (workerConfig && !nodeJsCompat) return { optimizeDeps: { ...isRolldown ? { rolldownOptions: { plugins: [{
|
|
26524
|
-
name: "vite-plugin-cloudflare:nodejs-compat-warnings-resolver",
|
|
26525
|
-
resolveId(source, importer) {
|
|
26526
|
-
return resolveId(environmentName, source, importer);
|
|
26527
|
-
}
|
|
26528
|
-
}] } } : { esbuildOptions: { plugins: [{
|
|
26529
|
-
name: "vite-plugin-cloudflare:nodejs-compat-warnings-resolver",
|
|
26530
|
-
setup(build$8) {
|
|
26531
|
-
build$8.onResolve({ filter: nodeBuiltinsRE }, ({ path: path$1, importer }) => {
|
|
26532
|
-
if (hasNodeJsAls(workerConfig) && isNodeAlsModule(path$1)) return;
|
|
26533
|
-
nodeJsCompatWarningsMap.get(workerConfig)?.registerImport(path$1, importer);
|
|
26534
|
-
return {
|
|
26535
|
-
path: path$1,
|
|
26536
|
-
external: true
|
|
26537
|
-
};
|
|
26538
|
-
});
|
|
26539
|
-
}
|
|
26540
|
-
}] } } } };
|
|
26541
|
-
},
|
|
26542
26378
|
configResolved(resolvedViteConfig) {
|
|
26543
26379
|
for (const environmentName of Object.keys(resolvedViteConfig.environments)) {
|
|
26544
26380
|
const workerConfig = ctx.getWorkerConfig(environmentName);
|
|
@@ -26549,8 +26385,19 @@ const nodeJsCompatWarningsPlugin = createPlugin("nodejs-compat-warnings", (ctx)
|
|
|
26549
26385
|
applyToEnvironment(environment) {
|
|
26550
26386
|
return ctx.getWorkerConfig(environment.name) !== void 0 && !ctx.getNodeJsCompat(environment.name);
|
|
26551
26387
|
},
|
|
26552
|
-
|
|
26553
|
-
|
|
26388
|
+
resolveId: {
|
|
26389
|
+
filter: { id: nodeBuiltinsRE },
|
|
26390
|
+
handler(source, importer) {
|
|
26391
|
+
if (!nodeBuiltinsRE.test(source)) return;
|
|
26392
|
+
const workerConfig = ctx.getWorkerConfig(this.environment.name);
|
|
26393
|
+
assert(workerConfig, `expected workerConfig to be defined`);
|
|
26394
|
+
if (hasNodeJsAls(workerConfig) && isNodeAlsModule(source)) return;
|
|
26395
|
+
nodeJsCompatWarningsMap.get(workerConfig)?.registerImport(source, importer);
|
|
26396
|
+
return {
|
|
26397
|
+
id: source,
|
|
26398
|
+
external: true
|
|
26399
|
+
};
|
|
26400
|
+
}
|
|
26554
26401
|
}
|
|
26555
26402
|
};
|
|
26556
26403
|
});
|
|
@@ -26566,27 +26413,27 @@ const outputConfigPlugin = createPlugin("output-config", (ctx) => {
|
|
|
26566
26413
|
assertIsNotPreview(ctx);
|
|
26567
26414
|
if (ctx.isChildEnvironment(this.environment.name)) return;
|
|
26568
26415
|
let outputConfig;
|
|
26569
|
-
|
|
26570
|
-
|
|
26571
|
-
if (!inputConfig) return;
|
|
26416
|
+
const inputWorkerConfig = ctx.getWorkerConfig(this.environment.name);
|
|
26417
|
+
if (inputWorkerConfig) {
|
|
26572
26418
|
const entryChunk = Object.values(bundle).find((chunk) => chunk.type === "chunk" && chunk.isEntry && chunk.name === MAIN_ENTRY_NAME);
|
|
26573
26419
|
assert(entryChunk, `Expected entry chunk with name "${MAIN_ENTRY_NAME}"`);
|
|
26574
|
-
const
|
|
26420
|
+
const isPrerenderWorker = this.environment.name === ctx.resolvedPluginConfig.prerenderWorkerEnvironmentName;
|
|
26421
|
+
const isEntryWorker = ctx.resolvedPluginConfig.type === "workers" && this.environment.name === ctx.resolvedPluginConfig.entryWorkerEnvironmentName;
|
|
26575
26422
|
outputConfig = {
|
|
26576
|
-
...
|
|
26423
|
+
...inputWorkerConfig,
|
|
26577
26424
|
main: entryChunk.fileName,
|
|
26578
26425
|
no_bundle: true,
|
|
26579
26426
|
rules: [{
|
|
26580
26427
|
type: "ESModule",
|
|
26581
26428
|
globs: ["**/*.js", "**/*.mjs"]
|
|
26582
26429
|
}],
|
|
26583
|
-
assets: isEntryWorker ? {
|
|
26584
|
-
...
|
|
26430
|
+
assets: isEntryWorker || isPrerenderWorker ? {
|
|
26431
|
+
...inputWorkerConfig.assets,
|
|
26585
26432
|
directory: getAssetsDirectory(this.environment.config.build.outDir, ctx.resolvedViteConfig)
|
|
26586
26433
|
} : void 0
|
|
26587
26434
|
};
|
|
26588
|
-
if (
|
|
26589
|
-
const localDevVars = getLocalDevVarsForPreview(
|
|
26435
|
+
if (inputWorkerConfig.configPath) {
|
|
26436
|
+
const localDevVars = getLocalDevVarsForPreview(inputWorkerConfig.configPath, ctx.resolvedPluginConfig.cloudflareEnv);
|
|
26590
26437
|
if (localDevVars) this.emitFile({
|
|
26591
26438
|
type: "asset",
|
|
26592
26439
|
fileName: ".dev.vars",
|
|
@@ -26594,19 +26441,21 @@ const outputConfigPlugin = createPlugin("output-config", (ctx) => {
|
|
|
26594
26441
|
});
|
|
26595
26442
|
}
|
|
26596
26443
|
} else if (this.environment.name === "client") {
|
|
26597
|
-
const inputConfig = ctx.resolvedPluginConfig.config;
|
|
26598
|
-
outputConfig = {
|
|
26599
|
-
...inputConfig,
|
|
26600
|
-
assets: {
|
|
26601
|
-
...inputConfig.assets,
|
|
26602
|
-
directory: "."
|
|
26603
|
-
}
|
|
26604
|
-
};
|
|
26605
26444
|
this.emitFile({
|
|
26606
26445
|
type: "asset",
|
|
26607
26446
|
fileName: ".assetsignore",
|
|
26608
26447
|
source: `${["wrangler.json", ".dev.vars"].join("\n")}\n`
|
|
26609
26448
|
});
|
|
26449
|
+
if (ctx.resolvedPluginConfig.type === "assets-only") {
|
|
26450
|
+
const inputAssetsOnlyConfig = ctx.resolvedPluginConfig.config;
|
|
26451
|
+
outputConfig = {
|
|
26452
|
+
...inputAssetsOnlyConfig,
|
|
26453
|
+
assets: {
|
|
26454
|
+
...inputAssetsOnlyConfig.assets,
|
|
26455
|
+
directory: "."
|
|
26456
|
+
}
|
|
26457
|
+
};
|
|
26458
|
+
}
|
|
26610
26459
|
}
|
|
26611
26460
|
if (!outputConfig) return;
|
|
26612
26461
|
if (outputConfig.unsafe && Object.keys(outputConfig.unsafe).length === 0) outputConfig.unsafe = void 0;
|
|
@@ -26754,6 +26603,7 @@ const triggerHandlersPlugin = createPlugin("trigger-handlers", (ctx) => {
|
|
|
26754
26603
|
|
|
26755
26604
|
//#endregion
|
|
26756
26605
|
//#region src/plugins/wasm.ts
|
|
26606
|
+
const wasmInitRE = /\.wasm\?init$/;
|
|
26757
26607
|
/**
|
|
26758
26608
|
* Plugin to support the `.wasm?init` extension
|
|
26759
26609
|
*/
|
|
@@ -26763,14 +26613,17 @@ const wasmHelperPlugin = createPlugin("wasm-helper", (ctx) => {
|
|
|
26763
26613
|
applyToEnvironment(environment) {
|
|
26764
26614
|
return ctx.getWorkerConfig(environment.name) !== void 0;
|
|
26765
26615
|
},
|
|
26766
|
-
load
|
|
26767
|
-
|
|
26768
|
-
|
|
26616
|
+
load: {
|
|
26617
|
+
filter: { id: wasmInitRE },
|
|
26618
|
+
handler(id) {
|
|
26619
|
+
if (!wasmInitRE.test(id)) return;
|
|
26620
|
+
return `
|
|
26769
26621
|
import wasm from "${cleanUrl(id)}";
|
|
26770
26622
|
export default function(opts = {}) {
|
|
26771
26623
|
return WebAssembly.instantiate(wasm, opts);
|
|
26772
26624
|
}
|
|
26773
26625
|
`;
|
|
26626
|
+
}
|
|
26774
26627
|
}
|
|
26775
26628
|
};
|
|
26776
26629
|
});
|
|
@@ -26797,6 +26650,7 @@ function cloudflare(pluginConfig = {}) {
|
|
|
26797
26650
|
sharedDuringBuild: true,
|
|
26798
26651
|
config(userConfig, env$1) {
|
|
26799
26652
|
ctx.setResolvedPluginConfig(resolvePluginConfig(pluginConfig, userConfig, env$1));
|
|
26653
|
+
if (env$1.command === "build") process.env.CLOUDFLARE_VITE_BUILD = "true";
|
|
26800
26654
|
},
|
|
26801
26655
|
async configureServer(viteDevServer) {
|
|
26802
26656
|
const restartServer = viteDevServer.restart.bind(viteDevServer);
|