@cloudflare/vite-plugin 1.42.0 → 1.42.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/utils.ts","../src/workers-configs.ts","../src/plugin-config.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;ACsDK,KDEO,OCFP,CAAA,CAAA,CAAA,GDEoB,OCFpB,CDE4B,CCF5B,EAAA,SAA8B,CAAA;;;;AAE9B,KAzBO,YAAA,GAAe,IAyBH,CAzBQ,eA0B7B,EAAA,MA1BoD,mBA2BpD,CAAA;KAJE,8BAAA,UAAwC;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/utils.ts","../src/workers-configs.ts","../src/plugin-config.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;ACsDK,KDEO,OCFP,CAAA,CAAA,CAAA,GDEoB,OCFpB,CDE4B,CCF5B,EAAA,SAA8B,CAAA;;;;AAE9B,KAzBO,YAAA,GAAe,IAyBH,CAzBQ,eA0B7B,EAAA,MA1BoD,mBA2BpD,CAAA;KAJE,8BAAA,UAAwC;ACf7C,KDiBK,mBAAA,GACF,iCClBqB,GDmBrB,8BCnBqB;AACxB,KDoBK,iCAAA,GCpBmB,MDqBjB,8BCrBiB,CAAA,gBAAA,CAAA;AAGtB,KDoBG,8BAAA,GACJ,8BCnByB,CAAA,aAAA,CAAA,CAAA,MAAA,CAAA;AAAA;AASd;;AAeE,cDAD,0BCAC,EAAA;EAbsB;;AAAgB;EAqB1C,SAAA,cAAA,EAAA;IAED,SAAA,KAAA,EAAA;MACE,SAAA,eAAA,EAAA,eAAA;MAHmC,SAAA,QAAA,EAAA,2DAAA;IAAgB,CAAA;IAMzD,SAAA,MAAA,EAAA;MAIK,SAAA,eAA0B,EAAA,QAAQ;MAIlC,SAAA,QAAA,EAAA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4F5B,CAAA;EAAR,UAAA,EAAA,MAAA;;AAER,UA1FU,2BAAA,SAAoC,gBA0FhB,CAAA;EACV,UAAA,CAAA,EAAA,MAAA;EACJ,MAAA,EA1FP,sBA0FO,CAAA,KAAA,CAAA;;KAvFX,qBAAA,GACF,yBA0Fa,GAzFb,2BAyFa;UAvFN,qBAAA,CAiF4B;EAAiB;EAStC,KAAA,CAAA,EAAA;IACM;;;;IAEM,QAAA,CAAA,EAAA,OAAA;EAAR,CAAA;EAH6B;;;;;AClJlD;UD6EU,YAAA;;;;oBAIS;;;;;;;;wBAQI;;KAgClB,yBAAA,GAA4B,KAChC;KAII,yDACF,QAAQ,2BAEC,uCACG,yBAED;qBACa;OAEnB,QAAQ;UAEC,YAAA,SAAqB;qBAClB;iBACJ;;;qBAGI;iBACJ;;UAGC,wBAAA,SAAiC;gBACnC,QAAQ;QAChB,QAAQ;sBACM,QAAQ;;;;;;;AFzI7B;;;;ACzBA;;;;AAA+B,iBEaf,gCAAA,CFbe,QAuBwC,CAvBxC,EAAA;EAuB1B,WAAA,CAAA,EAAA,MAAA;AAAkE,CAAA,CAAA,EAElE;EAIA,IAAA,EEdO,UFcP;EAGA,MAAA,EAAA,SAAA,GAAA,UAAA;AAML,CAAA;;AC9BA;AACA;AAGE;AAEwB;AASd;;AAeE,iBCDE,UAAA,CDCF,YAAA,CAAA,ECD2B,YDC3B,CAAA,ECD+C,IAAA,CAAK,MDCpD,EAAA"}
|
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 path3, { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
6
|
+
import path3, { basename, 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";
|
|
@@ -27,7 +27,7 @@ import v8 from "node:v8";
|
|
|
27
27
|
import { defineEnv } from "unenv";
|
|
28
28
|
import * as nativeFs from "fs";
|
|
29
29
|
import { readdir, readdirSync, realpath, realpathSync as realpathSync$1, stat, statSync as statSync$1 } from "fs";
|
|
30
|
-
import { basename, dirname as dirname$1, isAbsolute as isAbsolute$1, normalize, posix, relative as relative$1, resolve as resolve$1, sep } from "path";
|
|
30
|
+
import { basename as basename$1, dirname as dirname$1, isAbsolute as isAbsolute$1, normalize, posix, relative as relative$1, resolve as resolve$1, sep } from "path";
|
|
31
31
|
import { fileURLToPath as fileURLToPath$1 } from "url";
|
|
32
32
|
import { createRequire as createRequire$1 } from "module";
|
|
33
33
|
import { WebSocketServer } from "ws";
|
|
@@ -1506,7 +1506,7 @@ async function assertWranglerVersion() {
|
|
|
1506
1506
|
* The default compatibility date to use when the user omits one.
|
|
1507
1507
|
* This value is injected at build time and remains fixed for each release.
|
|
1508
1508
|
*/
|
|
1509
|
-
const DEFAULT_COMPAT_DATE = "2026-06-
|
|
1509
|
+
const DEFAULT_COMPAT_DATE = "2026-06-23";
|
|
1510
1510
|
|
|
1511
1511
|
//#endregion
|
|
1512
1512
|
//#region src/build-output-env.ts
|
|
@@ -26657,16 +26657,16 @@ var require_command_exists = __commonJS$1({ "../../node_modules/.pnpm/command-ex
|
|
|
26657
26657
|
if (isUsingWindows) cleanInput = /* @__PURE__ */ __name$1(function(s) {
|
|
26658
26658
|
if (/[\\]/.test(s)) {
|
|
26659
26659
|
var dirname2 = "\"" + path5.dirname(s) + "\"";
|
|
26660
|
-
var
|
|
26661
|
-
return dirname2 + ":" +
|
|
26660
|
+
var basename2 = "\"" + path5.basename(s) + "\"";
|
|
26661
|
+
return dirname2 + ":" + basename2;
|
|
26662
26662
|
}
|
|
26663
26663
|
return "\"" + s + "\"";
|
|
26664
26664
|
}, "cleanInput");
|
|
26665
26665
|
module$1.exports = /* @__PURE__ */ __name$1(function commandExists(commandName, callback$1) {
|
|
26666
26666
|
var cleanedCommandName = cleanInput(commandName);
|
|
26667
|
-
if (!callback$1 && typeof Promise !== "undefined") return new Promise(function(
|
|
26667
|
+
if (!callback$1 && typeof Promise !== "undefined") return new Promise(function(resolve2, reject) {
|
|
26668
26668
|
commandExists(commandName, function(error, output) {
|
|
26669
|
-
if (output)
|
|
26669
|
+
if (output) resolve2(commandName);
|
|
26670
26670
|
else reject(error);
|
|
26671
26671
|
});
|
|
26672
26672
|
});
|
|
@@ -27392,7 +27392,7 @@ var require_update_check = __commonJS$1({ "../../node_modules/.pnpm/update-check
|
|
|
27392
27392
|
lastUpdate
|
|
27393
27393
|
}), "utf8");
|
|
27394
27394
|
}, "updateCache");
|
|
27395
|
-
var loadPackage = /* @__PURE__ */ __name$1((url, authInfo) => new Promise((
|
|
27395
|
+
var loadPackage = /* @__PURE__ */ __name$1((url, authInfo) => new Promise((resolve2, reject) => {
|
|
27396
27396
|
const options = {
|
|
27397
27397
|
host: url.hostname,
|
|
27398
27398
|
path: url.pathname,
|
|
@@ -27418,7 +27418,7 @@ var require_update_check = __commonJS$1({ "../../node_modules/.pnpm/update-check
|
|
|
27418
27418
|
});
|
|
27419
27419
|
response.on("end", () => {
|
|
27420
27420
|
try {
|
|
27421
|
-
|
|
27421
|
+
resolve2(JSON.parse(rawData));
|
|
27422
27422
|
} catch (e2) {
|
|
27423
27423
|
reject(e2);
|
|
27424
27424
|
}
|
|
@@ -34570,7 +34570,7 @@ function terminateCloudflared(cloudflared) {
|
|
|
34570
34570
|
}
|
|
34571
34571
|
__name$1(terminateCloudflared, "terminateCloudflared");
|
|
34572
34572
|
function waitForQuickTunnelReady(cloudflared, timeoutMs, options) {
|
|
34573
|
-
return new Promise((
|
|
34573
|
+
return new Promise((resolve2, reject) => {
|
|
34574
34574
|
let resolved = false;
|
|
34575
34575
|
let stderrOutput = "";
|
|
34576
34576
|
const logger = options?.logger;
|
|
@@ -34591,7 +34591,7 @@ function waitForQuickTunnelReady(cloudflared, timeoutMs, options) {
|
|
|
34591
34591
|
if (match && !resolved) {
|
|
34592
34592
|
resolved = true;
|
|
34593
34593
|
clearTimeout(timeoutId);
|
|
34594
|
-
|
|
34594
|
+
resolve2({
|
|
34595
34595
|
mode: "quick",
|
|
34596
34596
|
publicUrl: new URL(match[0])
|
|
34597
34597
|
});
|
|
@@ -34935,6 +34935,49 @@ function getHostFromUrl(urlLike) {
|
|
|
34935
34935
|
}
|
|
34936
34936
|
}
|
|
34937
34937
|
__name$1(getHostFromUrl, "getHostFromUrl");
|
|
34938
|
+
var invalidWorkerNameCharsRegex = /[^a-z0-9- ]/g;
|
|
34939
|
+
var invalidWorkerNameStartEndRegex = /^(-+)|(-+)$/g;
|
|
34940
|
+
var workerNameLengthLimit = 63;
|
|
34941
|
+
function checkWorkerNameValidity(input) {
|
|
34942
|
+
if (!input) return {
|
|
34943
|
+
valid: false,
|
|
34944
|
+
cause: "Worker names cannot be empty."
|
|
34945
|
+
};
|
|
34946
|
+
if (input.match(invalidWorkerNameStartEndRegex)) return {
|
|
34947
|
+
valid: false,
|
|
34948
|
+
cause: "Worker names cannot start or end with a dash."
|
|
34949
|
+
};
|
|
34950
|
+
if (input.match(invalidWorkerNameCharsRegex)) return {
|
|
34951
|
+
valid: false,
|
|
34952
|
+
cause: "Project names must only contain lowercase characters, numbers, and dashes."
|
|
34953
|
+
};
|
|
34954
|
+
if (input.length > workerNameLengthLimit) return {
|
|
34955
|
+
valid: false,
|
|
34956
|
+
cause: "Project names must be less than 63 characters."
|
|
34957
|
+
};
|
|
34958
|
+
return { valid: true };
|
|
34959
|
+
}
|
|
34960
|
+
__name$1(checkWorkerNameValidity, "checkWorkerNameValidity");
|
|
34961
|
+
function toValidWorkerName(input) {
|
|
34962
|
+
if (checkWorkerNameValidity(input).valid) return input;
|
|
34963
|
+
input = input.replaceAll("_", "-").replace(invalidWorkerNameCharsRegex, "-").replace(invalidWorkerNameStartEndRegex, "").slice(0, workerNameLengthLimit);
|
|
34964
|
+
if (!input.length) return "my-worker";
|
|
34965
|
+
return input;
|
|
34966
|
+
}
|
|
34967
|
+
__name$1(toValidWorkerName, "toValidWorkerName");
|
|
34968
|
+
function getWorkerName(projectOrWorkerName = "", projectPath) {
|
|
34969
|
+
return toValidWorkerName(getCIOverrideName() ?? (projectOrWorkerName || basename(projectPath)));
|
|
34970
|
+
}
|
|
34971
|
+
__name$1(getWorkerName, "getWorkerName");
|
|
34972
|
+
function getWorkerNameFromProject(projectPath) {
|
|
34973
|
+
const packageJsonPath = resolve(projectPath, "package.json");
|
|
34974
|
+
let packageJsonName;
|
|
34975
|
+
try {
|
|
34976
|
+
packageJsonName = parsePackageJSON$1(readFileSync$2(packageJsonPath), packageJsonPath).name;
|
|
34977
|
+
} catch {}
|
|
34978
|
+
return getWorkerName(packageJsonName, projectPath);
|
|
34979
|
+
}
|
|
34980
|
+
__name$1(getWorkerNameFromProject, "getWorkerNameFromProject");
|
|
34938
34981
|
|
|
34939
34982
|
//#endregion
|
|
34940
34983
|
//#region ../../node_modules/.pnpm/get-port@7.1.0/node_modules/get-port/index.js
|
|
@@ -45409,10 +45452,12 @@ let deregister;
|
|
|
45409
45452
|
* repeated calls return the same deregister function.
|
|
45410
45453
|
*
|
|
45411
45454
|
* - Handles `with { type: "cf-worker" }` import attributes by synthesising an
|
|
45412
|
-
* ES module whose default export is the
|
|
45413
|
-
*
|
|
45414
|
-
*
|
|
45415
|
-
*
|
|
45455
|
+
* ES module whose default export is the entrypoint specifier. Relative
|
|
45456
|
+
* specifiers (`./`, `../`) are anchored to the importing module and emitted
|
|
45457
|
+
* as absolute paths; bare specifiers and virtual-module specifiers pass
|
|
45458
|
+
* through unchanged so consumers can apply their own resolution semantics.
|
|
45459
|
+
* The referenced module is NOT loaded, is NOT executed, and is NOT added to
|
|
45460
|
+
* the dependencies set.
|
|
45416
45461
|
* - Handles `with { cf: "no-cache" }` import attributes (set internally by
|
|
45417
45462
|
* `loadConfig`) by tagging the resolved URL with a unique UUID query
|
|
45418
45463
|
* string so Node treats each import as a fresh module. The UUID is
|
|
@@ -45427,11 +45472,14 @@ function registerConfigHooks() {
|
|
|
45427
45472
|
const hooks = registerHooks({
|
|
45428
45473
|
resolve(specifier, context, nextResolve) {
|
|
45429
45474
|
const importAttributes = context.importAttributes ?? {};
|
|
45430
|
-
if (importAttributes.type === CF_WORKER_TYPE)
|
|
45431
|
-
|
|
45432
|
-
|
|
45433
|
-
|
|
45434
|
-
|
|
45475
|
+
if (importAttributes.type === CF_WORKER_TYPE) {
|
|
45476
|
+
const entrypoint = (specifier.startsWith("./") || specifier.startsWith("../")) && context.parentURL ? fileURLToPath(new URL(specifier, context.parentURL)) : specifier;
|
|
45477
|
+
return {
|
|
45478
|
+
url: `${CF_WORKER_SCHEME}${encodeURIComponent(entrypoint)}`,
|
|
45479
|
+
format: "module",
|
|
45480
|
+
shortCircuit: true
|
|
45481
|
+
};
|
|
45482
|
+
}
|
|
45435
45483
|
const isNoCache = importAttributes[CF_ATTR] === CF_NO_CACHE_VALUE;
|
|
45436
45484
|
const resolved = nextResolve(specifier, context);
|
|
45437
45485
|
if (RE_NODE_MODULES.test(resolved.url)) return resolved;
|
|
@@ -52569,7 +52617,7 @@ function resolveWorkerConfig(options) {
|
|
|
52569
52617
|
configCustomizer: options.configCustomizer
|
|
52570
52618
|
});
|
|
52571
52619
|
workerConfig.compatibility_date ??= DEFAULT_COMPAT_DATE;
|
|
52572
|
-
if (isEntryWorker) workerConfig.name ??=
|
|
52620
|
+
if (isEntryWorker) workerConfig.name ??= getWorkerNameFromProject(options.root);
|
|
52573
52621
|
workerConfig.topLevelName ??= workerConfig.name;
|
|
52574
52622
|
return resolveWorkerType(workerConfig, raw, nonApplicable, {
|
|
52575
52623
|
isEntryWorker,
|
|
@@ -61345,16 +61393,18 @@ function getImageTag(imageTag) {
|
|
|
61345
61393
|
//#endregion
|
|
61346
61394
|
//#region ../containers-shared/src/images.ts
|
|
61347
61395
|
const DEFAULT_CONTAINER_EGRESS_INTERCEPTOR_IMAGE = "cloudflare/proxy-everything:3cb1195@sha256:0ef6716c52430096900b150d84a3302057d6cd2319dae7987128c85d0733e3c8";
|
|
61396
|
+
function getEgressInterceptorPlatform() {
|
|
61397
|
+
return process.env.MINIFLARE_CONTAINER_EGRESS_IMAGE_PLATFORM;
|
|
61398
|
+
}
|
|
61348
61399
|
function getEgressInterceptorImage() {
|
|
61349
61400
|
return process.env.MINIFLARE_CONTAINER_EGRESS_IMAGE ?? DEFAULT_CONTAINER_EGRESS_INTERCEPTOR_IMAGE;
|
|
61350
61401
|
}
|
|
61351
61402
|
async function pullEgressInterceptorImage(dockerPath) {
|
|
61352
|
-
|
|
61353
|
-
|
|
61354
|
-
|
|
61355
|
-
|
|
61356
|
-
|
|
61357
|
-
]);
|
|
61403
|
+
const image = getEgressInterceptorImage();
|
|
61404
|
+
const platform$1 = getEgressInterceptorPlatform();
|
|
61405
|
+
const args = ["pull", image];
|
|
61406
|
+
if (platform$1 !== void 0) args.push("--platform", platform$1);
|
|
61407
|
+
await runDockerCmd(dockerPath, args);
|
|
61358
61408
|
}
|
|
61359
61409
|
async function pullImage(dockerPath, options, logger) {
|
|
61360
61410
|
const domain = new URL(`http://${options.image_uri}`).hostname;
|
|
@@ -61827,7 +61877,7 @@ var Walker = class {
|
|
|
61827
61877
|
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path + pathSeparator, depth$1 - 1, this.walk);
|
|
61828
61878
|
} else {
|
|
61829
61879
|
resolvedPath = useRealPaths ? resolvedPath : path;
|
|
61830
|
-
const filename = basename(resolvedPath);
|
|
61880
|
+
const filename = basename$1(resolvedPath);
|
|
61831
61881
|
const directoryPath$1 = normalizePath$1(dirname$1(resolvedPath), this.state.options);
|
|
61832
61882
|
resolvedPath = this.joinPath(filename, directoryPath$1);
|
|
61833
61883
|
this.pushFile(resolvedPath, files, this.state.counts, filters);
|