@cloudflare/vite-plugin 1.40.2 → 1.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{dist-MawCthRW.mjs → dist-Cr__Sz5N.mjs} +203 -83
- package/dist/dist-Cr__Sz5N.mjs.map +1 -0
- package/dist/experimental-config.d.mts +4 -4
- package/dist/experimental-config.d.mts.map +1 -1
- package/dist/index.d.mts +5 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +757 -477
- package/dist/index.mjs.map +1 -1
- package/dist/{package-DEUdxNzK.mjs → package-IaRylt-M.mjs} +2 -2
- package/dist/{package-DEUdxNzK.mjs.map → package-IaRylt-M.mjs.map} +1 -1
- package/package.json +8 -8
- package/dist/dist-MawCthRW.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import assert from "node:assert";
|
|
|
3
3
|
import { CoreHeaders, CorePaths, Log, LogLevel, Miniflare, Request as Request$1, Response as Response$1, buildPublicUrl, coupleWebSocket, getDefaultDevRegistryPath, getNodeCompat, getWorkerRegistry, kUnsafeEphemeralUniqueKey, parseModuleFallbackRequest } from "miniflare";
|
|
4
4
|
import * as wrangler from "wrangler";
|
|
5
5
|
import * as nodePath from "node:path";
|
|
6
|
-
import
|
|
6
|
+
import path, { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
7
7
|
import * as util$1 from "node:util";
|
|
8
8
|
import { format, inspect, promisify } from "node:util";
|
|
9
9
|
import * as vite from "vite";
|
|
@@ -1505,7 +1505,7 @@ async function assertWranglerVersion() {
|
|
|
1505
1505
|
* The default compatibility date to use when the user omits one.
|
|
1506
1506
|
* This value is injected at build time and remains fixed for each release.
|
|
1507
1507
|
*/
|
|
1508
|
-
const DEFAULT_COMPAT_DATE = "2026-06-
|
|
1508
|
+
const DEFAULT_COMPAT_DATE = "2026-06-16";
|
|
1509
1509
|
|
|
1510
1510
|
//#endregion
|
|
1511
1511
|
//#region ../../node_modules/.pnpm/@remix-run+node-fetch-server@0.8.0/node_modules/@remix-run/node-fetch-server/dist/node-fetch-server.js
|
|
@@ -3957,7 +3957,7 @@ function resolveWranglerConfigPath({ config, script }, options) {
|
|
|
3957
3957
|
deployConfigPath: void 0,
|
|
3958
3958
|
redirected: false
|
|
3959
3959
|
};
|
|
3960
|
-
return findWranglerConfig$1(script !== void 0 ?
|
|
3960
|
+
return findWranglerConfig$1(script !== void 0 ? path.dirname(script) : process.cwd(), options);
|
|
3961
3961
|
}
|
|
3962
3962
|
__name(resolveWranglerConfigPath, "resolveWranglerConfigPath");
|
|
3963
3963
|
function findWranglerConfig$1(referencePath = process.cwd(), { useRedirectIfAvailable = false } = {}) {
|
|
@@ -3988,15 +3988,15 @@ function findRedirectedWranglerConfig(cwd, userConfigPath) {
|
|
|
3988
3988
|
const deployConfigFile = readFileSync$1(deployConfigPath);
|
|
3989
3989
|
try {
|
|
3990
3990
|
const deployConfig = parseJSONC(deployConfigFile, deployConfigPath);
|
|
3991
|
-
redirectedConfigPath = deployConfig.configPath &&
|
|
3991
|
+
redirectedConfigPath = deployConfig.configPath && path.resolve(path.dirname(deployConfigPath), deployConfig.configPath);
|
|
3992
3992
|
} catch (e) {
|
|
3993
|
-
throw new UserError(`Failed to parse the deploy configuration file at ${
|
|
3993
|
+
throw new UserError(`Failed to parse the deploy configuration file at ${path.relative(".", deployConfigPath)}`, {
|
|
3994
3994
|
cause: e,
|
|
3995
3995
|
telemetryMessage: false
|
|
3996
3996
|
});
|
|
3997
3997
|
}
|
|
3998
3998
|
if (!redirectedConfigPath) throw new UserError(esm_default`
|
|
3999
|
-
A deploy configuration file was found at "${
|
|
3999
|
+
A deploy configuration file was found at "${path.relative(".", deployConfigPath)}".
|
|
4000
4000
|
But this is not valid - the required "configPath" property was not found.
|
|
4001
4001
|
Instead this file contains:
|
|
4002
4002
|
\`\`\`
|
|
@@ -4004,13 +4004,13 @@ function findRedirectedWranglerConfig(cwd, userConfigPath) {
|
|
|
4004
4004
|
\`\`\`
|
|
4005
4005
|
`, { telemetryMessage: false });
|
|
4006
4006
|
if (!existsSync(redirectedConfigPath)) throw new UserError(esm_default`
|
|
4007
|
-
There is a deploy configuration at "${
|
|
4008
|
-
But the redirected configuration path it points to, "${
|
|
4007
|
+
There is a deploy configuration at "${path.relative(".", deployConfigPath)}".
|
|
4008
|
+
But the redirected configuration path it points to, "${path.relative(".", redirectedConfigPath)}", does not exist.
|
|
4009
4009
|
`, { telemetryMessage: false });
|
|
4010
4010
|
if (userConfigPath) {
|
|
4011
|
-
if (
|
|
4012
|
-
Found both a user configuration file at "${
|
|
4013
|
-
and a deploy configuration file at "${
|
|
4011
|
+
if (path.join(path.dirname(userConfigPath), PATH_TO_DEPLOY_CONFIG) !== deployConfigPath) throw new UserError(esm_default`
|
|
4012
|
+
Found both a user configuration file at "${path.relative(".", userConfigPath)}"
|
|
4013
|
+
and a deploy configuration file at "${path.relative(".", deployConfigPath)}".
|
|
4014
4014
|
But these do not share the same base path so it is not clear which should be used.
|
|
4015
4015
|
`, { telemetryMessage: false });
|
|
4016
4016
|
}
|
|
@@ -5226,10 +5226,10 @@ var require_util$5 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/un
|
|
|
5226
5226
|
if (!isHttpOrHttpsPrefixed(url.origin || url.protocol)) throw new InvalidArgumentError$36("Invalid URL protocol: the URL must start with `http:` or `https:`.");
|
|
5227
5227
|
const port = url.port != null ? url.port : url.protocol === "https:" ? 443 : 80;
|
|
5228
5228
|
let origin = url.origin != null ? url.origin : `${url.protocol || ""}//${url.hostname || ""}:${port}`;
|
|
5229
|
-
let path = url.path != null ? url.path : `${url.pathname || ""}${url.search || ""}`;
|
|
5229
|
+
let path$1 = url.path != null ? url.path : `${url.pathname || ""}${url.search || ""}`;
|
|
5230
5230
|
if (origin[origin.length - 1] === "/") origin = origin.slice(0, origin.length - 1);
|
|
5231
|
-
if (path && path[0] !== "/") path = `/${path}`;
|
|
5232
|
-
return new URL(`${origin}${path}`);
|
|
5231
|
+
if (path$1 && path$1[0] !== "/") path$1 = `/${path$1}`;
|
|
5232
|
+
return new URL(`${origin}${path$1}`);
|
|
5233
5233
|
}
|
|
5234
5234
|
if (!isHttpOrHttpsPrefixed(url.origin || url.protocol)) throw new InvalidArgumentError$36("Invalid URL protocol: the URL must start with `http:` or `https:`.");
|
|
5235
5235
|
return url;
|
|
@@ -6104,8 +6104,8 @@ var require_diagnostics = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pn
|
|
|
6104
6104
|
debugLog("connection to %s%s using %s%s errored - %s", host, port ? `:${port}` : "", protocol, version$2, error.message);
|
|
6105
6105
|
});
|
|
6106
6106
|
diagnosticsChannel$1.subscribe("undici:client:sendHeaders", (evt) => {
|
|
6107
|
-
const { request: { method, path, origin } } = evt;
|
|
6108
|
-
debugLog("sending request to %s %s%s", method, origin, path);
|
|
6107
|
+
const { request: { method, path: path$1, origin } } = evt;
|
|
6108
|
+
debugLog("sending request to %s %s%s", method, origin, path$1);
|
|
6109
6109
|
});
|
|
6110
6110
|
}
|
|
6111
6111
|
let isTrackingRequestEvents = false;
|
|
@@ -6117,16 +6117,16 @@ var require_diagnostics = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pn
|
|
|
6117
6117
|
}
|
|
6118
6118
|
isTrackingRequestEvents = true;
|
|
6119
6119
|
diagnosticsChannel$1.subscribe("undici:request:headers", (evt) => {
|
|
6120
|
-
const { request: { method, path, origin }, response: { statusCode } } = evt;
|
|
6121
|
-
debugLog("received response to %s %s%s - HTTP %d", method, origin, path, statusCode);
|
|
6120
|
+
const { request: { method, path: path$1, origin }, response: { statusCode } } = evt;
|
|
6121
|
+
debugLog("received response to %s %s%s - HTTP %d", method, origin, path$1, statusCode);
|
|
6122
6122
|
});
|
|
6123
6123
|
diagnosticsChannel$1.subscribe("undici:request:trailers", (evt) => {
|
|
6124
|
-
const { request: { method, path, origin } } = evt;
|
|
6125
|
-
debugLog("trailers received from %s %s%s", method, origin, path);
|
|
6124
|
+
const { request: { method, path: path$1, origin } } = evt;
|
|
6125
|
+
debugLog("trailers received from %s %s%s", method, origin, path$1);
|
|
6126
6126
|
});
|
|
6127
6127
|
diagnosticsChannel$1.subscribe("undici:request:error", (evt) => {
|
|
6128
|
-
const { request: { method, path, origin }, error } = evt;
|
|
6129
|
-
debugLog("request to %s %s%s errored - %s", method, origin, path, error.message);
|
|
6128
|
+
const { request: { method, path: path$1, origin }, error } = evt;
|
|
6129
|
+
debugLog("request to %s %s%s errored - %s", method, origin, path$1, error.message);
|
|
6130
6130
|
});
|
|
6131
6131
|
}
|
|
6132
6132
|
let isTrackingWebSocketEvents = false;
|
|
@@ -6179,10 +6179,10 @@ var require_request$1 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm
|
|
|
6179
6179
|
const invalidPathRegex = /[^\u0021-\u00ff]/;
|
|
6180
6180
|
const kHandler = Symbol("handler");
|
|
6181
6181
|
var Request$6 = class {
|
|
6182
|
-
constructor(origin, { path, method, body, headers, query, idempotent, blocking, upgrade: upgrade$1, headersTimeout, bodyTimeout, reset, expectContinue, servername, throwOnError, maxRedirections, typeOfService }, handler) {
|
|
6183
|
-
if (typeof path !== "string") throw new InvalidArgumentError$35("path must be a string");
|
|
6184
|
-
else if (path[0] !== "/" && !(path.startsWith("http://") || path.startsWith("https://")) && method !== "CONNECT") throw new InvalidArgumentError$35("path must be an absolute URL or start with a slash");
|
|
6185
|
-
else if (invalidPathRegex.test(path)) throw new InvalidArgumentError$35("invalid request path");
|
|
6182
|
+
constructor(origin, { path: path$1, method, body, headers, query, idempotent, blocking, upgrade: upgrade$1, headersTimeout, bodyTimeout, reset, expectContinue, servername, throwOnError, maxRedirections, typeOfService }, handler) {
|
|
6183
|
+
if (typeof path$1 !== "string") throw new InvalidArgumentError$35("path must be a string");
|
|
6184
|
+
else if (path$1[0] !== "/" && !(path$1.startsWith("http://") || path$1.startsWith("https://")) && method !== "CONNECT") throw new InvalidArgumentError$35("path must be an absolute URL or start with a slash");
|
|
6185
|
+
else if (invalidPathRegex.test(path$1)) throw new InvalidArgumentError$35("invalid request path");
|
|
6186
6186
|
if (typeof method !== "string") throw new InvalidArgumentError$35("method must be a string");
|
|
6187
6187
|
else if (normalizedMethodRecords$1[method] === void 0 && !isValidHTTPToken$2(method)) throw new InvalidArgumentError$35("invalid request method");
|
|
6188
6188
|
if (upgrade$1 && typeof upgrade$1 !== "string") throw new InvalidArgumentError$35("upgrade must be a string");
|
|
@@ -6223,7 +6223,7 @@ var require_request$1 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm
|
|
|
6223
6223
|
this.completed = false;
|
|
6224
6224
|
this.aborted = false;
|
|
6225
6225
|
this.upgrade = upgrade$1 || null;
|
|
6226
|
-
this.path = query ? serializePathWithQuery$3(path, query) : path;
|
|
6226
|
+
this.path = query ? serializePathWithQuery$3(path$1, query) : path$1;
|
|
6227
6227
|
this.origin = origin;
|
|
6228
6228
|
this.protocol = getProtocolFromUrlString(origin);
|
|
6229
6229
|
this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
|
|
@@ -10706,7 +10706,7 @@ var require_client_h1 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm
|
|
|
10706
10706
|
* @returns
|
|
10707
10707
|
*/
|
|
10708
10708
|
function writeH1(client, request$2) {
|
|
10709
|
-
const { method, path, host, upgrade: upgrade$1, blocking, reset } = request$2;
|
|
10709
|
+
const { method, path: path$1, host, upgrade: upgrade$1, blocking, reset } = request$2;
|
|
10710
10710
|
let { body, headers, contentLength } = request$2;
|
|
10711
10711
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
|
|
10712
10712
|
if (util$23.isFormDataLike(body)) {
|
|
@@ -10751,7 +10751,7 @@ var require_client_h1 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm
|
|
|
10751
10751
|
if (client[kMaxRequests$1] && socket[kCounter$1]++ >= client[kMaxRequests$1]) socket[kReset$1] = true;
|
|
10752
10752
|
if (blocking) socket[kBlocking] = true;
|
|
10753
10753
|
if (socket.setTypeOfService) socket.setTypeOfService(request$2.typeOfService);
|
|
10754
|
-
let header = `${method} ${path} HTTP/1.1\r\n`;
|
|
10754
|
+
let header = `${method} ${path$1} HTTP/1.1\r\n`;
|
|
10755
10755
|
if (typeof host === "string") header += `host: ${host}\r\n`;
|
|
10756
10756
|
else header += client[kHostHeader$1];
|
|
10757
10757
|
if (upgrade$1) header += `connection: upgrade\r\nupgrade: ${upgrade$1}\r\n`;
|
|
@@ -11287,7 +11287,7 @@ var require_client_h2 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm
|
|
|
11287
11287
|
function writeH2(client, request$2) {
|
|
11288
11288
|
const requestTimeout = request$2.bodyTimeout ?? client[kBodyTimeout$1];
|
|
11289
11289
|
const session = client[kHTTP2Session];
|
|
11290
|
-
const { method, path, host, upgrade: upgrade$1, expectContinue, signal, protocol, headers: reqHeaders } = request$2;
|
|
11290
|
+
const { method, path: path$1, host, upgrade: upgrade$1, expectContinue, signal, protocol, headers: reqHeaders } = request$2;
|
|
11291
11291
|
let { body } = request$2;
|
|
11292
11292
|
if (upgrade$1 != null && upgrade$1 !== "websocket") {
|
|
11293
11293
|
util$22.errorRequest(client, request$2, new InvalidArgumentError$30(`Custom upgrade "${upgrade$1}" not supported over HTTP/2`));
|
|
@@ -11340,7 +11340,7 @@ var require_client_h2 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm
|
|
|
11340
11340
|
}
|
|
11341
11341
|
headers[HTTP2_HEADER_METHOD] = "CONNECT";
|
|
11342
11342
|
headers[HTTP2_HEADER_PROTOCOL] = "websocket";
|
|
11343
|
-
headers[HTTP2_HEADER_PATH] = path;
|
|
11343
|
+
headers[HTTP2_HEADER_PATH] = path$1;
|
|
11344
11344
|
if (protocol === "ws:" || protocol === "wss:") headers[HTTP2_HEADER_SCHEME] = protocol === "ws:" ? "http" : "https";
|
|
11345
11345
|
else headers[HTTP2_HEADER_SCHEME] = protocol === "http:" ? "http" : "https";
|
|
11346
11346
|
stream$2 = session.request(headers, {
|
|
@@ -11382,7 +11382,7 @@ var require_client_h2 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm
|
|
|
11382
11382
|
stream$2.setTimeout(requestTimeout);
|
|
11383
11383
|
return true;
|
|
11384
11384
|
}
|
|
11385
|
-
headers[HTTP2_HEADER_PATH] = path;
|
|
11385
|
+
headers[HTTP2_HEADER_PATH] = path$1;
|
|
11386
11386
|
headers[HTTP2_HEADER_SCHEME] = protocol === "http:" ? "http" : "https";
|
|
11387
11387
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
|
|
11388
11388
|
if (body && typeof body.read === "function") body.read(0);
|
|
@@ -13208,8 +13208,8 @@ var require_proxy_agent = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pn
|
|
|
13208
13208
|
}
|
|
13209
13209
|
if (onHeaders) onHeaders.call(this, statusCode, data$1, resume$1);
|
|
13210
13210
|
};
|
|
13211
|
-
const { origin, path = "/", headers = {} } = opts;
|
|
13212
|
-
opts.path = origin + path;
|
|
13211
|
+
const { origin, path: path$1 = "/", headers = {} } = opts;
|
|
13212
|
+
opts.path = origin + path$1;
|
|
13213
13213
|
if (!("host" in headers) && !("Host" in headers)) {
|
|
13214
13214
|
const { host } = new URL(origin);
|
|
13215
13215
|
headers.host = host;
|
|
@@ -14993,16 +14993,16 @@ var require_mock_utils = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnp
|
|
|
14993
14993
|
}
|
|
14994
14994
|
return normalizedQp;
|
|
14995
14995
|
}
|
|
14996
|
-
function safeUrl(path) {
|
|
14997
|
-
if (typeof path !== "string") return path;
|
|
14998
|
-
const pathSegments = path.split("?", 3);
|
|
14999
|
-
if (pathSegments.length !== 2) return path;
|
|
14996
|
+
function safeUrl(path$1) {
|
|
14997
|
+
if (typeof path$1 !== "string") return path$1;
|
|
14998
|
+
const pathSegments = path$1.split("?", 3);
|
|
14999
|
+
if (pathSegments.length !== 2) return path$1;
|
|
15000
15000
|
const qp = new URLSearchParams(pathSegments.pop());
|
|
15001
15001
|
qp.sort();
|
|
15002
15002
|
return [...pathSegments, qp.toString()].join("?");
|
|
15003
15003
|
}
|
|
15004
|
-
function matchKey(mockDispatch$1, { path, method, body, headers }) {
|
|
15005
|
-
const pathMatch = matchValue$1(mockDispatch$1.path, path);
|
|
15004
|
+
function matchKey(mockDispatch$1, { path: path$1, method, body, headers }) {
|
|
15005
|
+
const pathMatch = matchValue$1(mockDispatch$1.path, path$1);
|
|
15006
15006
|
const methodMatch = matchValue$1(mockDispatch$1.method, method);
|
|
15007
15007
|
const bodyMatch = typeof mockDispatch$1.body !== "undefined" ? matchValue$1(mockDispatch$1.body, body) : true;
|
|
15008
15008
|
const headersMatch = matchHeaders(mockDispatch$1, headers);
|
|
@@ -15020,8 +15020,8 @@ var require_mock_utils = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnp
|
|
|
15020
15020
|
const basePath = key.query ? serializePathWithQuery$2(key.path, key.query) : key.path;
|
|
15021
15021
|
const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
|
|
15022
15022
|
const resolvedPathWithoutTrailingSlash = removeTrailingSlash(resolvedPath);
|
|
15023
|
-
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path, ignoreTrailingSlash }) => {
|
|
15024
|
-
return ignoreTrailingSlash ? matchValue$1(removeTrailingSlash(safeUrl(path)), resolvedPathWithoutTrailingSlash) : matchValue$1(safeUrl(path), resolvedPath);
|
|
15023
|
+
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path$1, ignoreTrailingSlash }) => {
|
|
15024
|
+
return ignoreTrailingSlash ? matchValue$1(removeTrailingSlash(safeUrl(path$1)), resolvedPathWithoutTrailingSlash) : matchValue$1(safeUrl(path$1), resolvedPath);
|
|
15025
15025
|
});
|
|
15026
15026
|
if (matchedMockDispatches.length === 0) throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
|
|
15027
15027
|
matchedMockDispatches = matchedMockDispatches.filter(({ method }) => matchValue$1(method, key.method));
|
|
@@ -15064,15 +15064,15 @@ var require_mock_utils = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnp
|
|
|
15064
15064
|
/**
|
|
15065
15065
|
* @param {string} path Path to remove trailing slash from
|
|
15066
15066
|
*/
|
|
15067
|
-
function removeTrailingSlash(path) {
|
|
15068
|
-
while (path.endsWith("/")) path = path.slice(0, -1);
|
|
15069
|
-
if (path.length === 0) path = "/";
|
|
15070
|
-
return path;
|
|
15067
|
+
function removeTrailingSlash(path$1) {
|
|
15068
|
+
while (path$1.endsWith("/")) path$1 = path$1.slice(0, -1);
|
|
15069
|
+
if (path$1.length === 0) path$1 = "/";
|
|
15070
|
+
return path$1;
|
|
15071
15071
|
}
|
|
15072
15072
|
function buildKey$1(opts) {
|
|
15073
|
-
const { path, method, body, headers, query } = opts;
|
|
15073
|
+
const { path: path$1, method, body, headers, query } = opts;
|
|
15074
15074
|
return {
|
|
15075
|
-
path,
|
|
15075
|
+
path: path$1,
|
|
15076
15076
|
method,
|
|
15077
15077
|
body,
|
|
15078
15078
|
headers,
|
|
@@ -15639,10 +15639,10 @@ var require_pending_interceptors_formatter = /* @__PURE__ */ __commonJS$1({ "../
|
|
|
15639
15639
|
});
|
|
15640
15640
|
}
|
|
15641
15641
|
format(pendingInterceptors) {
|
|
15642
|
-
const withPrettyHeaders = pendingInterceptors.map(({ method, path, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
15642
|
+
const withPrettyHeaders = pendingInterceptors.map(({ method, path: path$1, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
15643
15643
|
Method: method,
|
|
15644
15644
|
Origin: origin,
|
|
15645
|
-
Path: path,
|
|
15645
|
+
Path: path$1,
|
|
15646
15646
|
"Status code": statusCode,
|
|
15647
15647
|
Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
|
|
15648
15648
|
Invocations: timesInvoked,
|
|
@@ -15700,8 +15700,8 @@ var require_mock_agent = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnp
|
|
|
15700
15700
|
const acceptNonStandardSearchParameters = this[kMockAgentAcceptsNonStandardSearchParameters];
|
|
15701
15701
|
const dispatchOpts = { ...opts };
|
|
15702
15702
|
if (acceptNonStandardSearchParameters && dispatchOpts.path) {
|
|
15703
|
-
const [path, searchParams] = dispatchOpts.path.split("?");
|
|
15704
|
-
dispatchOpts.path = `${path}?${normalizeSearchParams(searchParams, acceptNonStandardSearchParameters)}`;
|
|
15703
|
+
const [path$1, searchParams] = dispatchOpts.path.split("?");
|
|
15704
|
+
dispatchOpts.path = `${path$1}?${normalizeSearchParams(searchParams, acceptNonStandardSearchParameters)}`;
|
|
15705
15705
|
}
|
|
15706
15706
|
return this[kAgent].dispatch(dispatchOpts, handler);
|
|
15707
15707
|
}
|
|
@@ -16178,10 +16178,10 @@ var require_snapshot_recorder = /* @__PURE__ */ __commonJS$1({ "../../node_modul
|
|
|
16178
16178
|
* @return {Promise<void>} - Resolves when snapshots are loaded
|
|
16179
16179
|
*/
|
|
16180
16180
|
async loadSnapshots(filePath) {
|
|
16181
|
-
const path = filePath || this.#snapshotPath;
|
|
16182
|
-
if (!path) throw new InvalidArgumentError$6("Snapshot path is required");
|
|
16181
|
+
const path$1 = filePath || this.#snapshotPath;
|
|
16182
|
+
if (!path$1) throw new InvalidArgumentError$6("Snapshot path is required");
|
|
16183
16183
|
try {
|
|
16184
|
-
const data$1 = await readFile(resolve$3(path), "utf8");
|
|
16184
|
+
const data$1 = await readFile(resolve$3(path$1), "utf8");
|
|
16185
16185
|
const parsed = JSON.parse(data$1);
|
|
16186
16186
|
if (Array.isArray(parsed)) {
|
|
16187
16187
|
this.#snapshots.clear();
|
|
@@ -16189,7 +16189,7 @@ var require_snapshot_recorder = /* @__PURE__ */ __commonJS$1({ "../../node_modul
|
|
|
16189
16189
|
} else this.#snapshots = new Map(Object.entries(parsed));
|
|
16190
16190
|
} catch (error) {
|
|
16191
16191
|
if (error.code === "ENOENT") this.#snapshots.clear();
|
|
16192
|
-
else throw new UndiciError$1(`Failed to load snapshots from ${path}`, { cause: error });
|
|
16192
|
+
else throw new UndiciError$1(`Failed to load snapshots from ${path$1}`, { cause: error });
|
|
16193
16193
|
}
|
|
16194
16194
|
}
|
|
16195
16195
|
/**
|
|
@@ -16199,9 +16199,9 @@ var require_snapshot_recorder = /* @__PURE__ */ __commonJS$1({ "../../node_modul
|
|
|
16199
16199
|
* @returns {Promise<void>} - Resolves when snapshots are saved
|
|
16200
16200
|
*/
|
|
16201
16201
|
async saveSnapshots(filePath) {
|
|
16202
|
-
const path = filePath || this.#snapshotPath;
|
|
16203
|
-
if (!path) throw new InvalidArgumentError$6("Snapshot path is required");
|
|
16204
|
-
const resolvedPath = resolve$3(path);
|
|
16202
|
+
const path$1 = filePath || this.#snapshotPath;
|
|
16203
|
+
if (!path$1) throw new InvalidArgumentError$6("Snapshot path is required");
|
|
16204
|
+
const resolvedPath = resolve$3(path$1);
|
|
16205
16205
|
await mkdir(dirname$2(resolvedPath), { recursive: true });
|
|
16206
16206
|
const data$1 = Array.from(this.#snapshots.entries()).map(([hash, snapshot]) => ({
|
|
16207
16207
|
hash,
|
|
@@ -16768,11 +16768,11 @@ var require_redirect_handler = /* @__PURE__ */ __commonJS$1({ "../../node_module
|
|
|
16768
16768
|
return;
|
|
16769
16769
|
}
|
|
16770
16770
|
const { origin, pathname, search } = util$10.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
|
|
16771
|
-
const path = search ? `${pathname}${search}` : pathname;
|
|
16772
|
-
const redirectUrlString = `${origin}${path}`;
|
|
16771
|
+
const path$1 = search ? `${pathname}${search}` : pathname;
|
|
16772
|
+
const redirectUrlString = `${origin}${path$1}`;
|
|
16773
16773
|
for (const historyUrl of this.history) if (historyUrl.toString() === redirectUrlString) throw new InvalidArgumentError$3(`Redirect loop detected. Cannot redirect to ${origin}. This typically happens when using a Client or Pool with cross-origin redirects. Use an Agent for cross-origin redirects.`);
|
|
16774
16774
|
this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
|
|
16775
|
-
this.opts.path = path;
|
|
16775
|
+
this.opts.path = path$1;
|
|
16776
16776
|
this.opts.origin = origin;
|
|
16777
16777
|
this.opts.query = null;
|
|
16778
16778
|
}
|
|
@@ -21730,10 +21730,10 @@ var require_fetch = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/und
|
|
|
21730
21730
|
const url = requestCurrentURL(request$2);
|
|
21731
21731
|
/** @type {import('../../..').Agent} */
|
|
21732
21732
|
const agent = fetchParams.controller.dispatcher;
|
|
21733
|
-
const path = url.pathname + url.search;
|
|
21733
|
+
const path$1 = url.pathname + url.search;
|
|
21734
21734
|
const hasTrailingQuestionMark = url.search.length === 0 && url.href[url.href.length - url.hash.length - 1] === "?";
|
|
21735
21735
|
return new Promise((resolve$4, reject) => agent.dispatch({
|
|
21736
|
-
path: hasTrailingQuestionMark ? `${path}?` : path,
|
|
21736
|
+
path: hasTrailingQuestionMark ? `${path$1}?` : path$1,
|
|
21737
21737
|
origin: url.origin,
|
|
21738
21738
|
method: request$2.method,
|
|
21739
21739
|
body: agent.isMockActive ? request$2.body && (request$2.body.source || request$2.body.stream) : body,
|
|
@@ -22515,9 +22515,9 @@ var require_util$2 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/un
|
|
|
22515
22515
|
* path-value = <any CHAR except CTLs or ";">
|
|
22516
22516
|
* @param {string} path
|
|
22517
22517
|
*/
|
|
22518
|
-
function validateCookiePath(path) {
|
|
22519
|
-
for (let i$1 = 0; i$1 < path.length; ++i$1) {
|
|
22520
|
-
const code = path.charCodeAt(i$1);
|
|
22518
|
+
function validateCookiePath(path$1) {
|
|
22519
|
+
for (let i$1 = 0; i$1 < path$1.length; ++i$1) {
|
|
22520
|
+
const code = path$1.charCodeAt(i$1);
|
|
22521
22521
|
if (code < 32 || code === 127 || code === 59) throw new Error("Invalid cookie path");
|
|
22522
22522
|
}
|
|
22523
22523
|
}
|
|
@@ -25625,9 +25625,9 @@ var require_undici = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/un
|
|
|
25625
25625
|
if (opts != null && typeof opts !== "object") throw new InvalidArgumentError("invalid opts");
|
|
25626
25626
|
if (opts && opts.path != null) {
|
|
25627
25627
|
if (typeof opts.path !== "string") throw new InvalidArgumentError("invalid opts.path");
|
|
25628
|
-
let path = opts.path;
|
|
25629
|
-
if (!opts.path.startsWith("/")) path = `/${path}`;
|
|
25630
|
-
url = new URL(util$3.parseOrigin(url).origin + path);
|
|
25628
|
+
let path$1 = opts.path;
|
|
25629
|
+
if (!opts.path.startsWith("/")) path$1 = `/${path$1}`;
|
|
25630
|
+
url = new URL(util$3.parseOrigin(url).origin + path$1);
|
|
25631
25631
|
} else {
|
|
25632
25632
|
if (!opts) opts = typeof url === "object" ? url : {};
|
|
25633
25633
|
url = util$3.parseURL(url);
|
|
@@ -30933,7 +30933,7 @@ function getGlobalConfigPath({ appName = "wrangler", leadingDot = true, useLegac
|
|
|
30933
30933
|
const dirName = `${leadingDot ? "." : ""}${appName}`;
|
|
30934
30934
|
const configDir = mod_esm_default(dirName).config();
|
|
30935
30935
|
if (useLegacyHomeDir) {
|
|
30936
|
-
const legacyConfigDir =
|
|
30936
|
+
const legacyConfigDir = path.join(os.homedir(), dirName);
|
|
30937
30937
|
if (isDirectory(legacyConfigDir)) return legacyConfigDir;
|
|
30938
30938
|
}
|
|
30939
30939
|
return configDir;
|
|
@@ -31038,7 +31038,7 @@ var getBuildPlatformFromEnv = getEnvironmentVariableFactory({ variableName: "WRA
|
|
|
31038
31038
|
var getRegistryPath = getEnvironmentVariableFactory({
|
|
31039
31039
|
variableName: "WRANGLER_REGISTRY_PATH",
|
|
31040
31040
|
defaultValue() {
|
|
31041
|
-
return
|
|
31041
|
+
return path.join(getGlobalWranglerConfigPath(), "registry");
|
|
31042
31042
|
}
|
|
31043
31043
|
});
|
|
31044
31044
|
var getD1ExtraLocationChoices = getEnvironmentVariableFactory({ variableName: "WRANGLER_D1_EXTRA_LOCATION_CHOICES" });
|
|
@@ -31454,7 +31454,7 @@ function isPagesConfig(rawConfig) {
|
|
|
31454
31454
|
}
|
|
31455
31455
|
__name(isPagesConfig, "isPagesConfig");
|
|
31456
31456
|
function normalizeAndValidateConfig(rawConfig, configPath, userConfigPath, args, preserveOriginalMain = false) {
|
|
31457
|
-
const diagnostics = new Diagnostics(`Processing ${configPath ?
|
|
31457
|
+
const diagnostics = new Diagnostics(`Processing ${configPath ? path.relative(process.cwd(), configPath) : "wrangler"} configuration:`);
|
|
31458
31458
|
validateOptionalProperty(diagnostics, "", "legacy_env", rawConfig.legacy_env, "boolean");
|
|
31459
31459
|
validateOptionalProperty(diagnostics, "", "send_metrics", rawConfig.send_metrics, "boolean");
|
|
31460
31460
|
validateOptionalProperty(diagnostics, "", "keep_vars", rawConfig.keep_vars, "boolean");
|
|
@@ -31558,34 +31558,34 @@ function normalizeAndValidateBuild(diagnostics, rawEnv, rawBuild, configPath) {
|
|
|
31558
31558
|
else validateOptionalProperty(diagnostics, "build", "watch_dir", watch_dir, "string");
|
|
31559
31559
|
return {
|
|
31560
31560
|
command,
|
|
31561
|
-
watch_dir: command && configPath ? Array.isArray(watch_dir) ? watch_dir.map((dir) =>
|
|
31561
|
+
watch_dir: command && configPath ? Array.isArray(watch_dir) ? watch_dir.map((dir) => path.relative(process.cwd(), path.join(path.dirname(configPath), `${dir}`))) : path.relative(process.cwd(), path.join(path.dirname(configPath), `${watch_dir}`)) : watch_dir,
|
|
31562
31562
|
cwd
|
|
31563
31563
|
};
|
|
31564
31564
|
}
|
|
31565
31565
|
__name(normalizeAndValidateBuild, "normalizeAndValidateBuild");
|
|
31566
31566
|
function normalizeAndValidateMainField(configPath, rawMain) {
|
|
31567
|
-
const configDir =
|
|
31567
|
+
const configDir = path.dirname(configPath ?? "wrangler.toml");
|
|
31568
31568
|
if (rawMain !== void 0) if (typeof rawMain === "string") {
|
|
31569
|
-
const directory =
|
|
31570
|
-
return
|
|
31569
|
+
const directory = path.resolve(configDir);
|
|
31570
|
+
return path.resolve(directory, rawMain);
|
|
31571
31571
|
} else return rawMain;
|
|
31572
31572
|
else return;
|
|
31573
31573
|
}
|
|
31574
31574
|
__name(normalizeAndValidateMainField, "normalizeAndValidateMainField");
|
|
31575
31575
|
function normalizeAndValidateBaseDirField(configPath, rawDir) {
|
|
31576
|
-
const configDir =
|
|
31576
|
+
const configDir = path.dirname(configPath ?? "wrangler.toml");
|
|
31577
31577
|
if (rawDir !== void 0) if (typeof rawDir === "string") {
|
|
31578
|
-
const directory =
|
|
31579
|
-
return
|
|
31578
|
+
const directory = path.resolve(configDir);
|
|
31579
|
+
return path.resolve(directory, rawDir);
|
|
31580
31580
|
} else return rawDir;
|
|
31581
31581
|
else return;
|
|
31582
31582
|
}
|
|
31583
31583
|
__name(normalizeAndValidateBaseDirField, "normalizeAndValidateBaseDirField");
|
|
31584
31584
|
function normalizeAndValidatePagesBuildOutputDir(configPath, rawPagesDir) {
|
|
31585
|
-
const configDir =
|
|
31585
|
+
const configDir = path.dirname(configPath ?? "wrangler.toml");
|
|
31586
31586
|
if (rawPagesDir !== void 0) if (typeof rawPagesDir === "string") {
|
|
31587
|
-
const directory =
|
|
31588
|
-
return
|
|
31587
|
+
const directory = path.resolve(configDir);
|
|
31588
|
+
return path.resolve(directory, rawPagesDir);
|
|
31589
31589
|
} else return rawPagesDir;
|
|
31590
31590
|
else return;
|
|
31591
31591
|
}
|
|
@@ -31638,7 +31638,7 @@ function normalizeAndValidateSite(diagnostics, configPath, rawConfig, mainEntryP
|
|
|
31638
31638
|
validateOptionalProperty(diagnostics, "site", "entry-point", rawConfig.site["entry-point"], "string");
|
|
31639
31639
|
deprecated(diagnostics, rawConfig, `site.entry-point`, `Delete the \`site.entry-point\` field, then add the top level \`main\` field to your configuration file:
|
|
31640
31640
|
\`\`\`
|
|
31641
|
-
main = "${
|
|
31641
|
+
main = "${path.join(String(rawConfig.site["entry-point"]) || "workers-site", path.extname(String(rawConfig.site["entry-point"]) || "workers-site") ? "" : "index.js")}"
|
|
31642
31642
|
\`\`\``, false, void 0, "warning");
|
|
31643
31643
|
let siteEntryPoint = rawConfig.site["entry-point"];
|
|
31644
31644
|
if (!mainEntryPoint && !siteEntryPoint) {
|
|
@@ -31651,7 +31651,7 @@ main = "workers-site/index.js"
|
|
|
31651
31651
|
} else if (mainEntryPoint && siteEntryPoint) diagnostics.errors.push(`Don't define both the \`main\` and \`site.entry-point\` fields in your configuration.
|
|
31652
31652
|
They serve the same purpose: to point to the entry-point of your worker.
|
|
31653
31653
|
Delete the deprecated \`site.entry-point\` field from your config.`);
|
|
31654
|
-
if (configPath && siteEntryPoint) siteEntryPoint =
|
|
31654
|
+
if (configPath && siteEntryPoint) siteEntryPoint = path.relative(process.cwd(), path.join(path.dirname(configPath), siteEntryPoint));
|
|
31655
31655
|
return {
|
|
31656
31656
|
bucket,
|
|
31657
31657
|
"entry-point": siteEntryPoint,
|
|
@@ -31683,7 +31683,7 @@ function normalizeAndValidateModulePaths(diagnostics, configPath, field, rawMapp
|
|
|
31683
31683
|
if (rawMapping === void 0) return;
|
|
31684
31684
|
const mapping = {};
|
|
31685
31685
|
for (const [name, filePath] of Object.entries(rawMapping)) if (isString$2(diagnostics, `${field}['${name}']`, filePath, void 0)) {
|
|
31686
|
-
if (configPath) mapping[name] = configPath ?
|
|
31686
|
+
if (configPath) mapping[name] = configPath ? path.relative(process.cwd(), path.join(path.dirname(configPath), filePath)) : filePath;
|
|
31687
31687
|
}
|
|
31688
31688
|
return mapping;
|
|
31689
31689
|
}
|
|
@@ -31941,7 +31941,7 @@ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, isDisp
|
|
|
31941
31941
|
__name(normalizeAndValidateEnvironment, "normalizeAndValidateEnvironment");
|
|
31942
31942
|
function validateAndNormalizeTsconfig(diagnostics, topLevelEnv, rawEnv, configPath) {
|
|
31943
31943
|
const tsconfig = inheritable(diagnostics, topLevelEnv, rawEnv, "tsconfig", isString$2, void 0);
|
|
31944
|
-
return configPath && tsconfig ?
|
|
31944
|
+
return configPath && tsconfig ? path.relative(process.cwd(), path.join(path.dirname(configPath), tsconfig)) : tsconfig;
|
|
31945
31945
|
}
|
|
31946
31946
|
__name(validateAndNormalizeTsconfig, "validateAndNormalizeTsconfig");
|
|
31947
31947
|
var validateAndNormalizeRules = /* @__PURE__ */ __name((diagnostics, topLevelEnv, rawEnv, envName) => {
|
|
@@ -32441,9 +32441,9 @@ function validateContainerApp(envName, topLevelName, configPath) {
|
|
|
32441
32441
|
let resolvedBuildContextPath = void 0;
|
|
32442
32442
|
try {
|
|
32443
32443
|
if (isDockerfile(resolvedImage, configPath)) {
|
|
32444
|
-
const baseDir = configPath ?
|
|
32445
|
-
resolvedImage =
|
|
32446
|
-
resolvedBuildContextPath = containerAppOptional.image_build_context ?
|
|
32444
|
+
const baseDir = configPath ? path.dirname(configPath) : process.cwd();
|
|
32445
|
+
resolvedImage = path.resolve(baseDir, resolvedImage);
|
|
32446
|
+
resolvedBuildContextPath = containerAppOptional.image_build_context ? path.resolve(baseDir, containerAppOptional.image_build_context) : path.dirname(resolvedImage);
|
|
32447
32447
|
}
|
|
32448
32448
|
} catch (err) {
|
|
32449
32449
|
if (err instanceof Error && err.message) diagnostics.errors.push(err.message);
|
|
@@ -33615,8 +33615,8 @@ function isRemoteValid(targetObject, fieldPath, diagnostics) {
|
|
|
33615
33615
|
}
|
|
33616
33616
|
__name(isRemoteValid, "isRemoteValid");
|
|
33617
33617
|
function isDockerfile(imagePath, configPath) {
|
|
33618
|
-
const baseDir = configPath ?
|
|
33619
|
-
const maybeDockerfile =
|
|
33618
|
+
const baseDir = configPath ? path.dirname(configPath) : process.cwd();
|
|
33619
|
+
const maybeDockerfile = path.resolve(baseDir, imagePath);
|
|
33620
33620
|
if (fs2.existsSync(maybeDockerfile)) {
|
|
33621
33621
|
if (isDirectory(maybeDockerfile)) throw new UserError(`${imagePath} is a directory, you should specify a path to the Dockerfile`, { telemetryMessage: false });
|
|
33622
33622
|
return true;
|
|
@@ -33768,7 +33768,7 @@ __name(validateDurableObjectBinding2, "validateDurableObjectBinding");
|
|
|
33768
33768
|
var import_signal_exit = __toESM(require_signal_exit());
|
|
33769
33769
|
function getWranglerHiddenDirPath(projectRoot) {
|
|
33770
33770
|
projectRoot ??= process.cwd();
|
|
33771
|
-
return
|
|
33771
|
+
return path.join(projectRoot, ".wrangler");
|
|
33772
33772
|
}
|
|
33773
33773
|
__name(getWranglerHiddenDirPath, "getWranglerHiddenDirPath");
|
|
33774
33774
|
var STALE_WRANGLER_TMP_DIR_MS = 1440 * 60 * 1e3;
|
|
@@ -33785,7 +33785,7 @@ function sweepStaleWranglerTmpDirs(tmpRoot) {
|
|
|
33785
33785
|
const cutoff = Date.now() - STALE_WRANGLER_TMP_DIR_MS;
|
|
33786
33786
|
for (const entry of entries) {
|
|
33787
33787
|
if (!entry.isDirectory()) continue;
|
|
33788
|
-
const entryPath =
|
|
33788
|
+
const entryPath = path.join(tmpRoot, entry.name);
|
|
33789
33789
|
try {
|
|
33790
33790
|
if (fs2.statSync(entryPath).mtimeMs < cutoff) removeDirSync(entryPath);
|
|
33791
33791
|
} catch {}
|
|
@@ -33793,10 +33793,10 @@ function sweepStaleWranglerTmpDirs(tmpRoot) {
|
|
|
33793
33793
|
}
|
|
33794
33794
|
__name(sweepStaleWranglerTmpDirs, "sweepStaleWranglerTmpDirs");
|
|
33795
33795
|
function getWranglerTmpDir(projectRoot, prefix, cleanup = true) {
|
|
33796
|
-
const tmpRoot =
|
|
33796
|
+
const tmpRoot = path.join(getWranglerHiddenDirPath(projectRoot), "tmp");
|
|
33797
33797
|
fs2.mkdirSync(tmpRoot, { recursive: true });
|
|
33798
33798
|
sweepStaleWranglerTmpDirs(tmpRoot);
|
|
33799
|
-
const tmpPrefix =
|
|
33799
|
+
const tmpPrefix = path.join(tmpRoot, `${prefix}-`);
|
|
33800
33800
|
const tmpDir = fs2.realpathSync(fs2.mkdtempSync(tmpPrefix));
|
|
33801
33801
|
const cleanupDir = /* @__PURE__ */ __name(() => {
|
|
33802
33802
|
if (cleanup) try {
|
|
@@ -36926,8 +36926,8 @@ const postfixRE = /[?#].*$/;
|
|
|
36926
36926
|
function cleanUrl(url) {
|
|
36927
36927
|
return url.replace(postfixRE, "");
|
|
36928
36928
|
}
|
|
36929
|
-
function withTrailingSlash(path) {
|
|
36930
|
-
return path.endsWith("/") ? path : `${path}/`;
|
|
36929
|
+
function withTrailingSlash(path$1) {
|
|
36930
|
+
return path$1.endsWith("/") ? path$1 : `${path$1}/`;
|
|
36931
36931
|
}
|
|
36932
36932
|
function createRequestHandler(handler) {
|
|
36933
36933
|
return async (req, res, next) => {
|
|
@@ -37164,8 +37164,11 @@ var PluginContext = class {
|
|
|
37164
37164
|
getWorkerConfig(environmentName) {
|
|
37165
37165
|
return this.#getWorker(environmentName)?.config;
|
|
37166
37166
|
}
|
|
37167
|
+
getWorkerNewConfig(environmentName) {
|
|
37168
|
+
return this.#getWorker(environmentName)?.parsedNewConfig;
|
|
37169
|
+
}
|
|
37167
37170
|
get allWorkerConfigs() {
|
|
37168
|
-
if (this.resolvedPluginConfig.type === "preview") return this.resolvedPluginConfig.workers;
|
|
37171
|
+
if (this.resolvedPluginConfig.type === "preview") return this.resolvedPluginConfig.workers.map((worker) => worker.config);
|
|
37169
37172
|
return Array.from(this.resolvedPluginConfig.environmentNameToWorkerMap.values()).map((worker) => worker.config);
|
|
37170
37173
|
}
|
|
37171
37174
|
get entryWorkerConfig() {
|
|
@@ -37296,6 +37299,138 @@ const defuArrayFn = createDefu((object, key, currentValue) => {
|
|
|
37296
37299
|
}
|
|
37297
37300
|
});
|
|
37298
37301
|
|
|
37302
|
+
//#endregion
|
|
37303
|
+
//#region src/build-output.ts
|
|
37304
|
+
/**
|
|
37305
|
+
* Initial draft version of the Build Output API.
|
|
37306
|
+
*
|
|
37307
|
+
* Will move to `v1` when the spec stabilises.
|
|
37308
|
+
*/
|
|
37309
|
+
const BUILD_OUTPUT_VERSION = "v0";
|
|
37310
|
+
/**
|
|
37311
|
+
* Project-relative root.
|
|
37312
|
+
*/
|
|
37313
|
+
const BUILD_OUTPUT_ROOT = ".cloudflare/output";
|
|
37314
|
+
/**
|
|
37315
|
+
* Filename of the per-Worker config.
|
|
37316
|
+
*/
|
|
37317
|
+
const WORKER_CONFIG_FILENAME = "worker.config.json";
|
|
37318
|
+
/**
|
|
37319
|
+
* Absolute path to the Build Output API root for the current project.
|
|
37320
|
+
*/
|
|
37321
|
+
function getBuildOutputDir(root) {
|
|
37322
|
+
return nodePath.resolve(root, BUILD_OUTPUT_ROOT);
|
|
37323
|
+
}
|
|
37324
|
+
/**
|
|
37325
|
+
* Clean the build output directory
|
|
37326
|
+
*
|
|
37327
|
+
* Called once at the start of each build
|
|
37328
|
+
*/
|
|
37329
|
+
function cleanBuildOutputDir(root) {
|
|
37330
|
+
removeDirSync(getBuildOutputDir(root));
|
|
37331
|
+
}
|
|
37332
|
+
/**
|
|
37333
|
+
* Absolute path to the workers output directory
|
|
37334
|
+
*/
|
|
37335
|
+
function getWorkersDir(root) {
|
|
37336
|
+
return nodePath.join(getBuildOutputDir(root), BUILD_OUTPUT_VERSION, "workers");
|
|
37337
|
+
}
|
|
37338
|
+
/**
|
|
37339
|
+
* Absolute path to `worker.config.json` for a given Worker.
|
|
37340
|
+
*/
|
|
37341
|
+
function getWorkerConfigPath(root, workerName) {
|
|
37342
|
+
return nodePath.join(getWorkersDir(root), workerName, WORKER_CONFIG_FILENAME);
|
|
37343
|
+
}
|
|
37344
|
+
/**
|
|
37345
|
+
* Absolute path to the bundle directory for a given Worker.
|
|
37346
|
+
*/
|
|
37347
|
+
function getWorkerBundleDir(root, workerName) {
|
|
37348
|
+
return nodePath.join(getWorkersDir(root), workerName, "bundle");
|
|
37349
|
+
}
|
|
37350
|
+
/**
|
|
37351
|
+
* Absolute path to the assets directory for a given Worker.
|
|
37352
|
+
*/
|
|
37353
|
+
function getWorkerAssetsDir(root, workerName) {
|
|
37354
|
+
return nodePath.join(getWorkersDir(root), workerName, "assets");
|
|
37355
|
+
}
|
|
37356
|
+
/**
|
|
37357
|
+
* Map a bundle filename to its declared module type.
|
|
37358
|
+
*/
|
|
37359
|
+
function detectModuleType(filename) {
|
|
37360
|
+
switch (nodePath.extname(filename).toLowerCase()) {
|
|
37361
|
+
case ".js":
|
|
37362
|
+
case ".mjs": return "esm";
|
|
37363
|
+
case ".wasm": return "wasm";
|
|
37364
|
+
case ".bin": return "data";
|
|
37365
|
+
case ".txt":
|
|
37366
|
+
case ".html":
|
|
37367
|
+
case ".sql": return "text";
|
|
37368
|
+
case ".json": return "json";
|
|
37369
|
+
case ".map": return "sourcemap";
|
|
37370
|
+
default: return "data";
|
|
37371
|
+
}
|
|
37372
|
+
}
|
|
37373
|
+
/**
|
|
37374
|
+
* Write the output `worker.config.json` for a given Worker to the Build
|
|
37375
|
+
* Output API tree.
|
|
37376
|
+
*
|
|
37377
|
+
* - Workers mode: `manifest` is provided (bundle/ present on disk).
|
|
37378
|
+
* - Assets-only mode: `manifest` is omitted (no bundle/ directory).
|
|
37379
|
+
*/
|
|
37380
|
+
function writeOutputWorkerConfig(root, parsedConfig, manifest) {
|
|
37381
|
+
const { entrypoint: _entrypoint,...rest } = parsedConfig;
|
|
37382
|
+
const outputConfig = {
|
|
37383
|
+
...rest,
|
|
37384
|
+
manifest
|
|
37385
|
+
};
|
|
37386
|
+
const workerOutputDir = nodePath.join(getWorkersDir(root), outputConfig.name);
|
|
37387
|
+
fs$1.mkdirSync(workerOutputDir, { recursive: true });
|
|
37388
|
+
const configPath = getWorkerConfigPath(root, outputConfig.name);
|
|
37389
|
+
fs$1.writeFileSync(configPath, JSON.stringify(outputConfig));
|
|
37390
|
+
}
|
|
37391
|
+
|
|
37392
|
+
//#endregion
|
|
37393
|
+
//#region src/build-output-preview.ts
|
|
37394
|
+
/**
|
|
37395
|
+
* Read the Build Output API at `<root>/.cloudflare/output/v0/workers/`
|
|
37396
|
+
* and reconstruct a `BuildOutputPreviewWorker` for each Worker
|
|
37397
|
+
*/
|
|
37398
|
+
async function readBuildOutputWorkers(root) {
|
|
37399
|
+
const workersDir = getWorkersDir(root);
|
|
37400
|
+
if (!fs$1.existsSync(workersDir)) throw new Error(`No Build Output API tree found at ${workersDir}.`);
|
|
37401
|
+
const workerNames = fs$1.readdirSync(workersDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
37402
|
+
if (workerNames.length === 0) throw new Error(`Build Output API tree at ${workersDir} contains no Worker directories.`);
|
|
37403
|
+
const { OutputWorkerSchema, convertToWranglerConfig } = await import("./dist-Cr__Sz5N.mjs");
|
|
37404
|
+
return workerNames.map((workerName) => {
|
|
37405
|
+
const configPath = getWorkerConfigPath(root, workerName);
|
|
37406
|
+
assert(fs$1.existsSync(configPath), `Build Output API: missing \`${WORKER_CONFIG_FILENAME}\` for Worker "${workerName}" at ${configPath}.`);
|
|
37407
|
+
const { manifest,...inputShape } = OutputWorkerSchema.parse(JSON.parse(fs$1.readFileSync(configPath, "utf-8")));
|
|
37408
|
+
const { config, diagnostics } = normalizeAndValidateConfig(convertToWranglerConfig(inputShape), void 0, void 0, {}, true);
|
|
37409
|
+
if (diagnostics.hasWarnings()) console.warn(diagnostics.renderWarnings());
|
|
37410
|
+
if (diagnostics.hasErrors()) throw new Error(diagnostics.renderErrors());
|
|
37411
|
+
const bundleDir = getWorkerBundleDir(root, workerName);
|
|
37412
|
+
const assetsDir = getWorkerAssetsDir(root, workerName);
|
|
37413
|
+
if (fs$1.existsSync(assetsDir)) config.assets = {
|
|
37414
|
+
...config.assets ?? {},
|
|
37415
|
+
directory: assetsDir
|
|
37416
|
+
};
|
|
37417
|
+
let bundle;
|
|
37418
|
+
if (manifest) {
|
|
37419
|
+
config.main = manifest.mainModule;
|
|
37420
|
+
bundle = {
|
|
37421
|
+
rootPath: bundleDir,
|
|
37422
|
+
mainModule: manifest.mainModule,
|
|
37423
|
+
modules: manifest.modules
|
|
37424
|
+
};
|
|
37425
|
+
}
|
|
37426
|
+
return {
|
|
37427
|
+
source: "build-output",
|
|
37428
|
+
config,
|
|
37429
|
+
bundle
|
|
37430
|
+
};
|
|
37431
|
+
});
|
|
37432
|
+
}
|
|
37433
|
+
|
|
37299
37434
|
//#endregion
|
|
37300
37435
|
//#region src/deploy-config.ts
|
|
37301
37436
|
function getDeployConfigPath(root) {
|
|
@@ -42429,15 +42564,15 @@ function hasTrailingSlash(input = "", respectQueryAndFragment) {
|
|
|
42429
42564
|
function withTrailingSlash$1(input = "", respectQueryAndFragment) {
|
|
42430
42565
|
if (!respectQueryAndFragment) return input.endsWith("/") ? input : input + "/";
|
|
42431
42566
|
if (hasTrailingSlash(input, true)) return input || "/";
|
|
42432
|
-
let path = input;
|
|
42567
|
+
let path$1 = input;
|
|
42433
42568
|
let fragment = "";
|
|
42434
42569
|
const fragmentIndex = input.indexOf("#");
|
|
42435
42570
|
if (fragmentIndex >= 0) {
|
|
42436
|
-
path = input.slice(0, fragmentIndex);
|
|
42571
|
+
path$1 = input.slice(0, fragmentIndex);
|
|
42437
42572
|
fragment = input.slice(fragmentIndex);
|
|
42438
|
-
if (!path) return fragment;
|
|
42573
|
+
if (!path$1) return fragment;
|
|
42439
42574
|
}
|
|
42440
|
-
const [s0, ...s] = path.split("?");
|
|
42575
|
+
const [s0, ...s] = path$1.split("?");
|
|
42441
42576
|
return s0 + "/" + (s.length > 0 ? `?${s.join("?")}` : "") + fragment;
|
|
42442
42577
|
}
|
|
42443
42578
|
function isNonEmptyURL(url) {
|
|
@@ -42463,8 +42598,8 @@ const isAbsolute$2 = function(p$1) {
|
|
|
42463
42598
|
//#endregion
|
|
42464
42599
|
//#region ../../node_modules/.pnpm/mlly@1.7.4/node_modules/mlly/dist/index.mjs
|
|
42465
42600
|
const BUILTIN_MODULES = new Set(builtinModules);
|
|
42466
|
-
function normalizeSlash(path) {
|
|
42467
|
-
return path.replace(/\\/g, "/");
|
|
42601
|
+
function normalizeSlash(path$1) {
|
|
42602
|
+
return path$1.replace(/\\/g, "/");
|
|
42468
42603
|
}
|
|
42469
42604
|
/**
|
|
42470
42605
|
* @typedef ErrnoExceptionFields
|
|
@@ -42584,8 +42719,8 @@ codes.ERR_INVALID_PACKAGE_CONFIG = createError(
|
|
|
42584
42719
|
* @param {string} [base]
|
|
42585
42720
|
* @param {string} [message]
|
|
42586
42721
|
*/
|
|
42587
|
-
(path, base, message) => {
|
|
42588
|
-
return `Invalid package config ${path}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
|
|
42722
|
+
(path$1, base, message) => {
|
|
42723
|
+
return `Invalid package config ${path$1}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
|
|
42589
42724
|
},
|
|
42590
42725
|
Error
|
|
42591
42726
|
);
|
|
@@ -42615,8 +42750,8 @@ codes.ERR_MODULE_NOT_FOUND = createError(
|
|
|
42615
42750
|
* @param {string} base
|
|
42616
42751
|
* @param {boolean} [exactUrl]
|
|
42617
42752
|
*/
|
|
42618
|
-
(path, base, exactUrl = false) => {
|
|
42619
|
-
return `Cannot find ${exactUrl ? "module" : "package"} '${path}' imported from ${base}`;
|
|
42753
|
+
(path$1, base, exactUrl = false) => {
|
|
42754
|
+
return `Cannot find ${exactUrl ? "module" : "package"} '${path$1}' imported from ${base}`;
|
|
42620
42755
|
},
|
|
42621
42756
|
Error
|
|
42622
42757
|
);
|
|
@@ -42654,8 +42789,8 @@ codes.ERR_UNKNOWN_FILE_EXTENSION = createError(
|
|
|
42654
42789
|
* @param {string} extension
|
|
42655
42790
|
* @param {string} path
|
|
42656
42791
|
*/
|
|
42657
|
-
(extension, path) => {
|
|
42658
|
-
return `Unknown file extension "${extension}" for ${path}`;
|
|
42792
|
+
(extension, path$1) => {
|
|
42793
|
+
return `Unknown file extension "${extension}" for ${path$1}`;
|
|
42659
42794
|
},
|
|
42660
42795
|
TypeError
|
|
42661
42796
|
);
|
|
@@ -42812,7 +42947,7 @@ function read(jsonPath, { base, specifier }) {
|
|
|
42812
42947
|
/** @type {string | undefined} */
|
|
42813
42948
|
let string;
|
|
42814
42949
|
try {
|
|
42815
|
-
string = fs2.readFileSync(
|
|
42950
|
+
string = fs2.readFileSync(path.toNamespacedPath(jsonPath), "utf8");
|
|
42816
42951
|
} catch (error) {
|
|
42817
42952
|
const exception = error;
|
|
42818
42953
|
if (exception.code !== "ENOENT") throw exception;
|
|
@@ -43018,15 +43153,15 @@ function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
|
|
|
43018
43153
|
const packagePath = fileURLToPath(new URL$1(".", packageJsonUrl));
|
|
43019
43154
|
const basePath = fileURLToPath(base);
|
|
43020
43155
|
if (!main) process$1.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");
|
|
43021
|
-
else if (
|
|
43156
|
+
else if (path.resolve(packagePath, main) !== urlPath) process$1.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");
|
|
43022
43157
|
}
|
|
43023
43158
|
/**
|
|
43024
43159
|
* @param {string} path
|
|
43025
43160
|
* @returns {Stats | undefined}
|
|
43026
43161
|
*/
|
|
43027
|
-
function tryStatSync(path) {
|
|
43162
|
+
function tryStatSync(path$1) {
|
|
43028
43163
|
try {
|
|
43029
|
-
return statSync(path);
|
|
43164
|
+
return statSync(path$1);
|
|
43030
43165
|
} catch {}
|
|
43031
43166
|
}
|
|
43032
43167
|
/**
|
|
@@ -43125,7 +43260,7 @@ function finalizeResolution(resolved, base, preserveSymlinks) {
|
|
|
43125
43260
|
{
|
|
43126
43261
|
const real = realpathSync(filePath);
|
|
43127
43262
|
const { search, hash } = resolved;
|
|
43128
|
-
resolved = pathToFileURL(real + (filePath.endsWith(
|
|
43263
|
+
resolved = pathToFileURL(real + (filePath.endsWith(path.sep) ? "/" : ""));
|
|
43129
43264
|
resolved.search = search;
|
|
43130
43265
|
resolved.hash = hash;
|
|
43131
43266
|
}
|
|
@@ -44183,8 +44318,14 @@ const allowedWranglerConfigExtensions = [
|
|
|
44183
44318
|
//#region src/plugin-config.ts
|
|
44184
44319
|
function normalizeNewConfig(option) {
|
|
44185
44320
|
if (option === void 0 || option === false) return;
|
|
44186
|
-
if (option === true) return {
|
|
44187
|
-
|
|
44321
|
+
if (option === true) return {
|
|
44322
|
+
types: { generate: true },
|
|
44323
|
+
cfBuildOutput: false
|
|
44324
|
+
};
|
|
44325
|
+
return {
|
|
44326
|
+
types: { generate: option.types?.generate ?? true },
|
|
44327
|
+
cfBuildOutput: option.cfBuildOutput ?? false
|
|
44328
|
+
};
|
|
44188
44329
|
}
|
|
44189
44330
|
function filterEntryWorkerConfig(config) {
|
|
44190
44331
|
const { topLevelName: _topLevelName, name: _name,...filteredConfig } = config;
|
|
@@ -44250,20 +44391,30 @@ async function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
44250
44391
|
const prefixedEnv = vite.loadEnv(viteEnv.mode, root, ["CLOUDFLARE_", "WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_"]);
|
|
44251
44392
|
Object.assign(process.env, prefixedEnv);
|
|
44252
44393
|
const remoteBindings = prefixedEnv.CLOUDFLARE_VITE_FORCE_LOCAL === "true" ? false : pluginConfig.remoteBindings ?? true;
|
|
44253
|
-
if (viteEnv.isPreview)
|
|
44254
|
-
|
|
44255
|
-
|
|
44256
|
-
|
|
44257
|
-
|
|
44258
|
-
|
|
44394
|
+
if (viteEnv.isPreview) {
|
|
44395
|
+
const workers = resolvedNewConfig?.cfBuildOutput ? await readBuildOutputWorkers(root) : getWorkerConfigs(root, !!process.env.CLOUDFLARE_VITE_BUILD).map((config) => ({
|
|
44396
|
+
source: "legacy",
|
|
44397
|
+
config
|
|
44398
|
+
}));
|
|
44399
|
+
return {
|
|
44400
|
+
...shared,
|
|
44401
|
+
remoteBindings,
|
|
44402
|
+
type: "preview",
|
|
44403
|
+
workers
|
|
44404
|
+
};
|
|
44405
|
+
}
|
|
44259
44406
|
const configPaths = /* @__PURE__ */ new Set();
|
|
44260
44407
|
const cloudflareEnv = prefixedEnv.CLOUDFLARE_ENV;
|
|
44261
44408
|
const validateAndAddEnvironmentName = createEnvironmentNameValidator();
|
|
44262
44409
|
let configPath;
|
|
44263
44410
|
let rawConfigOverride;
|
|
44411
|
+
let parsedNewConfig;
|
|
44264
44412
|
if (resolvedNewConfig) {
|
|
44265
44413
|
if (pluginConfig.configPath) throw new Error("`configPath` cannot be used together with `experimental.newConfig`. Configure the entry Worker via `cloudflare.config.ts` instead.");
|
|
44266
44414
|
if (pluginConfig.auxiliaryWorkers?.length) throw new Error("`auxiliaryWorkers` are not yet supported when `experimental.newConfig` is enabled.");
|
|
44415
|
+
if (pluginConfig.experimental?.prerenderWorker) throw new Error("`experimental.prerenderWorker` is not yet supported when `experimental.newConfig` is enabled.");
|
|
44416
|
+
if (typeof pluginConfig.config !== "undefined") throw new Error("`config` cannot be used together with `experimental.newConfig`. Configure the entry Worker via `cloudflare.config.ts` instead.");
|
|
44417
|
+
if (resolvedNewConfig.cfBuildOutput && pluginConfig.viteEnvironment?.childEnvironments?.length) throw new Error("`viteEnvironment.childEnvironments` cannot be used together with `experimental.newConfig.cfBuildOutput`. Child environments are not yet supported in the Build Output API.");
|
|
44267
44418
|
const result = await loadNewConfig({
|
|
44268
44419
|
root,
|
|
44269
44420
|
mode: viteEnv.mode,
|
|
@@ -44271,6 +44422,7 @@ async function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
44271
44422
|
});
|
|
44272
44423
|
configPath = result.configPath;
|
|
44273
44424
|
rawConfigOverride = result.rawConfig;
|
|
44425
|
+
parsedNewConfig = result.parsedConfig;
|
|
44274
44426
|
configPaths.add(result.configPath);
|
|
44275
44427
|
for (const dep of result.dependencies) configPaths.add(dep);
|
|
44276
44428
|
} else configPath = getValidatedWranglerConfigPath(root, pluginConfig.configPath ?? prefixedEnv.CLOUDFLARE_VITE_WRANGLER_CONFIG_PATH);
|
|
@@ -44278,7 +44430,7 @@ async function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
44278
44430
|
root,
|
|
44279
44431
|
configPath: resolvedNewConfig ? void 0 : configPath,
|
|
44280
44432
|
env: cloudflareEnv,
|
|
44281
|
-
configCustomizer: pluginConfig.config,
|
|
44433
|
+
configCustomizer: resolvedNewConfig ? void 0 : pluginConfig.config,
|
|
44282
44434
|
visitedConfigPaths: configPaths,
|
|
44283
44435
|
rawConfigOverride
|
|
44284
44436
|
});
|
|
@@ -44309,6 +44461,7 @@ async function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
44309
44461
|
type: "assets-only",
|
|
44310
44462
|
cloudflareEnv,
|
|
44311
44463
|
config: entryWorkerResolvedConfig.config,
|
|
44464
|
+
parsedNewConfig,
|
|
44312
44465
|
environmentNameToWorkerMap,
|
|
44313
44466
|
environmentNameToChildEnvironmentNamesMap,
|
|
44314
44467
|
prerenderWorkerEnvironmentName,
|
|
@@ -44320,7 +44473,7 @@ async function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
44320
44473
|
if (Array.isArray(entryWorkerResolvedConfig.config.assets?.run_worker_first)) staticRouting = parseStaticRouting(entryWorkerResolvedConfig.config.assets.run_worker_first);
|
|
44321
44474
|
const entryWorkerEnvironmentName = pluginConfig.viteEnvironment?.name ?? workerNameToEnvironmentName(entryWorkerResolvedConfig.config.topLevelName);
|
|
44322
44475
|
validateAndAddEnvironmentName(entryWorkerEnvironmentName);
|
|
44323
|
-
environmentNameToWorkerMap.set(entryWorkerEnvironmentName, resolveWorker(entryWorkerResolvedConfig.config, pluginConfig.assetsOnly));
|
|
44476
|
+
environmentNameToWorkerMap.set(entryWorkerEnvironmentName, resolveWorker(entryWorkerResolvedConfig.config, pluginConfig.assetsOnly, parsedNewConfig));
|
|
44324
44477
|
const entryWorkerChildEnvironments = pluginConfig.viteEnvironment?.childEnvironments;
|
|
44325
44478
|
if (entryWorkerChildEnvironments) {
|
|
44326
44479
|
for (const childName of entryWorkerChildEnvironments) validateAndAddEnvironmentName(childName);
|
|
@@ -44383,11 +44536,12 @@ function resolveDevOnly(devOnly) {
|
|
|
44383
44536
|
if (typeof devOnly === "function") return devOnly();
|
|
44384
44537
|
return devOnly ?? false;
|
|
44385
44538
|
}
|
|
44386
|
-
function resolveWorker(workerConfig, devOnly) {
|
|
44539
|
+
function resolveWorker(workerConfig, devOnly, parsedNewConfig) {
|
|
44387
44540
|
return {
|
|
44388
44541
|
config: workerConfig,
|
|
44389
44542
|
nodeJsCompat: hasNodeJsCompat(workerConfig) ? new NodeJsCompat(workerConfig) : void 0,
|
|
44390
|
-
devOnly
|
|
44543
|
+
devOnly,
|
|
44544
|
+
parsedNewConfig
|
|
44391
44545
|
};
|
|
44392
44546
|
}
|
|
44393
44547
|
const NEW_CONFIG_FILENAME = "cloudflare.config.ts";
|
|
@@ -44395,8 +44549,10 @@ const TYPES_OUTPUT_FILENAME = "worker-configuration.d.ts";
|
|
|
44395
44549
|
const EXPERIMENTAL_CONFIG_PKG = "@cloudflare/vite-plugin/experimental-config";
|
|
44396
44550
|
/**
|
|
44397
44551
|
* Load and convert a `cloudflare.config.ts` file via `@cloudflare/config`. Returns
|
|
44398
|
-
* the resulting Wrangler `RawConfig`, the
|
|
44399
|
-
*
|
|
44552
|
+
* the resulting Wrangler `RawConfig`, the parsed new-config shape (for
|
|
44553
|
+
* downstream Build Output API emission), the absolute path of the loaded
|
|
44554
|
+
* file, and the set of files imported while resolving the config (for
|
|
44555
|
+
* watch-mode).
|
|
44400
44556
|
*
|
|
44401
44557
|
* If `generateTypes` is true, also writes `worker-configuration.d.ts` next to
|
|
44402
44558
|
* the config when the generated content differs from what's already on disk.
|
|
@@ -44404,10 +44560,10 @@ const EXPERIMENTAL_CONFIG_PKG = "@cloudflare/vite-plugin/experimental-config";
|
|
|
44404
44560
|
async function loadNewConfig(options) {
|
|
44405
44561
|
const configPath = nodePath.resolve(options.root, NEW_CONFIG_FILENAME);
|
|
44406
44562
|
if (!fs$1.existsSync(configPath)) throw new Error(`\`experimental.newConfig\` is enabled but no \`${NEW_CONFIG_FILENAME}\` was found at ${configPath}.`);
|
|
44407
|
-
const { loadConfig,
|
|
44563
|
+
const { loadConfig, InputWorkerSchema, convertToWranglerConfig, generateTypes: generateTypesFn, resolveWorkerDefinition } = await import("./dist-Cr__Sz5N.mjs");
|
|
44408
44564
|
const { config: rawExport, dependencies } = await loadConfig(configPath);
|
|
44409
44565
|
const resolved = await resolveWorkerDefinition(rawExport, { mode: options.mode });
|
|
44410
|
-
const parsed =
|
|
44566
|
+
const parsed = InputWorkerSchema.safeParse(resolved);
|
|
44411
44567
|
if (!parsed.success) throw new Error(`Invalid \`${NEW_CONFIG_FILENAME}\`:\n${parsed.error.message}`);
|
|
44412
44568
|
const rawConfig = convertToWranglerConfig(parsed.data);
|
|
44413
44569
|
if (options.generateTypes) writeWorkerConfigurationDts({
|
|
@@ -44417,6 +44573,7 @@ async function loadNewConfig(options) {
|
|
|
44417
44573
|
});
|
|
44418
44574
|
return {
|
|
44419
44575
|
rawConfig,
|
|
44576
|
+
parsedConfig: parsed.data,
|
|
44420
44577
|
configPath,
|
|
44421
44578
|
dependencies
|
|
44422
44579
|
};
|
|
@@ -45542,6 +45699,268 @@ function createModuleReference(type, id) {
|
|
|
45542
45699
|
return `__CLOUDFLARE_MODULE__${type}__${id}__CLOUDFLARE_MODULE__`;
|
|
45543
45700
|
}
|
|
45544
45701
|
|
|
45702
|
+
//#endregion
|
|
45703
|
+
//#region src/cloudflare-environment.ts
|
|
45704
|
+
const MAIN_ENTRY_NAME = "index";
|
|
45705
|
+
const webSocketUndefinedError = "The WebSocket is undefined";
|
|
45706
|
+
function createHotChannel(webSocketContainer) {
|
|
45707
|
+
const listenersMap = /* @__PURE__ */ new Map();
|
|
45708
|
+
const client = { send(payload) {
|
|
45709
|
+
const webSocket = webSocketContainer.webSocket;
|
|
45710
|
+
assert(webSocket, webSocketUndefinedError);
|
|
45711
|
+
webSocket.send(JSON.stringify(payload));
|
|
45712
|
+
} };
|
|
45713
|
+
function onMessage(event) {
|
|
45714
|
+
const payload = JSON.parse(event.data.toString());
|
|
45715
|
+
const listeners = listenersMap.get(payload.event) ?? /* @__PURE__ */ new Set();
|
|
45716
|
+
for (const listener of listeners) listener(payload.data, client);
|
|
45717
|
+
}
|
|
45718
|
+
return {
|
|
45719
|
+
send(payload) {
|
|
45720
|
+
const webSocket = webSocketContainer.webSocket;
|
|
45721
|
+
const message = JSON.stringify(payload);
|
|
45722
|
+
if (!webSocket) {
|
|
45723
|
+
webSocketContainer.messageBuffers ??= [];
|
|
45724
|
+
webSocketContainer.messageBuffers.push(message);
|
|
45725
|
+
return;
|
|
45726
|
+
}
|
|
45727
|
+
webSocket.send(message);
|
|
45728
|
+
},
|
|
45729
|
+
on(event, listener) {
|
|
45730
|
+
const listeners = listenersMap.get(event) ?? /* @__PURE__ */ new Set();
|
|
45731
|
+
listeners.add(listener);
|
|
45732
|
+
listenersMap.set(event, listeners);
|
|
45733
|
+
},
|
|
45734
|
+
off(event, listener) {
|
|
45735
|
+
listenersMap.get(event)?.delete(listener);
|
|
45736
|
+
},
|
|
45737
|
+
listen() {
|
|
45738
|
+
const webSocket = webSocketContainer.webSocket;
|
|
45739
|
+
assert(webSocket, webSocketUndefinedError);
|
|
45740
|
+
webSocket.addEventListener("message", onMessage);
|
|
45741
|
+
},
|
|
45742
|
+
close() {
|
|
45743
|
+
const webSocket = webSocketContainer.webSocket;
|
|
45744
|
+
assert(webSocket, webSocketUndefinedError);
|
|
45745
|
+
webSocket.removeEventListener("message", onMessage);
|
|
45746
|
+
}
|
|
45747
|
+
};
|
|
45748
|
+
}
|
|
45749
|
+
var CloudflareDevEnvironment = class extends vite.DevEnvironment {
|
|
45750
|
+
#webSocketContainer;
|
|
45751
|
+
constructor(name, config) {
|
|
45752
|
+
const webSocketContainer = {};
|
|
45753
|
+
super(name, config, {
|
|
45754
|
+
hot: true,
|
|
45755
|
+
transport: createHotChannel(webSocketContainer)
|
|
45756
|
+
});
|
|
45757
|
+
this.#webSocketContainer = webSocketContainer;
|
|
45758
|
+
}
|
|
45759
|
+
async initRunner(miniflare, workerConfig, options) {
|
|
45760
|
+
const response = await miniflare.dispatchFetch(new URL(INIT_PATH, UNKNOWN_HOST), { headers: {
|
|
45761
|
+
[CoreHeaders.ROUTE_OVERRIDE]: workerConfig.name,
|
|
45762
|
+
[WORKER_ENTRY_PATH_HEADER]: encodeURIComponent(workerConfig.main),
|
|
45763
|
+
[IS_ENTRY_WORKER_HEADER]: String(options.isEntryWorker),
|
|
45764
|
+
[ENVIRONMENT_NAME_HEADER]: this.name,
|
|
45765
|
+
[IS_PARENT_ENVIRONMENT_HEADER]: String(options.isParentEnvironment),
|
|
45766
|
+
upgrade: "websocket"
|
|
45767
|
+
} });
|
|
45768
|
+
assert(response.ok, `Failed to initialize module runner, error: ${await response.text()}`);
|
|
45769
|
+
const webSocket = response.webSocket;
|
|
45770
|
+
assert(webSocket, "Failed to establish WebSocket");
|
|
45771
|
+
webSocket.accept();
|
|
45772
|
+
this.#webSocketContainer.webSocket = webSocket;
|
|
45773
|
+
if (this.#webSocketContainer.messageBuffers) {
|
|
45774
|
+
for (const bufferedMessage of this.#webSocketContainer.messageBuffers) webSocket.send(bufferedMessage);
|
|
45775
|
+
delete this.#webSocketContainer.messageBuffers;
|
|
45776
|
+
}
|
|
45777
|
+
}
|
|
45778
|
+
async fetchWorkerExportTypes(miniflare, workerConfig) {
|
|
45779
|
+
await this.depsOptimizer?.init();
|
|
45780
|
+
return await (await miniflare.dispatchFetch(new URL(GET_EXPORT_TYPES_PATH, UNKNOWN_HOST), { headers: { [CoreHeaders.ROUTE_OVERRIDE]: workerConfig.name } })).json();
|
|
45781
|
+
}
|
|
45782
|
+
async fetchModule(id, importer, options) {
|
|
45783
|
+
if (additionalModuleRE.test(id)) return {
|
|
45784
|
+
externalize: id,
|
|
45785
|
+
type: "module"
|
|
45786
|
+
};
|
|
45787
|
+
return super.fetchModule(id, importer, options);
|
|
45788
|
+
}
|
|
45789
|
+
};
|
|
45790
|
+
const cloudflareBuiltInModules = [
|
|
45791
|
+
"cloudflare:email",
|
|
45792
|
+
"cloudflare:node",
|
|
45793
|
+
"cloudflare:sockets",
|
|
45794
|
+
"cloudflare:workers",
|
|
45795
|
+
"cloudflare:workflows"
|
|
45796
|
+
];
|
|
45797
|
+
const defaultConditions = [
|
|
45798
|
+
"workerd",
|
|
45799
|
+
"worker",
|
|
45800
|
+
"module",
|
|
45801
|
+
"browser"
|
|
45802
|
+
];
|
|
45803
|
+
const target = "es2024";
|
|
45804
|
+
const resolveExtensions = [
|
|
45805
|
+
".mjs",
|
|
45806
|
+
".js",
|
|
45807
|
+
".mts",
|
|
45808
|
+
".ts",
|
|
45809
|
+
".jsx",
|
|
45810
|
+
".tsx",
|
|
45811
|
+
".json",
|
|
45812
|
+
".cjs",
|
|
45813
|
+
".cts",
|
|
45814
|
+
".ctx"
|
|
45815
|
+
];
|
|
45816
|
+
function createCloudflareEnvironmentOptions({ workerConfig, userConfig, mode, environmentName, isEntryWorker, isParentEnvironment, hasNodeJsCompat: hasNodeJsCompat$1 }) {
|
|
45817
|
+
const rollupOptions = isParentEnvironment ? {
|
|
45818
|
+
input: { [MAIN_ENTRY_NAME]: VIRTUAL_WORKER_ENTRY },
|
|
45819
|
+
preserveEntrySignatures: "strict"
|
|
45820
|
+
} : {};
|
|
45821
|
+
const define$1 = getProcessEnvReplacements(hasNodeJsCompat$1, mode);
|
|
45822
|
+
return {
|
|
45823
|
+
resolve: {
|
|
45824
|
+
noExternal: true,
|
|
45825
|
+
conditions: [...defaultConditions, "development|production"],
|
|
45826
|
+
builtins: [...cloudflareBuiltInModules]
|
|
45827
|
+
},
|
|
45828
|
+
define: define$1,
|
|
45829
|
+
dev: { createEnvironment(name, config) {
|
|
45830
|
+
if (!config.plugins.some((plugin) => plugin.name === "vite-plugin-cloudflare:dev" && plugin.configureServer !== void 0)) return vite.createRunnableDevEnvironment(name, config);
|
|
45831
|
+
return new CloudflareDevEnvironment(name, config);
|
|
45832
|
+
} },
|
|
45833
|
+
build: {
|
|
45834
|
+
createEnvironment(name, config) {
|
|
45835
|
+
return new vite.BuildEnvironment(name, config);
|
|
45836
|
+
},
|
|
45837
|
+
target,
|
|
45838
|
+
emitAssets: true,
|
|
45839
|
+
manifest: isEntryWorker,
|
|
45840
|
+
outDir: getOutputDirectory(userConfig, environmentName),
|
|
45841
|
+
copyPublicDir: false,
|
|
45842
|
+
ssr: true,
|
|
45843
|
+
...isRolldown ? { rolldownOptions: {
|
|
45844
|
+
...rollupOptions,
|
|
45845
|
+
platform: "neutral",
|
|
45846
|
+
resolve: { extensions: resolveExtensions }
|
|
45847
|
+
} } : { rollupOptions }
|
|
45848
|
+
},
|
|
45849
|
+
optimizeDeps: {
|
|
45850
|
+
noDiscovery: false,
|
|
45851
|
+
ignoreOutdatedRequests: true,
|
|
45852
|
+
entries: vite.normalizePath(workerConfig.main),
|
|
45853
|
+
exclude: [
|
|
45854
|
+
...cloudflareBuiltInModules,
|
|
45855
|
+
...nonPrefixedNodeModules,
|
|
45856
|
+
...nonPrefixedNodeModules.map((module$1) => `node:${module$1}`),
|
|
45857
|
+
...[
|
|
45858
|
+
"node:sea",
|
|
45859
|
+
"node:sqlite",
|
|
45860
|
+
"node:test",
|
|
45861
|
+
"node:test/reporters"
|
|
45862
|
+
]
|
|
45863
|
+
],
|
|
45864
|
+
...isRolldown ? { rolldownOptions: {
|
|
45865
|
+
platform: "neutral",
|
|
45866
|
+
resolve: {
|
|
45867
|
+
conditionNames: [...defaultConditions, "development"],
|
|
45868
|
+
extensions: resolveExtensions
|
|
45869
|
+
},
|
|
45870
|
+
transform: {
|
|
45871
|
+
target,
|
|
45872
|
+
define: define$1
|
|
45873
|
+
},
|
|
45874
|
+
plugins: [vite.esmExternalRequirePlugin({
|
|
45875
|
+
external: [nodeBuiltinsRE],
|
|
45876
|
+
skipDuplicateCheck: true
|
|
45877
|
+
})]
|
|
45878
|
+
} } : { esbuildOptions: {
|
|
45879
|
+
platform: "neutral",
|
|
45880
|
+
conditions: [...defaultConditions, "development"],
|
|
45881
|
+
resolveExtensions,
|
|
45882
|
+
target,
|
|
45883
|
+
define: define$1
|
|
45884
|
+
} }
|
|
45885
|
+
},
|
|
45886
|
+
keepProcessEnv: true
|
|
45887
|
+
};
|
|
45888
|
+
}
|
|
45889
|
+
/**
|
|
45890
|
+
* Gets `process.env` replacement values.
|
|
45891
|
+
* `process.env.NODE_ENV` is always replaced.
|
|
45892
|
+
* `process.env` is replaced with an empty object if `nodejs_compat` is not enabled
|
|
45893
|
+
* @param hasNodeJsCompat - whether `nodejs_compat` is enabled
|
|
45894
|
+
* @param mode - the Vite mode
|
|
45895
|
+
* @returns replacement values
|
|
45896
|
+
*/
|
|
45897
|
+
function getProcessEnvReplacements(hasNodeJsCompat$1, mode) {
|
|
45898
|
+
const nodeEnv = process.env.NODE_ENV || mode;
|
|
45899
|
+
const nodeEnvReplacements = {
|
|
45900
|
+
"process.env.NODE_ENV": JSON.stringify(nodeEnv),
|
|
45901
|
+
"global.process.env.NODE_ENV": JSON.stringify(nodeEnv),
|
|
45902
|
+
"globalThis.process.env.NODE_ENV": JSON.stringify(nodeEnv)
|
|
45903
|
+
};
|
|
45904
|
+
return hasNodeJsCompat$1 ? nodeEnvReplacements : {
|
|
45905
|
+
...nodeEnvReplacements,
|
|
45906
|
+
"process.env": "{}",
|
|
45907
|
+
"global.process.env": "{}",
|
|
45908
|
+
"globalThis.process.env": "{}"
|
|
45909
|
+
};
|
|
45910
|
+
}
|
|
45911
|
+
function initRunners(resolvedPluginConfig, viteDevServer, miniflare) {
|
|
45912
|
+
const initPromises = [...resolvedPluginConfig.environmentNameToWorkerMap].flatMap(([environmentName, worker]) => {
|
|
45913
|
+
debuglog("Initializing worker:", worker.config.name);
|
|
45914
|
+
const isEntryWorker = environmentName === resolvedPluginConfig.entryWorkerEnvironmentName;
|
|
45915
|
+
const childEnvironmentNames = resolvedPluginConfig.environmentNameToChildEnvironmentNamesMap.get(environmentName) ?? [];
|
|
45916
|
+
return [viteDevServer.environments[environmentName].initRunner(miniflare, worker.config, {
|
|
45917
|
+
isEntryWorker,
|
|
45918
|
+
isParentEnvironment: true
|
|
45919
|
+
}), ...childEnvironmentNames.map((childEnvironmentName) => {
|
|
45920
|
+
debuglog("Initializing child environment:", childEnvironmentName);
|
|
45921
|
+
return viteDevServer.environments[childEnvironmentName].initRunner(miniflare, worker.config, {
|
|
45922
|
+
isEntryWorker: false,
|
|
45923
|
+
isParentEnvironment: false
|
|
45924
|
+
});
|
|
45925
|
+
})];
|
|
45926
|
+
});
|
|
45927
|
+
return Promise.all(initPromises);
|
|
45928
|
+
}
|
|
45929
|
+
|
|
45930
|
+
//#endregion
|
|
45931
|
+
//#region src/plugins/build-output.ts
|
|
45932
|
+
/**
|
|
45933
|
+
* Build Output API plugin. Replaces `outputConfigPlugin` when
|
|
45934
|
+
* `experimental.newConfig.cfBuildOutput` is set.
|
|
45935
|
+
*/
|
|
45936
|
+
const buildOutputPlugin = createPlugin("build-output", (ctx) => {
|
|
45937
|
+
return { writeBundle(_options, bundle) {
|
|
45938
|
+
if (ctx.isChildEnvironment(this.environment.name)) return;
|
|
45939
|
+
if (ctx.resolvedPluginConfig.type === "assets-only" && this.environment.name === "client") {
|
|
45940
|
+
const workerNewConfig$1 = ctx.resolvedPluginConfig.parsedNewConfig;
|
|
45941
|
+
assert(workerNewConfig$1, "Expected parsedNewConfig on assets-only resolved config");
|
|
45942
|
+
writeOutputWorkerConfig(ctx.resolvedViteConfig.root, workerNewConfig$1);
|
|
45943
|
+
return;
|
|
45944
|
+
}
|
|
45945
|
+
const workerNewConfig = ctx.getWorkerNewConfig(this.environment.name);
|
|
45946
|
+
if (!workerNewConfig) return;
|
|
45947
|
+
const entryChunk = Object.values(bundle).find((chunk) => chunk.type === "chunk" && chunk.isEntry && chunk.name === MAIN_ENTRY_NAME);
|
|
45948
|
+
assert(entryChunk, `Expected entry chunk with name "${MAIN_ENTRY_NAME}"`);
|
|
45949
|
+
const importedAssetPaths = /* @__PURE__ */ new Set();
|
|
45950
|
+
for (const entry of Object.values(bundle)) for (const asset of entry.viteMetadata?.importedAssets ?? []) importedAssetPaths.add(asset);
|
|
45951
|
+
const modules = {};
|
|
45952
|
+
for (const fileName of Object.keys(bundle)) {
|
|
45953
|
+
if (fileName === ".vite/manifest.json") continue;
|
|
45954
|
+
if (importedAssetPaths.has(fileName)) continue;
|
|
45955
|
+
modules[fileName] = { type: detectModuleType(fileName) };
|
|
45956
|
+
}
|
|
45957
|
+
writeOutputWorkerConfig(ctx.resolvedViteConfig.root, workerNewConfig, {
|
|
45958
|
+
mainModule: entryChunk.fileName,
|
|
45959
|
+
modules
|
|
45960
|
+
});
|
|
45961
|
+
} };
|
|
45962
|
+
});
|
|
45963
|
+
|
|
45545
45964
|
//#endregion
|
|
45546
45965
|
//#region ../workers-shared/utils/configuration/constructConfiguration.ts
|
|
45547
45966
|
function constructRedirects({ redirects, redirectsFile, logger }) {
|
|
@@ -45613,9 +46032,9 @@ function constructHeaders({ headers, headersFile, logger }) {
|
|
|
45613
46032
|
|
|
45614
46033
|
//#endregion
|
|
45615
46034
|
//#region ../workers-shared/utils/configuration/validateURL.ts
|
|
45616
|
-
const extractPathname = (path = "/", includeSearch, includeHash) => {
|
|
45617
|
-
if (!path.startsWith("/")) path = `/${path}`;
|
|
45618
|
-
const url = new URL(`//${path}`, "relative://");
|
|
46035
|
+
const extractPathname = (path$1 = "/", includeSearch, includeHash) => {
|
|
46036
|
+
if (!path$1.startsWith("/")) path$1 = `/${path$1}`;
|
|
46037
|
+
const url = new URL(`//${path$1}`, "relative://");
|
|
45619
46038
|
return `${url.pathname}${includeSearch ? url.search : ""}${includeHash ? url.hash : ""}`;
|
|
45620
46039
|
};
|
|
45621
46040
|
const URL_REGEX = /^https:\/\/+(?<host>[^/]+)\/?(?<path>.*)/;
|
|
@@ -45674,7 +46093,7 @@ function parseHeaders(input, { maxRules = MAX_HEADER_RULES, maxLineLength = MAX_
|
|
|
45674
46093
|
lineNumber: i$1 + 1,
|
|
45675
46094
|
message: "No headers specified"
|
|
45676
46095
|
});
|
|
45677
|
-
const [path, pathError] = validateUrl(line, false, true);
|
|
46096
|
+
const [path$1, pathError] = validateUrl(line, false, true);
|
|
45678
46097
|
if (pathError) {
|
|
45679
46098
|
invalid.push({
|
|
45680
46099
|
line,
|
|
@@ -45685,7 +46104,7 @@ function parseHeaders(input, { maxRules = MAX_HEADER_RULES, maxLineLength = MAX_
|
|
|
45685
46104
|
skipUntilNextPath = true;
|
|
45686
46105
|
continue;
|
|
45687
46106
|
}
|
|
45688
|
-
const wildcardError = validateNoMultipleWildcards(path);
|
|
46107
|
+
const wildcardError = validateNoMultipleWildcards(path$1);
|
|
45689
46108
|
if (wildcardError) {
|
|
45690
46109
|
invalid.push({
|
|
45691
46110
|
line,
|
|
@@ -45697,7 +46116,7 @@ function parseHeaders(input, { maxRules = MAX_HEADER_RULES, maxLineLength = MAX_
|
|
|
45697
46116
|
continue;
|
|
45698
46117
|
}
|
|
45699
46118
|
rule = {
|
|
45700
|
-
path,
|
|
46119
|
+
path: path$1,
|
|
45701
46120
|
line,
|
|
45702
46121
|
headers: {},
|
|
45703
46122
|
unsetHeaders: []
|
|
@@ -45780,11 +46199,11 @@ function isValidRule(rule) {
|
|
|
45780
46199
|
* `:splat` placeholder, would result in duplicate `:splat` parameters which is
|
|
45781
46200
|
* unsupported.
|
|
45782
46201
|
*/
|
|
45783
|
-
function validateNoMultipleWildcards(path) {
|
|
45784
|
-
const wildcardCount = (path.match(SPLAT_REGEX) ?? []).length;
|
|
45785
|
-
const hasSplatPlaceholder = /:splat(?!\w)/.test(path);
|
|
45786
|
-
if (wildcardCount > 1) return `Only one wildcard is allowed per rule. Use a named placeholder (e.g. :project) instead. Skipping ${path}.`;
|
|
45787
|
-
if (wildcardCount > 0 && hasSplatPlaceholder) return `Cannot combine a wildcard * with a :splat placeholder because wildcards are converted to :splat at runtime. Skipping ${path}.`;
|
|
46202
|
+
function validateNoMultipleWildcards(path$1) {
|
|
46203
|
+
const wildcardCount = (path$1.match(SPLAT_REGEX) ?? []).length;
|
|
46204
|
+
const hasSplatPlaceholder = /:splat(?!\w)/.test(path$1);
|
|
46205
|
+
if (wildcardCount > 1) return `Only one wildcard is allowed per rule. Use a named placeholder (e.g. :project) instead. Skipping ${path$1}.`;
|
|
46206
|
+
if (wildcardCount > 0 && hasSplatPlaceholder) return `Cannot combine a wildcard * with a :splat placeholder because wildcards are converted to :splat at runtime. Skipping ${path$1}.`;
|
|
45788
46207
|
}
|
|
45789
46208
|
|
|
45790
46209
|
//#endregion
|
|
@@ -46001,13 +46420,13 @@ var require_ignore = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/ig
|
|
|
46001
46420
|
const throwError = (message, Ctor) => {
|
|
46002
46421
|
throw new Ctor(message);
|
|
46003
46422
|
};
|
|
46004
|
-
const checkPath = (path, originalPath, doThrow) => {
|
|
46005
|
-
if (!isString$1(path)) return doThrow(`path must be a string, but got \`${originalPath}\``, TypeError);
|
|
46006
|
-
if (!path) return doThrow(`path must not be empty`, TypeError);
|
|
46007
|
-
if (checkPath.isNotRelative(path)) return doThrow(`path should be a \`path.relative()\`d string, but got "${originalPath}"`, RangeError);
|
|
46423
|
+
const checkPath = (path$1, originalPath, doThrow) => {
|
|
46424
|
+
if (!isString$1(path$1)) return doThrow(`path must be a string, but got \`${originalPath}\``, TypeError);
|
|
46425
|
+
if (!path$1) return doThrow(`path must not be empty`, TypeError);
|
|
46426
|
+
if (checkPath.isNotRelative(path$1)) return doThrow(`path should be a \`path.relative()\`d string, but got "${originalPath}"`, RangeError);
|
|
46008
46427
|
return true;
|
|
46009
46428
|
};
|
|
46010
|
-
const isNotRelative = (path) => REGEX_TEST_INVALID_PATH.test(path);
|
|
46429
|
+
const isNotRelative = (path$1) => REGEX_TEST_INVALID_PATH.test(path$1);
|
|
46011
46430
|
checkPath.isNotRelative = isNotRelative;
|
|
46012
46431
|
checkPath.convert = (p$1) => p$1;
|
|
46013
46432
|
var Ignore = class {
|
|
@@ -46043,13 +46462,13 @@ var require_ignore = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/ig
|
|
|
46043
46462
|
addPattern(pattern) {
|
|
46044
46463
|
return this.add(pattern);
|
|
46045
46464
|
}
|
|
46046
|
-
_testOne(path, checkUnignored) {
|
|
46465
|
+
_testOne(path$1, checkUnignored) {
|
|
46047
46466
|
let ignored = false;
|
|
46048
46467
|
let unignored = false;
|
|
46049
46468
|
this._rules.forEach((rule) => {
|
|
46050
46469
|
const { negative } = rule;
|
|
46051
46470
|
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) return;
|
|
46052
|
-
if (rule.regex.test(path)) {
|
|
46471
|
+
if (rule.regex.test(path$1)) {
|
|
46053
46472
|
ignored = !negative;
|
|
46054
46473
|
unignored = negative;
|
|
46055
46474
|
}
|
|
@@ -46060,33 +46479,33 @@ var require_ignore = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/ig
|
|
|
46060
46479
|
};
|
|
46061
46480
|
}
|
|
46062
46481
|
_test(originalPath, cache$2, checkUnignored, slices) {
|
|
46063
|
-
const path = originalPath && checkPath.convert(originalPath);
|
|
46064
|
-
checkPath(path, originalPath, this._allowRelativePaths ? RETURN_FALSE : throwError);
|
|
46065
|
-
return this._t(path, cache$2, checkUnignored, slices);
|
|
46482
|
+
const path$1 = originalPath && checkPath.convert(originalPath);
|
|
46483
|
+
checkPath(path$1, originalPath, this._allowRelativePaths ? RETURN_FALSE : throwError);
|
|
46484
|
+
return this._t(path$1, cache$2, checkUnignored, slices);
|
|
46066
46485
|
}
|
|
46067
|
-
_t(path, cache$2, checkUnignored, slices) {
|
|
46068
|
-
if (path in cache$2) return cache$2[path];
|
|
46069
|
-
if (!slices) slices = path.split(SLASH);
|
|
46486
|
+
_t(path$1, cache$2, checkUnignored, slices) {
|
|
46487
|
+
if (path$1 in cache$2) return cache$2[path$1];
|
|
46488
|
+
if (!slices) slices = path$1.split(SLASH);
|
|
46070
46489
|
slices.pop();
|
|
46071
|
-
if (!slices.length) return cache$2[path] = this._testOne(path, checkUnignored);
|
|
46490
|
+
if (!slices.length) return cache$2[path$1] = this._testOne(path$1, checkUnignored);
|
|
46072
46491
|
const parent = this._t(slices.join(SLASH) + SLASH, cache$2, checkUnignored, slices);
|
|
46073
|
-
return cache$2[path] = parent.ignored ? parent : this._testOne(path, checkUnignored);
|
|
46492
|
+
return cache$2[path$1] = parent.ignored ? parent : this._testOne(path$1, checkUnignored);
|
|
46074
46493
|
}
|
|
46075
|
-
ignores(path) {
|
|
46076
|
-
return this._test(path, this._ignoreCache, false).ignored;
|
|
46494
|
+
ignores(path$1) {
|
|
46495
|
+
return this._test(path$1, this._ignoreCache, false).ignored;
|
|
46077
46496
|
}
|
|
46078
46497
|
createFilter() {
|
|
46079
|
-
return (path) => !this.ignores(path);
|
|
46498
|
+
return (path$1) => !this.ignores(path$1);
|
|
46080
46499
|
}
|
|
46081
46500
|
filter(paths) {
|
|
46082
46501
|
return makeArray(paths).filter(this.createFilter());
|
|
46083
46502
|
}
|
|
46084
|
-
test(path) {
|
|
46085
|
-
return this._test(path, this._testCache, true);
|
|
46503
|
+
test(path$1) {
|
|
46504
|
+
return this._test(path$1, this._testCache, true);
|
|
46086
46505
|
}
|
|
46087
46506
|
};
|
|
46088
46507
|
const factory = (options) => new Ignore(options);
|
|
46089
|
-
const isPathValid = (path) => checkPath(path && checkPath.convert(path), path, RETURN_FALSE);
|
|
46508
|
+
const isPathValid = (path$1) => checkPath(path$1 && checkPath.convert(path$1), path$1, RETURN_FALSE);
|
|
46090
46509
|
factory.isPathValid = isPathValid;
|
|
46091
46510
|
factory.default = factory;
|
|
46092
46511
|
module.exports = factory;
|
|
@@ -46095,7 +46514,7 @@ var require_ignore = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/ig
|
|
|
46095
46514
|
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
46096
46515
|
checkPath.convert = makePosix;
|
|
46097
46516
|
const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
46098
|
-
checkPath.isNotRelative = (path) => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path) || isNotRelative(path);
|
|
46517
|
+
checkPath.isNotRelative = (path$1) => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path$1) || isNotRelative(path$1);
|
|
46099
46518
|
}
|
|
46100
46519
|
}) });
|
|
46101
46520
|
|
|
@@ -47450,11 +47869,11 @@ var Mime = class {
|
|
|
47450
47869
|
}
|
|
47451
47870
|
return this;
|
|
47452
47871
|
}
|
|
47453
|
-
getType(path) {
|
|
47454
|
-
if (typeof path !== "string") return null;
|
|
47455
|
-
const last = path.replace(/^.*[/\\]/s, "").toLowerCase();
|
|
47872
|
+
getType(path$1) {
|
|
47873
|
+
if (typeof path$1 !== "string") return null;
|
|
47874
|
+
const last = path$1.replace(/^.*[/\\]/s, "").toLowerCase();
|
|
47456
47875
|
const ext = last.replace(/^.*\./s, "").toLowerCase();
|
|
47457
|
-
const hasPath = last.length < path.length;
|
|
47876
|
+
const hasPath = last.length < path$1.length;
|
|
47458
47877
|
if (!(ext.length < last.length - 1) && hasPath) return null;
|
|
47459
47878
|
return __classPrivateFieldGet(this, _Mime_extensionToType, "f").get(ext) ?? null;
|
|
47460
47879
|
}
|
|
@@ -47788,8 +48207,8 @@ function getErrorMap() {
|
|
|
47788
48207
|
//#endregion
|
|
47789
48208
|
//#region ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
|
|
47790
48209
|
const makeIssue = (params) => {
|
|
47791
|
-
const { data: data$1, path, errorMaps, issueData } = params;
|
|
47792
|
-
const fullPath = [...path, ...issueData.path || []];
|
|
48210
|
+
const { data: data$1, path: path$1, errorMaps, issueData } = params;
|
|
48211
|
+
const fullPath = [...path$1, ...issueData.path || []];
|
|
47793
48212
|
const fullIssue = {
|
|
47794
48213
|
...issueData,
|
|
47795
48214
|
path: fullPath
|
|
@@ -47901,11 +48320,11 @@ var errorUtil;
|
|
|
47901
48320
|
//#endregion
|
|
47902
48321
|
//#region ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
|
|
47903
48322
|
var ParseInputLazyPath = class {
|
|
47904
|
-
constructor(parent, value, path, key) {
|
|
48323
|
+
constructor(parent, value, path$1, key) {
|
|
47905
48324
|
this._cachedPath = [];
|
|
47906
48325
|
this.parent = parent;
|
|
47907
48326
|
this.data = value;
|
|
47908
|
-
this._path = path;
|
|
48327
|
+
this._path = path$1;
|
|
47909
48328
|
this._key = key;
|
|
47910
48329
|
}
|
|
47911
48330
|
get path() {
|
|
@@ -51211,7 +51630,8 @@ function createBuildApp(resolvedPluginConfig) {
|
|
|
51211
51630
|
if (hasClientEntry) await builder.build(clientEnvironment);
|
|
51212
51631
|
else if (importedAssetPaths.size || getHasPublicAssets(builder.config) || resolvedPluginConfig.prerenderWorkerEnvironmentName) await fallbackBuild(builder, clientEnvironment);
|
|
51213
51632
|
else {
|
|
51214
|
-
|
|
51633
|
+
const cfBuildOutput = resolvedPluginConfig.experimental.newConfig?.cfBuildOutput === true;
|
|
51634
|
+
if (!satisfiesMinimumViteVersion("7.0.0") && !cfBuildOutput) removeAssetsField(entryWorkerBuildDirectory);
|
|
51215
51635
|
return;
|
|
51216
51636
|
}
|
|
51217
51637
|
const clientBuildDirectory = nodePath.resolve(builder.config.root, clientEnvironment.config.build.outDir);
|
|
@@ -51266,234 +51686,6 @@ function removeAssetsField(entryWorkerBuildDirectory) {
|
|
|
51266
51686
|
fs$1.writeFileSync(entryWorkerConfigPath, JSON.stringify(workerConfig));
|
|
51267
51687
|
}
|
|
51268
51688
|
|
|
51269
|
-
//#endregion
|
|
51270
|
-
//#region src/cloudflare-environment.ts
|
|
51271
|
-
const MAIN_ENTRY_NAME = "index";
|
|
51272
|
-
const webSocketUndefinedError = "The WebSocket is undefined";
|
|
51273
|
-
function createHotChannel(webSocketContainer) {
|
|
51274
|
-
const listenersMap = /* @__PURE__ */ new Map();
|
|
51275
|
-
const client = { send(payload) {
|
|
51276
|
-
const webSocket = webSocketContainer.webSocket;
|
|
51277
|
-
assert(webSocket, webSocketUndefinedError);
|
|
51278
|
-
webSocket.send(JSON.stringify(payload));
|
|
51279
|
-
} };
|
|
51280
|
-
function onMessage(event) {
|
|
51281
|
-
const payload = JSON.parse(event.data.toString());
|
|
51282
|
-
const listeners = listenersMap.get(payload.event) ?? /* @__PURE__ */ new Set();
|
|
51283
|
-
for (const listener of listeners) listener(payload.data, client);
|
|
51284
|
-
}
|
|
51285
|
-
return {
|
|
51286
|
-
send(payload) {
|
|
51287
|
-
const webSocket = webSocketContainer.webSocket;
|
|
51288
|
-
const message = JSON.stringify(payload);
|
|
51289
|
-
if (!webSocket) {
|
|
51290
|
-
webSocketContainer.messageBuffers ??= [];
|
|
51291
|
-
webSocketContainer.messageBuffers.push(message);
|
|
51292
|
-
return;
|
|
51293
|
-
}
|
|
51294
|
-
webSocket.send(message);
|
|
51295
|
-
},
|
|
51296
|
-
on(event, listener) {
|
|
51297
|
-
const listeners = listenersMap.get(event) ?? /* @__PURE__ */ new Set();
|
|
51298
|
-
listeners.add(listener);
|
|
51299
|
-
listenersMap.set(event, listeners);
|
|
51300
|
-
},
|
|
51301
|
-
off(event, listener) {
|
|
51302
|
-
listenersMap.get(event)?.delete(listener);
|
|
51303
|
-
},
|
|
51304
|
-
listen() {
|
|
51305
|
-
const webSocket = webSocketContainer.webSocket;
|
|
51306
|
-
assert(webSocket, webSocketUndefinedError);
|
|
51307
|
-
webSocket.addEventListener("message", onMessage);
|
|
51308
|
-
},
|
|
51309
|
-
close() {
|
|
51310
|
-
const webSocket = webSocketContainer.webSocket;
|
|
51311
|
-
assert(webSocket, webSocketUndefinedError);
|
|
51312
|
-
webSocket.removeEventListener("message", onMessage);
|
|
51313
|
-
}
|
|
51314
|
-
};
|
|
51315
|
-
}
|
|
51316
|
-
var CloudflareDevEnvironment = class extends vite.DevEnvironment {
|
|
51317
|
-
#webSocketContainer;
|
|
51318
|
-
constructor(name, config) {
|
|
51319
|
-
const webSocketContainer = {};
|
|
51320
|
-
super(name, config, {
|
|
51321
|
-
hot: true,
|
|
51322
|
-
transport: createHotChannel(webSocketContainer)
|
|
51323
|
-
});
|
|
51324
|
-
this.#webSocketContainer = webSocketContainer;
|
|
51325
|
-
}
|
|
51326
|
-
async initRunner(miniflare, workerConfig, options) {
|
|
51327
|
-
const response = await miniflare.dispatchFetch(new URL(INIT_PATH, UNKNOWN_HOST), { headers: {
|
|
51328
|
-
[CoreHeaders.ROUTE_OVERRIDE]: workerConfig.name,
|
|
51329
|
-
[WORKER_ENTRY_PATH_HEADER]: encodeURIComponent(workerConfig.main),
|
|
51330
|
-
[IS_ENTRY_WORKER_HEADER]: String(options.isEntryWorker),
|
|
51331
|
-
[ENVIRONMENT_NAME_HEADER]: this.name,
|
|
51332
|
-
[IS_PARENT_ENVIRONMENT_HEADER]: String(options.isParentEnvironment),
|
|
51333
|
-
upgrade: "websocket"
|
|
51334
|
-
} });
|
|
51335
|
-
assert(response.ok, `Failed to initialize module runner, error: ${await response.text()}`);
|
|
51336
|
-
const webSocket = response.webSocket;
|
|
51337
|
-
assert(webSocket, "Failed to establish WebSocket");
|
|
51338
|
-
webSocket.accept();
|
|
51339
|
-
this.#webSocketContainer.webSocket = webSocket;
|
|
51340
|
-
if (this.#webSocketContainer.messageBuffers) {
|
|
51341
|
-
for (const bufferedMessage of this.#webSocketContainer.messageBuffers) webSocket.send(bufferedMessage);
|
|
51342
|
-
delete this.#webSocketContainer.messageBuffers;
|
|
51343
|
-
}
|
|
51344
|
-
}
|
|
51345
|
-
async fetchWorkerExportTypes(miniflare, workerConfig) {
|
|
51346
|
-
await this.depsOptimizer?.init();
|
|
51347
|
-
return await (await miniflare.dispatchFetch(new URL(GET_EXPORT_TYPES_PATH, UNKNOWN_HOST), { headers: { [CoreHeaders.ROUTE_OVERRIDE]: workerConfig.name } })).json();
|
|
51348
|
-
}
|
|
51349
|
-
async fetchModule(id, importer, options) {
|
|
51350
|
-
if (additionalModuleRE.test(id)) return {
|
|
51351
|
-
externalize: id,
|
|
51352
|
-
type: "module"
|
|
51353
|
-
};
|
|
51354
|
-
return super.fetchModule(id, importer, options);
|
|
51355
|
-
}
|
|
51356
|
-
};
|
|
51357
|
-
const cloudflareBuiltInModules = [
|
|
51358
|
-
"cloudflare:email",
|
|
51359
|
-
"cloudflare:node",
|
|
51360
|
-
"cloudflare:sockets",
|
|
51361
|
-
"cloudflare:workers",
|
|
51362
|
-
"cloudflare:workflows"
|
|
51363
|
-
];
|
|
51364
|
-
const defaultConditions = [
|
|
51365
|
-
"workerd",
|
|
51366
|
-
"worker",
|
|
51367
|
-
"module",
|
|
51368
|
-
"browser"
|
|
51369
|
-
];
|
|
51370
|
-
const target = "es2024";
|
|
51371
|
-
const resolveExtensions = [
|
|
51372
|
-
".mjs",
|
|
51373
|
-
".js",
|
|
51374
|
-
".mts",
|
|
51375
|
-
".ts",
|
|
51376
|
-
".jsx",
|
|
51377
|
-
".tsx",
|
|
51378
|
-
".json",
|
|
51379
|
-
".cjs",
|
|
51380
|
-
".cts",
|
|
51381
|
-
".ctx"
|
|
51382
|
-
];
|
|
51383
|
-
function createCloudflareEnvironmentOptions({ workerConfig, userConfig, mode, environmentName, isEntryWorker, isParentEnvironment, hasNodeJsCompat: hasNodeJsCompat$1 }) {
|
|
51384
|
-
const rollupOptions = isParentEnvironment ? {
|
|
51385
|
-
input: { [MAIN_ENTRY_NAME]: VIRTUAL_WORKER_ENTRY },
|
|
51386
|
-
preserveEntrySignatures: "strict"
|
|
51387
|
-
} : {};
|
|
51388
|
-
const define$1 = getProcessEnvReplacements(hasNodeJsCompat$1, mode);
|
|
51389
|
-
return {
|
|
51390
|
-
resolve: {
|
|
51391
|
-
noExternal: true,
|
|
51392
|
-
conditions: [...defaultConditions, "development|production"],
|
|
51393
|
-
builtins: [...cloudflareBuiltInModules]
|
|
51394
|
-
},
|
|
51395
|
-
define: define$1,
|
|
51396
|
-
dev: { createEnvironment(name, config) {
|
|
51397
|
-
if (!config.plugins.some((plugin) => plugin.name === "vite-plugin-cloudflare:dev" && plugin.configureServer !== void 0)) return vite.createRunnableDevEnvironment(name, config);
|
|
51398
|
-
return new CloudflareDevEnvironment(name, config);
|
|
51399
|
-
} },
|
|
51400
|
-
build: {
|
|
51401
|
-
createEnvironment(name, config) {
|
|
51402
|
-
return new vite.BuildEnvironment(name, config);
|
|
51403
|
-
},
|
|
51404
|
-
target,
|
|
51405
|
-
emitAssets: true,
|
|
51406
|
-
manifest: isEntryWorker,
|
|
51407
|
-
outDir: getOutputDirectory(userConfig, environmentName),
|
|
51408
|
-
copyPublicDir: false,
|
|
51409
|
-
ssr: true,
|
|
51410
|
-
...isRolldown ? { rolldownOptions: {
|
|
51411
|
-
...rollupOptions,
|
|
51412
|
-
platform: "neutral",
|
|
51413
|
-
resolve: { extensions: resolveExtensions }
|
|
51414
|
-
} } : { rollupOptions }
|
|
51415
|
-
},
|
|
51416
|
-
optimizeDeps: {
|
|
51417
|
-
noDiscovery: false,
|
|
51418
|
-
ignoreOutdatedRequests: true,
|
|
51419
|
-
entries: vite.normalizePath(workerConfig.main),
|
|
51420
|
-
exclude: [
|
|
51421
|
-
...cloudflareBuiltInModules,
|
|
51422
|
-
...nonPrefixedNodeModules,
|
|
51423
|
-
...nonPrefixedNodeModules.map((module$1) => `node:${module$1}`),
|
|
51424
|
-
...[
|
|
51425
|
-
"node:sea",
|
|
51426
|
-
"node:sqlite",
|
|
51427
|
-
"node:test",
|
|
51428
|
-
"node:test/reporters"
|
|
51429
|
-
]
|
|
51430
|
-
],
|
|
51431
|
-
...isRolldown ? { rolldownOptions: {
|
|
51432
|
-
platform: "neutral",
|
|
51433
|
-
resolve: {
|
|
51434
|
-
conditionNames: [...defaultConditions, "development"],
|
|
51435
|
-
extensions: resolveExtensions
|
|
51436
|
-
},
|
|
51437
|
-
transform: {
|
|
51438
|
-
target,
|
|
51439
|
-
define: define$1
|
|
51440
|
-
},
|
|
51441
|
-
plugins: [vite.esmExternalRequirePlugin({
|
|
51442
|
-
external: [nodeBuiltinsRE],
|
|
51443
|
-
skipDuplicateCheck: true
|
|
51444
|
-
})]
|
|
51445
|
-
} } : { esbuildOptions: {
|
|
51446
|
-
platform: "neutral",
|
|
51447
|
-
conditions: [...defaultConditions, "development"],
|
|
51448
|
-
resolveExtensions,
|
|
51449
|
-
target,
|
|
51450
|
-
define: define$1
|
|
51451
|
-
} }
|
|
51452
|
-
},
|
|
51453
|
-
keepProcessEnv: true
|
|
51454
|
-
};
|
|
51455
|
-
}
|
|
51456
|
-
/**
|
|
51457
|
-
* Gets `process.env` replacement values.
|
|
51458
|
-
* `process.env.NODE_ENV` is always replaced.
|
|
51459
|
-
* `process.env` is replaced with an empty object if `nodejs_compat` is not enabled
|
|
51460
|
-
* @param hasNodeJsCompat - whether `nodejs_compat` is enabled
|
|
51461
|
-
* @param mode - the Vite mode
|
|
51462
|
-
* @returns replacement values
|
|
51463
|
-
*/
|
|
51464
|
-
function getProcessEnvReplacements(hasNodeJsCompat$1, mode) {
|
|
51465
|
-
const nodeEnv = process.env.NODE_ENV || mode;
|
|
51466
|
-
const nodeEnvReplacements = {
|
|
51467
|
-
"process.env.NODE_ENV": JSON.stringify(nodeEnv),
|
|
51468
|
-
"global.process.env.NODE_ENV": JSON.stringify(nodeEnv),
|
|
51469
|
-
"globalThis.process.env.NODE_ENV": JSON.stringify(nodeEnv)
|
|
51470
|
-
};
|
|
51471
|
-
return hasNodeJsCompat$1 ? nodeEnvReplacements : {
|
|
51472
|
-
...nodeEnvReplacements,
|
|
51473
|
-
"process.env": "{}",
|
|
51474
|
-
"global.process.env": "{}",
|
|
51475
|
-
"globalThis.process.env": "{}"
|
|
51476
|
-
};
|
|
51477
|
-
}
|
|
51478
|
-
function initRunners(resolvedPluginConfig, viteDevServer, miniflare) {
|
|
51479
|
-
const initPromises = [...resolvedPluginConfig.environmentNameToWorkerMap].flatMap(([environmentName, worker]) => {
|
|
51480
|
-
debuglog("Initializing worker:", worker.config.name);
|
|
51481
|
-
const isEntryWorker = environmentName === resolvedPluginConfig.entryWorkerEnvironmentName;
|
|
51482
|
-
const childEnvironmentNames = resolvedPluginConfig.environmentNameToChildEnvironmentNamesMap.get(environmentName) ?? [];
|
|
51483
|
-
return [viteDevServer.environments[environmentName].initRunner(miniflare, worker.config, {
|
|
51484
|
-
isEntryWorker,
|
|
51485
|
-
isParentEnvironment: true
|
|
51486
|
-
}), ...childEnvironmentNames.map((childEnvironmentName) => {
|
|
51487
|
-
debuglog("Initializing child environment:", childEnvironmentName);
|
|
51488
|
-
return viteDevServer.environments[childEnvironmentName].initRunner(miniflare, worker.config, {
|
|
51489
|
-
isEntryWorker: false,
|
|
51490
|
-
isParentEnvironment: false
|
|
51491
|
-
});
|
|
51492
|
-
})];
|
|
51493
|
-
});
|
|
51494
|
-
return Promise.all(initPromises);
|
|
51495
|
-
}
|
|
51496
|
-
|
|
51497
51689
|
//#endregion
|
|
51498
51690
|
//#region src/dev-vars.ts
|
|
51499
51691
|
/**
|
|
@@ -51597,7 +51789,12 @@ const configPlugin = createPlugin("config", (ctx) => {
|
|
|
51597
51789
|
},
|
|
51598
51790
|
configResolved(resolvedViteConfig) {
|
|
51599
51791
|
ctx.setResolvedViteConfig(resolvedViteConfig);
|
|
51600
|
-
if (ctx.resolvedPluginConfig.type
|
|
51792
|
+
if (ctx.resolvedPluginConfig.type === "preview") return;
|
|
51793
|
+
validateWorkerEnvironmentOptions(ctx.resolvedPluginConfig, ctx.resolvedViteConfig);
|
|
51794
|
+
if (ctx.resolvedPluginConfig.experimental.newConfig?.cfBuildOutput) {
|
|
51795
|
+
forceBuildOutputDirs(ctx.resolvedPluginConfig, ctx.resolvedViteConfig);
|
|
51796
|
+
if (ctx.resolvedViteConfig.command === "build") cleanBuildOutputDir(ctx.resolvedViteConfig.root);
|
|
51797
|
+
}
|
|
51601
51798
|
},
|
|
51602
51799
|
buildStart() {
|
|
51603
51800
|
ctx.setHasShownWorkerConfigWarnings(false);
|
|
@@ -51627,26 +51824,33 @@ const configPlugin = createPlugin("config", (ctx) => {
|
|
|
51627
51824
|
const { entryWorkerEnvironmentName } = ctx.resolvedPluginConfig;
|
|
51628
51825
|
const entryWorkerEnvironment = builder.environments[entryWorkerEnvironmentName];
|
|
51629
51826
|
assert(entryWorkerEnvironment, `No "${entryWorkerEnvironmentName}" environment`);
|
|
51827
|
+
const cfBuildOutput = ctx.resolvedPluginConfig.experimental.newConfig?.cfBuildOutput === true;
|
|
51630
51828
|
if (entryWorkerEnvironment.isBuilt) {
|
|
51631
|
-
if (!builder.environments.client?.isBuilt) removeAssetsField(nodePath.resolve(builder.config.root, entryWorkerEnvironment.config.build.outDir));
|
|
51829
|
+
if (!builder.environments.client?.isBuilt && !cfBuildOutput) removeAssetsField(nodePath.resolve(builder.config.root, entryWorkerEnvironment.config.build.outDir));
|
|
51632
51830
|
} else {
|
|
51633
51831
|
const clientEnvironment = builder.environments.client;
|
|
51634
51832
|
assert(clientEnvironment, "No \"client\" environment");
|
|
51635
51833
|
if (!clientEnvironment.isBuilt) throw new Error("If `assetsOnly` is set to `true`, the client environment must be built");
|
|
51636
|
-
|
|
51637
|
-
|
|
51638
|
-
|
|
51639
|
-
|
|
51640
|
-
|
|
51641
|
-
|
|
51642
|
-
|
|
51643
|
-
|
|
51644
|
-
|
|
51645
|
-
|
|
51646
|
-
|
|
51647
|
-
|
|
51648
|
-
|
|
51649
|
-
|
|
51834
|
+
if (cfBuildOutput) {
|
|
51835
|
+
const entryWorkerNewConfig = ctx.getWorkerNewConfig(entryWorkerEnvironmentName);
|
|
51836
|
+
assert(entryWorkerNewConfig, `No config found for "${entryWorkerEnvironmentName}" environment`);
|
|
51837
|
+
writeOutputWorkerConfig(builder.config.root, entryWorkerNewConfig);
|
|
51838
|
+
} else {
|
|
51839
|
+
const entryWorkerConfig = ctx.getWorkerConfig(entryWorkerEnvironmentName);
|
|
51840
|
+
assert(entryWorkerConfig, `No config found for "${entryWorkerEnvironmentName}" environment`);
|
|
51841
|
+
const outputConfig = {
|
|
51842
|
+
...entryWorkerConfig,
|
|
51843
|
+
main: void 0,
|
|
51844
|
+
assets: {
|
|
51845
|
+
...entryWorkerConfig.assets,
|
|
51846
|
+
directory: ".",
|
|
51847
|
+
binding: void 0
|
|
51848
|
+
}
|
|
51849
|
+
};
|
|
51850
|
+
if (outputConfig.unsafe && Object.keys(outputConfig.unsafe).length === 0) outputConfig.unsafe = void 0;
|
|
51851
|
+
fs$1.writeFileSync(nodePath.resolve(builder.config.root, clientEnvironment.config.build.outDir, "wrangler.json"), JSON.stringify(outputConfig));
|
|
51852
|
+
writeDeployConfig(ctx.resolvedPluginConfig, ctx.resolvedViteConfig, true);
|
|
51853
|
+
}
|
|
51650
51854
|
}
|
|
51651
51855
|
}
|
|
51652
51856
|
}
|
|
@@ -51686,6 +51890,37 @@ function getEnvironmentsConfig(ctx, userConfig, mode) {
|
|
|
51686
51890
|
}
|
|
51687
51891
|
};
|
|
51688
51892
|
}
|
|
51893
|
+
/**
|
|
51894
|
+
* When the Build Output API is enabled,
|
|
51895
|
+
* force every Worker environment's and the client environment's `build.outDir`
|
|
51896
|
+
* to the spec-mandated location.
|
|
51897
|
+
*
|
|
51898
|
+
* Runs after Vite's merge in `configResolved`, so it overrides any
|
|
51899
|
+
* user-supplied `build.outDir`
|
|
51900
|
+
*/
|
|
51901
|
+
function forceBuildOutputDirs(resolvedPluginConfig, resolvedViteConfig) {
|
|
51902
|
+
if (!resolvedPluginConfig.experimental.newConfig?.cfBuildOutput) return;
|
|
51903
|
+
const { root } = resolvedViteConfig;
|
|
51904
|
+
let clientWorkerName;
|
|
51905
|
+
if (resolvedPluginConfig.type === "workers") {
|
|
51906
|
+
for (const [environmentName, worker] of resolvedPluginConfig.environmentNameToWorkerMap) {
|
|
51907
|
+
const environment = resolvedViteConfig.environments[environmentName];
|
|
51908
|
+
if (!environment) continue;
|
|
51909
|
+
assert(worker.parsedNewConfig, "Expected parsedNewConfig to be defined");
|
|
51910
|
+
environment.build.outDir = getWorkerBundleDir(root, worker.parsedNewConfig.name);
|
|
51911
|
+
}
|
|
51912
|
+
const entryName = resolvedPluginConfig.entryWorkerEnvironmentName;
|
|
51913
|
+
const entryWorker = resolvedPluginConfig.environmentNameToWorkerMap.get(entryName);
|
|
51914
|
+
assert(entryWorker, `Expected entry worker for environment "${entryName}"`);
|
|
51915
|
+
assert(entryWorker.parsedNewConfig, "Expected parsedNewConfig to be defined");
|
|
51916
|
+
clientWorkerName = entryWorker.parsedNewConfig.name;
|
|
51917
|
+
} else {
|
|
51918
|
+
assert(resolvedPluginConfig.parsedNewConfig, "Expected parsedNewConfig to be defined");
|
|
51919
|
+
clientWorkerName = resolvedPluginConfig.parsedNewConfig.name;
|
|
51920
|
+
}
|
|
51921
|
+
const clientEnvironment = resolvedViteConfig.environments.client;
|
|
51922
|
+
if (clientEnvironment) clientEnvironment.build.outDir = getWorkerAssetsDir(root, clientWorkerName);
|
|
51923
|
+
}
|
|
51689
51924
|
function getAllowedHosts(tunnelHostnames, userAllowedHosts) {
|
|
51690
51925
|
if (tunnelHostnames.length === 0 || userAllowedHosts === true) return userAllowedHosts;
|
|
51691
51926
|
return Array.from(new Set([...userAllowedHosts ?? [], ...tunnelHostnames]));
|
|
@@ -51786,8 +52021,8 @@ const debugPlugin = createPlugin("debug", (ctx) => {
|
|
|
51786
52021
|
if (!!process.env.VSCODE_INSPECTOR_OPTIONS) return;
|
|
51787
52022
|
if (ctx.resolvedPluginConfig.workers.length >= 1 && ctx.resolvedPluginConfig.inspectorPort !== false) addDebugToVitePrintUrls(vitePreviewServer);
|
|
51788
52023
|
const workerNames = ctx.resolvedPluginConfig.workers.map((worker) => {
|
|
51789
|
-
assert(worker.name, "Expected the Worker to have a name");
|
|
51790
|
-
return worker.name;
|
|
52024
|
+
assert(worker.config.name, "Expected the Worker to have a name");
|
|
52025
|
+
return worker.config.name;
|
|
51791
52026
|
});
|
|
51792
52027
|
vitePreviewServer.middlewares.use(DEBUG_PATH, async (_, res, next) => {
|
|
51793
52028
|
const resolvedInspectorPort = await ctx.getResolvedInspectorPort();
|
|
@@ -51959,11 +52194,11 @@ const getQueryString = (params) => {
|
|
|
51959
52194
|
};
|
|
51960
52195
|
const getUrl = (config, options) => {
|
|
51961
52196
|
const encoder$1 = config.ENCODE_PATH || encodeURI;
|
|
51962
|
-
const path = options.url.replace("{api-version}", config.VERSION).replace(/{(.*?)}/g, (substring, group) => {
|
|
52197
|
+
const path$1 = options.url.replace("{api-version}", config.VERSION).replace(/{(.*?)}/g, (substring, group) => {
|
|
51963
52198
|
if (options.path?.hasOwnProperty(group)) return encoder$1(String(options.path[group]));
|
|
51964
52199
|
return substring;
|
|
51965
52200
|
});
|
|
51966
|
-
const url = `${config.BASE}${path}`;
|
|
52201
|
+
const url = `${config.BASE}${path$1}`;
|
|
51967
52202
|
if (options.query) return `${url}${getQueryString(options.query)}`;
|
|
51968
52203
|
return url;
|
|
51969
52204
|
};
|
|
@@ -53015,7 +53250,7 @@ function getContainerOptions(options) {
|
|
|
53015
53250
|
return containersConfig.map((container) => {
|
|
53016
53251
|
if (isDockerfile(container.image, configPath)) return {
|
|
53017
53252
|
dockerfile: container.image,
|
|
53018
|
-
image_build_context: container.image_build_context ??
|
|
53253
|
+
image_build_context: container.image_build_context ?? path.dirname(container.image),
|
|
53019
53254
|
image_vars: container.image_vars,
|
|
53020
53255
|
class_name: container.class_name,
|
|
53021
53256
|
image_tag: getDevContainerImageName(container.class_name, containerBuildId)
|
|
@@ -53031,26 +53266,26 @@ function getContainerOptions(options) {
|
|
|
53031
53266
|
//#endregion
|
|
53032
53267
|
//#region ../../node_modules/.pnpm/fdir@6.5.0_picomatch@4.0.4/node_modules/fdir/dist/index.mjs
|
|
53033
53268
|
var __require = /* @__PURE__ */ createRequire$1(import.meta.url);
|
|
53034
|
-
function cleanPath(path) {
|
|
53035
|
-
let normalized = normalize(path);
|
|
53269
|
+
function cleanPath(path$1) {
|
|
53270
|
+
let normalized = normalize(path$1);
|
|
53036
53271
|
if (normalized.length > 1 && normalized[normalized.length - 1] === sep) normalized = normalized.substring(0, normalized.length - 1);
|
|
53037
53272
|
return normalized;
|
|
53038
53273
|
}
|
|
53039
53274
|
const SLASHES_REGEX = /[\\/]/g;
|
|
53040
|
-
function convertSlashes(path, separator) {
|
|
53041
|
-
return path.replace(SLASHES_REGEX, separator);
|
|
53275
|
+
function convertSlashes(path$1, separator) {
|
|
53276
|
+
return path$1.replace(SLASHES_REGEX, separator);
|
|
53042
53277
|
}
|
|
53043
53278
|
const WINDOWS_ROOT_DIR_REGEX = /^[a-z]:[\\/]$/i;
|
|
53044
|
-
function isRootDirectory(path) {
|
|
53045
|
-
return path === "/" || WINDOWS_ROOT_DIR_REGEX.test(path);
|
|
53279
|
+
function isRootDirectory(path$1) {
|
|
53280
|
+
return path$1 === "/" || WINDOWS_ROOT_DIR_REGEX.test(path$1);
|
|
53046
53281
|
}
|
|
53047
|
-
function normalizePath$1(path, options) {
|
|
53282
|
+
function normalizePath$1(path$1, options) {
|
|
53048
53283
|
const { resolvePaths, normalizePath: normalizePath$1$1, pathSeparator } = options;
|
|
53049
|
-
const pathNeedsCleaning = process.platform === "win32" && path.includes("/") || path.startsWith(".");
|
|
53050
|
-
if (resolvePaths) path = resolve$1(path);
|
|
53051
|
-
if (normalizePath$1$1 || pathNeedsCleaning) path = cleanPath(path);
|
|
53052
|
-
if (path === ".") return "";
|
|
53053
|
-
return convertSlashes(path[path.length - 1] !== pathSeparator ? path + pathSeparator : path, pathSeparator);
|
|
53284
|
+
const pathNeedsCleaning = process.platform === "win32" && path$1.includes("/") || path$1.startsWith(".");
|
|
53285
|
+
if (resolvePaths) path$1 = resolve$1(path$1);
|
|
53286
|
+
if (normalizePath$1$1 || pathNeedsCleaning) path$1 = cleanPath(path$1);
|
|
53287
|
+
if (path$1 === ".") return "";
|
|
53288
|
+
return convertSlashes(path$1[path$1.length - 1] !== pathSeparator ? path$1 + pathSeparator : path$1, pathSeparator);
|
|
53054
53289
|
}
|
|
53055
53290
|
function joinPathWithBasePath(filename, directoryPath) {
|
|
53056
53291
|
return directoryPath + filename;
|
|
@@ -53086,8 +53321,8 @@ const pushDirectory = (directoryPath, paths) => {
|
|
|
53086
53321
|
paths.push(directoryPath || ".");
|
|
53087
53322
|
};
|
|
53088
53323
|
const pushDirectoryFilter = (directoryPath, paths, filters) => {
|
|
53089
|
-
const path = directoryPath || ".";
|
|
53090
|
-
if (filters.every((filter) => filter(path, true))) paths.push(path);
|
|
53324
|
+
const path$1 = directoryPath || ".";
|
|
53325
|
+
if (filters.every((filter) => filter(path$1, true))) paths.push(path$1);
|
|
53091
53326
|
};
|
|
53092
53327
|
const empty$2 = () => {};
|
|
53093
53328
|
function build$6(root, options) {
|
|
@@ -53136,26 +53371,26 @@ const empty = () => {};
|
|
|
53136
53371
|
function build$3(options) {
|
|
53137
53372
|
return options.group ? groupFiles : empty;
|
|
53138
53373
|
}
|
|
53139
|
-
const resolveSymlinksAsync = function(path, state, callback$1) {
|
|
53374
|
+
const resolveSymlinksAsync = function(path$1, state, callback$1) {
|
|
53140
53375
|
const { queue, fs: fs$2, options: { suppressErrors } } = state;
|
|
53141
53376
|
queue.enqueue();
|
|
53142
|
-
fs$2.realpath(path, (error, resolvedPath) => {
|
|
53377
|
+
fs$2.realpath(path$1, (error, resolvedPath) => {
|
|
53143
53378
|
if (error) return queue.dequeue(suppressErrors ? null : error, state);
|
|
53144
53379
|
fs$2.stat(resolvedPath, (error$1, stat$1) => {
|
|
53145
53380
|
if (error$1) return queue.dequeue(suppressErrors ? null : error$1, state);
|
|
53146
|
-
if (stat$1.isDirectory() && isRecursive(path, resolvedPath, state)) return queue.dequeue(null, state);
|
|
53381
|
+
if (stat$1.isDirectory() && isRecursive(path$1, resolvedPath, state)) return queue.dequeue(null, state);
|
|
53147
53382
|
callback$1(stat$1, resolvedPath);
|
|
53148
53383
|
queue.dequeue(null, state);
|
|
53149
53384
|
});
|
|
53150
53385
|
});
|
|
53151
53386
|
};
|
|
53152
|
-
const resolveSymlinks = function(path, state, callback$1) {
|
|
53387
|
+
const resolveSymlinks = function(path$1, state, callback$1) {
|
|
53153
53388
|
const { queue, fs: fs$2, options: { suppressErrors } } = state;
|
|
53154
53389
|
queue.enqueue();
|
|
53155
53390
|
try {
|
|
53156
|
-
const resolvedPath = fs$2.realpathSync(path);
|
|
53391
|
+
const resolvedPath = fs$2.realpathSync(path$1);
|
|
53157
53392
|
const stat$1 = fs$2.statSync(resolvedPath);
|
|
53158
|
-
if (stat$1.isDirectory() && isRecursive(path, resolvedPath, state)) return;
|
|
53393
|
+
if (stat$1.isDirectory() && isRecursive(path$1, resolvedPath, state)) return;
|
|
53159
53394
|
callback$1(stat$1, resolvedPath);
|
|
53160
53395
|
} catch (e) {
|
|
53161
53396
|
if (!suppressErrors) throw e;
|
|
@@ -53165,16 +53400,16 @@ function build$2(options, isSynchronous) {
|
|
|
53165
53400
|
if (!options.resolveSymlinks || options.excludeSymlinks) return null;
|
|
53166
53401
|
return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
|
|
53167
53402
|
}
|
|
53168
|
-
function isRecursive(path, resolved, state) {
|
|
53403
|
+
function isRecursive(path$1, resolved, state) {
|
|
53169
53404
|
if (state.options.useRealPaths) return isRecursiveUsingRealPaths(resolved, state);
|
|
53170
|
-
let parent = dirname$1(path);
|
|
53405
|
+
let parent = dirname$1(path$1);
|
|
53171
53406
|
let depth$1 = 1;
|
|
53172
53407
|
while (parent !== state.root && depth$1 < 2) {
|
|
53173
53408
|
const resolvedPath = state.symlinks.get(parent);
|
|
53174
53409
|
if (!!resolvedPath && (resolvedPath === resolved || resolvedPath.startsWith(resolved) || resolved.startsWith(resolvedPath))) depth$1++;
|
|
53175
53410
|
else parent = dirname$1(parent);
|
|
53176
53411
|
}
|
|
53177
|
-
state.symlinks.set(path, resolved);
|
|
53412
|
+
state.symlinks.set(path$1, resolved);
|
|
53178
53413
|
return depth$1 > 1;
|
|
53179
53414
|
}
|
|
53180
53415
|
function isRecursiveUsingRealPaths(resolved, state) {
|
|
@@ -53355,19 +53590,19 @@ var Walker = class {
|
|
|
53355
53590
|
const filename = this.joinPath(entry.name, directoryPath);
|
|
53356
53591
|
this.pushFile(filename, files, this.state.counts, filters);
|
|
53357
53592
|
} else if (entry.isDirectory()) {
|
|
53358
|
-
let path = joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
|
|
53359
|
-
if (exclude && exclude(entry.name, path)) continue;
|
|
53360
|
-
this.pushDirectory(path, paths, filters);
|
|
53361
|
-
this.walkDirectory(this.state, path, path, depth$1 - 1, this.walk);
|
|
53593
|
+
let path$1 = joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
|
|
53594
|
+
if (exclude && exclude(entry.name, path$1)) continue;
|
|
53595
|
+
this.pushDirectory(path$1, paths, filters);
|
|
53596
|
+
this.walkDirectory(this.state, path$1, path$1, depth$1 - 1, this.walk);
|
|
53362
53597
|
} else if (this.resolveSymlink && entry.isSymbolicLink()) {
|
|
53363
|
-
let path = joinPathWithBasePath(entry.name, directoryPath);
|
|
53364
|
-
this.resolveSymlink(path, this.state, (stat$1, resolvedPath) => {
|
|
53598
|
+
let path$1 = joinPathWithBasePath(entry.name, directoryPath);
|
|
53599
|
+
this.resolveSymlink(path$1, this.state, (stat$1, resolvedPath) => {
|
|
53365
53600
|
if (stat$1.isDirectory()) {
|
|
53366
53601
|
resolvedPath = normalizePath$1(resolvedPath, this.state.options);
|
|
53367
|
-
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path + pathSeparator)) return;
|
|
53368
|
-
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path + pathSeparator, depth$1 - 1, this.walk);
|
|
53602
|
+
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path$1 + pathSeparator)) return;
|
|
53603
|
+
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path$1 + pathSeparator, depth$1 - 1, this.walk);
|
|
53369
53604
|
} else {
|
|
53370
|
-
resolvedPath = useRealPaths ? resolvedPath : path;
|
|
53605
|
+
resolvedPath = useRealPaths ? resolvedPath : path$1;
|
|
53371
53606
|
const filename = basename(resolvedPath);
|
|
53372
53607
|
const directoryPath$1 = normalizePath$1(dirname$1(resolvedPath), this.state.options);
|
|
53373
53608
|
resolvedPath = this.joinPath(filename, directoryPath$1);
|
|
@@ -53532,7 +53767,7 @@ var Builder = class {
|
|
|
53532
53767
|
isMatch = globFn(patterns, ...options);
|
|
53533
53768
|
this.globCache[patterns.join("\0")] = isMatch;
|
|
53534
53769
|
}
|
|
53535
|
-
this.options.filters.push((path) => isMatch(path));
|
|
53770
|
+
this.options.filters.push((path$1) => isMatch(path$1));
|
|
53536
53771
|
return this;
|
|
53537
53772
|
}
|
|
53538
53773
|
};
|
|
@@ -53746,8 +53981,8 @@ var require_utils = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/pic
|
|
|
53746
53981
|
if (state.negated === true) output = `(?:^(?!${output}).*$)`;
|
|
53747
53982
|
return output;
|
|
53748
53983
|
};
|
|
53749
|
-
exports.basename = (path, { windows } = {}) => {
|
|
53750
|
-
const segs = path.split(windows ? /[\\/]/ : "/");
|
|
53984
|
+
exports.basename = (path$1, { windows } = {}) => {
|
|
53985
|
+
const segs = path$1.split(windows ? /[\\/]/ : "/");
|
|
53751
53986
|
const last = segs[segs.length - 1];
|
|
53752
53987
|
if (last === "") return segs[segs.length - 2];
|
|
53753
53988
|
return last;
|
|
@@ -55487,15 +55722,15 @@ function buildRelative(cwd, root) {
|
|
|
55487
55722
|
};
|
|
55488
55723
|
}
|
|
55489
55724
|
const splitPatternOptions = { parts: true };
|
|
55490
|
-
function splitPattern(path) {
|
|
55725
|
+
function splitPattern(path$1) {
|
|
55491
55726
|
var _result$parts;
|
|
55492
|
-
const result = import_picomatch.default.scan(path, splitPatternOptions);
|
|
55493
|
-
return ((_result$parts = result.parts) === null || _result$parts === void 0 ? void 0 : _result$parts.length) ? result.parts : [path];
|
|
55727
|
+
const result = import_picomatch.default.scan(path$1, splitPatternOptions);
|
|
55728
|
+
return ((_result$parts = result.parts) === null || _result$parts === void 0 ? void 0 : _result$parts.length) ? result.parts : [path$1];
|
|
55494
55729
|
}
|
|
55495
55730
|
const POSIX_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g;
|
|
55496
55731
|
const WIN32_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g;
|
|
55497
|
-
const escapePosixPath = (path) => path.replace(POSIX_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
|
55498
|
-
const escapeWin32Path = (path) => path.replace(WIN32_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
|
55732
|
+
const escapePosixPath = (path$1) => path$1.replace(POSIX_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
|
55733
|
+
const escapeWin32Path = (path$1) => path$1.replace(WIN32_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
|
55499
55734
|
/**
|
|
55500
55735
|
* Escapes a path's special characters depending on the platform.
|
|
55501
55736
|
* @see {@link https://superchupu.dev/tinyglobby/documentation#escapePath}
|
|
@@ -55619,13 +55854,13 @@ function buildCrawler(options, patterns) {
|
|
|
55619
55854
|
if (options.deep !== void 0) maxDepth = Math.round(options.deep - props.depthOffset);
|
|
55620
55855
|
const crawler = new Builder({
|
|
55621
55856
|
filters: [debug$7 ? (p$1, isDirectory$1) => {
|
|
55622
|
-
const path = format$2(p$1, isDirectory$1);
|
|
55623
|
-
const matches = matcher(path) && !ignore$1(path);
|
|
55624
|
-
if (matches) log(`matched ${path}`);
|
|
55857
|
+
const path$1 = format$2(p$1, isDirectory$1);
|
|
55858
|
+
const matches = matcher(path$1) && !ignore$1(path$1);
|
|
55859
|
+
if (matches) log(`matched ${path$1}`);
|
|
55625
55860
|
return matches;
|
|
55626
55861
|
} : (p$1, isDirectory$1) => {
|
|
55627
|
-
const path = format$2(p$1, isDirectory$1);
|
|
55628
|
-
return matcher(path) && !ignore$1(path);
|
|
55862
|
+
const path$1 = format$2(p$1, isDirectory$1);
|
|
55863
|
+
return matcher(path$1) && !ignore$1(path$1);
|
|
55629
55864
|
}],
|
|
55630
55865
|
exclude: debug$7 ? (_, p$1) => {
|
|
55631
55866
|
const skipped = excludePredicate(_, p$1);
|
|
@@ -55976,11 +56211,54 @@ function getPreviewModules(main, modulesRules) {
|
|
|
55976
56211
|
})))]
|
|
55977
56212
|
};
|
|
55978
56213
|
}
|
|
56214
|
+
/**
|
|
56215
|
+
* Translate a Build Output API module type to a Miniflare module type.
|
|
56216
|
+
*/
|
|
56217
|
+
function toMiniflareModuleType(type) {
|
|
56218
|
+
switch (type) {
|
|
56219
|
+
case "esm": return "ESModule";
|
|
56220
|
+
case "cjs": return "CommonJS";
|
|
56221
|
+
case "wasm": return "CompiledWasm";
|
|
56222
|
+
case "text": return "Text";
|
|
56223
|
+
case "data": return "Data";
|
|
56224
|
+
case "json": return "Data";
|
|
56225
|
+
case "python": return "PythonModule";
|
|
56226
|
+
case "pythonRequirement": return null;
|
|
56227
|
+
case "sourcemap": return null;
|
|
56228
|
+
}
|
|
56229
|
+
}
|
|
56230
|
+
/**
|
|
56231
|
+
* Get Miniflare's module list directly from the `modules` manifest.
|
|
56232
|
+
*
|
|
56233
|
+
* Miniflare uses the first module in the list as the entry, so the
|
|
56234
|
+
* `mainModule` is hoisted to index 0 regardless of the manifest's
|
|
56235
|
+
* order.
|
|
56236
|
+
*/
|
|
56237
|
+
function getModulesFromManifest(bundle) {
|
|
56238
|
+
const { mainModule } = bundle;
|
|
56239
|
+
const mainEntry = bundle.modules[mainModule];
|
|
56240
|
+
assert(mainEntry !== void 0, `Build Output API: \`mainModule\` "${mainModule}" is missing from \`modules\`.`);
|
|
56241
|
+
const ordered = [[mainModule, mainEntry]];
|
|
56242
|
+
for (const [modulePath, value] of Object.entries(bundle.modules)) if (modulePath !== mainModule) ordered.push([modulePath, value]);
|
|
56243
|
+
const modules = ordered.map(([modulePath, { type }]) => {
|
|
56244
|
+
const miniflareType = toMiniflareModuleType(type);
|
|
56245
|
+
if (miniflareType === null) return null;
|
|
56246
|
+
return {
|
|
56247
|
+
type: miniflareType,
|
|
56248
|
+
path: modulePath
|
|
56249
|
+
};
|
|
56250
|
+
}).filter((m) => m !== null);
|
|
56251
|
+
return {
|
|
56252
|
+
rootPath: bundle.rootPath,
|
|
56253
|
+
modules
|
|
56254
|
+
};
|
|
56255
|
+
}
|
|
55979
56256
|
async function getPreviewMiniflareOptions(ctx, vitePreviewServer) {
|
|
55980
56257
|
const inputInspectorPort = await getInputInspectorPort(ctx, vitePreviewServer);
|
|
55981
56258
|
const { resolvedPluginConfig, resolvedViteConfig } = ctx;
|
|
55982
56259
|
const containerTagToOptionsMap = /* @__PURE__ */ new Map();
|
|
55983
|
-
const workers = (await Promise.all(resolvedPluginConfig.workers.map(async (
|
|
56260
|
+
const workers = (await Promise.all(resolvedPluginConfig.workers.map(async (previewWorker) => {
|
|
56261
|
+
const workerConfig = previewWorker.config;
|
|
55984
56262
|
const bindings = wrangler.unstable_convertConfigBindingsToStartWorkerBindings(workerConfig);
|
|
55985
56263
|
const preExistingRemoteProxySessionData = workerConfig.configPath ? remoteProxySessionsDataMap.get(workerConfig.configPath) : void 0;
|
|
55986
56264
|
const remoteProxySessionData = !resolvedPluginConfig.remoteBindings ? null : await wrangler.maybeStartOrUpdateRemoteProxySession({
|
|
@@ -56011,7 +56289,7 @@ async function getPreviewMiniflareOptions(ctx, vitePreviewServer) {
|
|
|
56011
56289
|
...workerOptions,
|
|
56012
56290
|
name: workerOptions.name ?? workerConfig.name,
|
|
56013
56291
|
unsafeInspectorProxy: inputInspectorPort !== false,
|
|
56014
|
-
...miniflareWorkerOptions.main ? getPreviewModules(miniflareWorkerOptions.main, modulesRules) : {
|
|
56292
|
+
...previewWorker.source === "build-output" && previewWorker.bundle ? getModulesFromManifest(previewWorker.bundle) : miniflareWorkerOptions.main ? getPreviewModules(miniflareWorkerOptions.main, modulesRules) : {
|
|
56015
56293
|
modules: true,
|
|
56016
56294
|
script: ""
|
|
56017
56295
|
}
|
|
@@ -56699,13 +56977,13 @@ const wslDefaultBrowser = async () => {
|
|
|
56699
56977
|
const { stdout } = await executePowerShell(String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`, { powerShellPath: psPath });
|
|
56700
56978
|
return stdout.trim();
|
|
56701
56979
|
};
|
|
56702
|
-
const convertWslPathToWindows = async (path) => {
|
|
56703
|
-
if (/^[a-z]+:\/\//i.test(path)) return path;
|
|
56980
|
+
const convertWslPathToWindows = async (path$1) => {
|
|
56981
|
+
if (/^[a-z]+:\/\//i.test(path$1)) return path$1;
|
|
56704
56982
|
try {
|
|
56705
|
-
const { stdout } = await execFile$1("wslpath", ["-aw", path], { encoding: "utf8" });
|
|
56983
|
+
const { stdout } = await execFile$1("wslpath", ["-aw", path$1], { encoding: "utf8" });
|
|
56706
56984
|
return stdout.trim();
|
|
56707
56985
|
} catch {
|
|
56708
|
-
return path;
|
|
56986
|
+
return path$1;
|
|
56709
56987
|
}
|
|
56710
56988
|
};
|
|
56711
56989
|
|
|
@@ -56891,8 +57169,8 @@ var is_in_ssh_default = isInSsh;
|
|
|
56891
57169
|
//#endregion
|
|
56892
57170
|
//#region ../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js
|
|
56893
57171
|
const fallbackAttemptSymbol = Symbol("fallbackAttempt");
|
|
56894
|
-
const __dirname = import.meta.url ?
|
|
56895
|
-
const localXdgOpenPath =
|
|
57172
|
+
const __dirname = import.meta.url ? path.dirname(fileURLToPath(import.meta.url)) : "";
|
|
57173
|
+
const localXdgOpenPath = path.join(__dirname, "xdg-open");
|
|
56896
57174
|
const { platform, arch: arch$1 } = process$1;
|
|
56897
57175
|
const tryEachApp = async (apps$1, opener) => {
|
|
56898
57176
|
if (apps$1.length === 0) return;
|
|
@@ -57276,6 +57554,8 @@ await assertWranglerVersion();
|
|
|
57276
57554
|
*/
|
|
57277
57555
|
function cloudflare(pluginConfig = {}) {
|
|
57278
57556
|
const ctx = new PluginContext(sharedContext);
|
|
57557
|
+
const newConfig = pluginConfig.experimental?.newConfig;
|
|
57558
|
+
const outputPlugin = typeof newConfig === "object" && newConfig?.cfBuildOutput === true ? buildOutputPlugin(ctx) : outputConfigPlugin(ctx);
|
|
57279
57559
|
return [
|
|
57280
57560
|
{
|
|
57281
57561
|
name: "vite-plugin-cloudflare",
|
|
@@ -57308,7 +57588,7 @@ function cloudflare(pluginConfig = {}) {
|
|
|
57308
57588
|
triggerHandlersPlugin(ctx),
|
|
57309
57589
|
virtualModulesPlugin(ctx),
|
|
57310
57590
|
virtualClientFallbackPlugin(ctx),
|
|
57311
|
-
|
|
57591
|
+
outputPlugin,
|
|
57312
57592
|
wasmHelperPlugin(ctx),
|
|
57313
57593
|
additionalModulesPlugin(ctx),
|
|
57314
57594
|
nodeJsAlsPlugin(ctx),
|