@cloudflare/vite-plugin 1.36.3 → 1.37.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/index.d.mts +5 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +419 -301
- package/dist/index.mjs.map +1 -1
- package/dist/{package-BWpnGwvX.mjs → package-DxUBcJd6.mjs} +2 -2
- package/dist/{package-BWpnGwvX.mjs.map → package-DxUBcJd6.mjs.map} +1 -1
- package/dist/workers/runner-worker/module-runner.js +35 -24
- package/package.json +9 -9
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region package.json
|
|
2
2
|
var package_default = {
|
|
3
3
|
name: "@cloudflare/vite-plugin",
|
|
4
|
-
version: "1.
|
|
4
|
+
version: "1.37.0",
|
|
5
5
|
description: "Cloudflare plugin for Vite",
|
|
6
6
|
keywords: [
|
|
7
7
|
"cloudflare",
|
|
@@ -79,4 +79,4 @@ var package_default = {
|
|
|
79
79
|
|
|
80
80
|
//#endregion
|
|
81
81
|
export { package_default as default };
|
|
82
|
-
//# sourceMappingURL=package-
|
|
82
|
+
//# sourceMappingURL=package-DxUBcJd6.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-
|
|
1
|
+
{"version":3,"file":"package-DxUBcJd6.mjs","names":[],"sources":["../package.json"],"sourcesContent":["{\n\t\"name\": \"@cloudflare/vite-plugin\",\n\t\"version\": \"1.37.0\",\n\t\"description\": \"Cloudflare plugin for Vite\",\n\t\"keywords\": [\n\t\t\"cloudflare\",\n\t\t\"cloudflare-workers\",\n\t\t\"vite\",\n\t\t\"vite-plugin\",\n\t\t\"workers\"\n\t],\n\t\"homepage\": \"https://github.com/cloudflare/workers-sdk/tree/main/packages/vite-plugin-cloudflare#readme\",\n\t\"bugs\": {\n\t\t\"url\": \"https://github.com/cloudflare/workers-sdk/issues\"\n\t},\n\t\"license\": \"MIT\",\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"https://github.com/cloudflare/workers-sdk.git\",\n\t\t\"directory\": \"packages/vite-plugin-cloudflare\"\n\t},\n\t\"files\": [\n\t\t\"dist\"\n\t],\n\t\"type\": \"module\",\n\t\"sideEffects\": false,\n\t\"main\": \"./dist/index.mjs\",\n\t\"types\": \"./dist/index.d.mts\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./dist/index.d.mts\",\n\t\t\t\"import\": \"./dist/index.mjs\"\n\t\t}\n\t},\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t},\n\t\"scripts\": {\n\t\t\"build\": \"tsdown\",\n\t\t\"check:type\": \"tsc --build\",\n\t\t\"dev\": \"tsdown --watch\",\n\t\t\"test\": \"vitest run\",\n\t\t\"test:ci\": \"pnpm test\",\n\t\t\"test:e2e\": \"vitest run -c e2e/vitest.config.ts\",\n\t\t\"test:watch\": \"vitest\"\n\t},\n\t\"dependencies\": {\n\t\t\"@cloudflare/unenv-preset\": \"workspace:*\",\n\t\t\"miniflare\": \"workspace:*\",\n\t\t\"unenv\": \"2.0.0-rc.24\",\n\t\t\"wrangler\": \"workspace:*\",\n\t\t\"ws\": \"catalog:default\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@cloudflare/containers-shared\": \"workspace:*\",\n\t\t\"@cloudflare/mock-npm-registry\": \"workspace:*\",\n\t\t\"@cloudflare/workers-shared\": \"workspace:*\",\n\t\t\"@cloudflare/workers-tsconfig\": \"workspace:*\",\n\t\t\"@cloudflare/workers-types\": \"catalog:default\",\n\t\t\"@cloudflare/workers-utils\": \"workspace:*\",\n\t\t\"@remix-run/node-fetch-server\": \"^0.8.0\",\n\t\t\"@types/node\": \"catalog:default\",\n\t\t\"@types/semver\": \"^7.5.1\",\n\t\t\"@types/ws\": \"^8.5.13\",\n\t\t\"defu\": \"^6.1.4\",\n\t\t\"get-port\": \"^7.1.0\",\n\t\t\"magic-string\": \"^0.30.12\",\n\t\t\"mlly\": \"^1.7.4\",\n\t\t\"open\": \"catalog:default\",\n\t\t\"picocolors\": \"^1.1.1\",\n\t\t\"semver\": \"^7.7.1\",\n\t\t\"tinyglobby\": \"catalog:default\",\n\t\t\"tree-kill\": \"catalog:default\",\n\t\t\"tsdown\": \"0.16.3\",\n\t\t\"typescript\": \"catalog:default\",\n\t\t\"vite\": \"catalog:default\",\n\t\t\"vite-legacy\": \"npm:vite@7.1.12\",\n\t\t\"vitest\": \"catalog:default\"\n\t},\n\t\"peerDependencies\": {\n\t\t\"vite\": \"^6.1.0 || ^7.0.0 || ^8.0.0\",\n\t\t\"wrangler\": \"workspace:^\"\n\t},\n\t\"workers-sdk\": {\n\t\t\"prerelease\": true\n\t}\n}\n"],"mappings":";sBAAA;OACS;UACG;cACI;WACH;EACX;EACA;EACA;EACA;EACA;EACA;WACW;OACJ,EACP,OAAO,oDACP;UACU;aACG;EACb,QAAQ;EACR,OAAO;EACP,aAAa;EACb;QACQ,CACR,OACA;OACO;cACO;OACP;QACC;UACE,EACV,KAAK;EACJ,SAAS;EACT,UAAU;EACV,EACD;gBACgB,EAChB,UAAU,UACV;UACU;EACV,SAAS;EACT,cAAc;EACd,OAAO;EACP,QAAQ;EACR,WAAW;EACX,YAAY;EACZ,cAAc;EACd;eACe;EACf,4BAA4B;EAC5B,aAAa;EACb,SAAS;EACT,YAAY;EACZ,MAAM;EACN;kBACkB;EAClB,iCAAiC;EACjC,iCAAiC;EACjC,8BAA8B;EAC9B,gCAAgC;EAChC,6BAA6B;EAC7B,6BAA6B;EAC7B,gCAAgC;EAChC,eAAe;EACf,iBAAiB;EACjB,aAAa;EACb,QAAQ;EACR,YAAY;EACZ,gBAAgB;EAChB,QAAQ;EACR,QAAQ;EACR,cAAc;EACd,UAAU;EACV,cAAc;EACd,aAAa;EACb,UAAU;EACV,cAAc;EACd,QAAQ;EACR,eAAe;EACf,UAAU;EACV;mBACmB;EACnB,QAAQ;EACR,YAAY;EACZ;CACD,eAAe,EACd,cAAc,MACd;CACD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/vite@8.0.
|
|
1
|
+
//#region ../../node_modules/.pnpm/vite@8.0.12_@types+node@22.15.17_esbuild@0.27.3_jiti@2.6.1_tsx@4.21.0_yaml@2.8.1/node_modules/vite/dist/node/module-runner.js
|
|
2
2
|
let SOURCEMAPPING_URL = "sourceMa";
|
|
3
3
|
SOURCEMAPPING_URL += "ppingURL";
|
|
4
4
|
const isWindows = typeof process < "u" && process.platform === "win32";
|
|
@@ -85,14 +85,14 @@ const isAbsolute = function(p) {
|
|
|
85
85
|
}, dirname = function(p) {
|
|
86
86
|
let segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
|
87
87
|
return segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0]) && (segments[0] += "/"), segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
88
|
-
}, decodeBase64 = typeof
|
|
88
|
+
}, textDecoder = new TextDecoder(), decodeBase64 = typeof Buffer == "function" && typeof Buffer.from == "function" ? (base64) => Buffer.from(base64, "base64").toString("utf-8") : (base64) => textDecoder.decode(Uint8Array.from(atob(base64), (c) => c.charCodeAt(0))), percentRegEx = /%/g, backslashRegEx = /\\/g, newlineRegEx = /\n/g, carriageReturnRegEx = /\r/g, tabRegEx = /\t/g, questionRegex = /\?/g, hashRegex = /#/g;
|
|
89
89
|
function encodePathChars(filepath) {
|
|
90
|
-
return filepath.
|
|
90
|
+
return filepath.includes("%") && (filepath = filepath.replace(percentRegEx, "%25")), !isWindows && filepath.includes("\\") && (filepath = filepath.replace(backslashRegEx, "%5C")), filepath.includes("\n") && (filepath = filepath.replace(newlineRegEx, "%0A")), filepath.includes("\r") && (filepath = filepath.replace(carriageReturnRegEx, "%0D")), filepath.includes(" ") && (filepath = filepath.replace(tabRegEx, "%09")), filepath;
|
|
91
91
|
}
|
|
92
92
|
const posixDirname = dirname, posixResolve = resolve;
|
|
93
93
|
function posixPathToFileHref(posixPath) {
|
|
94
94
|
let resolved = posixResolve(posixPath), filePathLast = posixPath.charCodeAt(posixPath.length - 1);
|
|
95
|
-
return (filePathLast === 47 || isWindows && filePathLast === 92) && resolved[resolved.length - 1] !== "/" && (resolved += "/"), resolved = encodePathChars(resolved), resolved.
|
|
95
|
+
return (filePathLast === 47 || isWindows && filePathLast === 92) && resolved[resolved.length - 1] !== "/" && (resolved += "/"), resolved = encodePathChars(resolved), resolved.includes("?") && (resolved = resolved.replace(questionRegex, "%3F")), resolved.includes("#") && (resolved = resolved.replace(hashRegex, "%23")), new URL(`file://${resolved}`).href;
|
|
96
96
|
}
|
|
97
97
|
function toWindowsPath(path) {
|
|
98
98
|
return path.replace(/\//g, "\\");
|
|
@@ -216,6 +216,7 @@ function traceSegmentInternal(segments, memo, line, column, bias) {
|
|
|
216
216
|
return found ? index = (bias === -1 ? upperBound : lowerBound)(segments, column, index) : bias === -1 && index++, index === -1 || index === segments.length ? -1 : index;
|
|
217
217
|
}
|
|
218
218
|
var DecodedMap = class {
|
|
219
|
+
map;
|
|
219
220
|
_encoded;
|
|
220
221
|
_decoded;
|
|
221
222
|
_decodedMemo;
|
|
@@ -245,6 +246,8 @@ function getOriginalPosition(map, needle) {
|
|
|
245
246
|
}
|
|
246
247
|
const MODULE_RUNNER_SOURCEMAPPING_REGEXP = RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json;base64,(.+)`);
|
|
247
248
|
var EvaluatedModuleNode = class {
|
|
249
|
+
id;
|
|
250
|
+
url;
|
|
248
251
|
importers = /* @__PURE__ */ new Set();
|
|
249
252
|
imports = /* @__PURE__ */ new Set();
|
|
250
253
|
evaluated = !1;
|
|
@@ -336,6 +339,8 @@ function normalizeModuleId(file) {
|
|
|
336
339
|
return prefixedBuiltins.has(file) ? file : slash(file).replace(/^\/@fs\//, isWindows ? "" : "/").replace(/^node:/, "").replace(/^\/+/, "/").replace(/^file:\/+/, isWindows ? "" : "/");
|
|
337
340
|
}
|
|
338
341
|
var HMRContext = class {
|
|
342
|
+
hmrClient;
|
|
343
|
+
ownerPath;
|
|
339
344
|
newListeners;
|
|
340
345
|
constructor(hmrClient, ownerPath) {
|
|
341
346
|
this.hmrClient = hmrClient, this.ownerPath = ownerPath, hmrClient.dataMap.has(ownerPath) || hmrClient.dataMap.set(ownerPath, {});
|
|
@@ -417,6 +422,9 @@ var HMRContext = class {
|
|
|
417
422
|
}), this.hmrClient.hotModulesMap.set(this.ownerPath, mod);
|
|
418
423
|
}
|
|
419
424
|
}, HMRClient = class {
|
|
425
|
+
logger;
|
|
426
|
+
transport;
|
|
427
|
+
importUpdatedModule;
|
|
420
428
|
hotModulesMap = /* @__PURE__ */ new Map();
|
|
421
429
|
disposeMap = /* @__PURE__ */ new Map();
|
|
422
430
|
pruneMap = /* @__PURE__ */ new Map();
|
|
@@ -633,14 +641,14 @@ const createInvokeableTransport = (transport) => {
|
|
|
633
641
|
return {
|
|
634
642
|
async connect({ onMessage, onDisconnection }) {
|
|
635
643
|
let socket = options.createConnection();
|
|
636
|
-
socket.addEventListener("message",
|
|
644
|
+
socket.addEventListener("message", ({ data }) => {
|
|
637
645
|
onMessage(JSON.parse(data));
|
|
638
646
|
});
|
|
639
647
|
let isOpened = socket.readyState === socket.OPEN;
|
|
640
648
|
isOpened || await new Promise((resolve$1, reject) => {
|
|
641
649
|
socket.addEventListener("open", () => {
|
|
642
650
|
isOpened = !0, resolve$1();
|
|
643
|
-
}, { once: !0 }), socket.addEventListener("close",
|
|
651
|
+
}, { once: !0 }), socket.addEventListener("close", () => {
|
|
644
652
|
if (!isOpened) {
|
|
645
653
|
reject(/* @__PURE__ */ Error("WebSocket closed without opened."));
|
|
646
654
|
return;
|
|
@@ -722,10 +730,14 @@ function createHMRHandlerForRunner(runner) {
|
|
|
722
730
|
let { triggeredBy } = payload, clearEntrypointUrls = triggeredBy ? getModulesEntrypoints(runner, getModulesByFile(runner, slash(triggeredBy))) : findAllEntrypoints(runner);
|
|
723
731
|
if (!clearEntrypointUrls.size) break;
|
|
724
732
|
hmrClient.logger.debug("program reload"), await hmrClient.notifyListeners("vite:beforeFullReload", payload), runner.evaluatedModules.clear();
|
|
725
|
-
for (let url of clearEntrypointUrls)
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
733
|
+
for (let url of clearEntrypointUrls) {
|
|
734
|
+
if (runner.isClosed()) break;
|
|
735
|
+
try {
|
|
736
|
+
await runner.import(url);
|
|
737
|
+
} catch (err) {
|
|
738
|
+
if (runner.isClosed()) break;
|
|
739
|
+
err.code !== "ERR_OUTDATED_OPTIMIZED_DEP" && hmrClient.logger.error(`An error happened during full reload\n${err.message}\n${err.stack}`);
|
|
740
|
+
}
|
|
729
741
|
}
|
|
730
742
|
break;
|
|
731
743
|
}
|
|
@@ -1037,6 +1049,9 @@ function createNodeImportMeta(modulePath) {
|
|
|
1037
1049
|
};
|
|
1038
1050
|
}
|
|
1039
1051
|
var ModuleRunner = class {
|
|
1052
|
+
options;
|
|
1053
|
+
evaluator;
|
|
1054
|
+
debug;
|
|
1040
1055
|
evaluatedModules;
|
|
1041
1056
|
hmrClient;
|
|
1042
1057
|
transport;
|
|
@@ -1084,29 +1099,25 @@ var ModuleRunner = class {
|
|
|
1084
1099
|
let { url, type } = fetchResult;
|
|
1085
1100
|
return type !== "module" && type !== "commonjs" || analyzeImportedModDifference(exports, url, type, metadata), exports;
|
|
1086
1101
|
}
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
if (
|
|
1094
|
-
if (visited.add(importer), importer === moduleUrl) return !0;
|
|
1095
|
-
let mod = this.evaluatedModules.getModuleById(importer);
|
|
1096
|
-
if (mod && mod.importers.size && this.isCircularImport(mod.importers, moduleUrl, visited)) return !0;
|
|
1102
|
+
isCircularRequest(mod, callstack, visited = /* @__PURE__ */ new Set()) {
|
|
1103
|
+
if (visited.has(mod.id)) return !1;
|
|
1104
|
+
visited.add(mod.id);
|
|
1105
|
+
for (let importedModuleId of mod.imports) {
|
|
1106
|
+
if (callstack.includes(importedModuleId)) return !0;
|
|
1107
|
+
let importedModule = this.evaluatedModules.getModuleById(importedModuleId);
|
|
1108
|
+
if (importedModule?.promise && !importedModule.evaluated && this.isCircularRequest(importedModule, callstack, visited)) return !0;
|
|
1097
1109
|
}
|
|
1098
1110
|
return !1;
|
|
1099
1111
|
}
|
|
1100
1112
|
async cachedRequest(url, mod, callstack = [], metadata) {
|
|
1101
|
-
let meta = mod.meta, moduleId = meta.id,
|
|
1102
|
-
if (importee && importers.add(importee), mod.evaluated && mod.promise) return this.processImport(await mod.promise, meta, metadata);
|
|
1103
|
-
if ((callstack.includes(moduleId) || this.
|
|
1113
|
+
let meta = mod.meta, moduleId = meta.id, importee = callstack[callstack.length - 1];
|
|
1114
|
+
if (importee && mod.importers.add(importee), mod.evaluated && mod.promise) return this.processImport(await mod.promise, meta, metadata);
|
|
1115
|
+
if (mod.promise) return mod.exports && (callstack.includes(moduleId) || this.isCircularRequest(mod, callstack)) ? this.processImport(mod.exports, meta, metadata) : this.processImport(await mod.promise, meta, metadata);
|
|
1104
1116
|
let debugTimer;
|
|
1105
1117
|
this.debug && (debugTimer = setTimeout(() => {
|
|
1106
1118
|
this.debug(`[module runner] module ${moduleId} takes over 2s to load.\n${`stack:\n${[...callstack, moduleId].reverse().map((p) => ` - ${p}`).join("\n")}`}`);
|
|
1107
1119
|
}, 2e3));
|
|
1108
1120
|
try {
|
|
1109
|
-
if (mod.promise) return this.processImport(await mod.promise, meta, metadata);
|
|
1110
1121
|
let promise = this.directRequest(url, mod, callstack);
|
|
1111
1122
|
return mod.promise = promise, mod.evaluated = !1, this.processImport(await promise, meta, metadata);
|
|
1112
1123
|
} finally {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudflare/vite-plugin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.37.0",
|
|
4
4
|
"description": "Cloudflare plugin for Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"unenv": "2.0.0-rc.24",
|
|
40
40
|
"ws": "8.18.0",
|
|
41
41
|
"@cloudflare/unenv-preset": "2.16.1",
|
|
42
|
-
"miniflare": "4.
|
|
43
|
-
"wrangler": "4.
|
|
42
|
+
"miniflare": "4.20260511.0",
|
|
43
|
+
"wrangler": "4.91.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@cloudflare/workers-types": "^4.
|
|
46
|
+
"@cloudflare/workers-types": "^4.20260511.1",
|
|
47
47
|
"@remix-run/node-fetch-server": "^0.8.0",
|
|
48
48
|
"@types/node": "^22.10.1",
|
|
49
49
|
"@types/semver": "^7.5.1",
|
|
@@ -59,18 +59,18 @@
|
|
|
59
59
|
"tree-kill": "^1.2.2",
|
|
60
60
|
"tsdown": "0.16.3",
|
|
61
61
|
"typescript": "~5.8.3",
|
|
62
|
-
"vite": "^8.0.
|
|
62
|
+
"vite": "^8.0.12",
|
|
63
63
|
"vite-legacy": "npm:vite@7.1.12",
|
|
64
64
|
"vitest": "4.1.0",
|
|
65
65
|
"@cloudflare/containers-shared": "0.14.1",
|
|
66
66
|
"@cloudflare/mock-npm-registry": "0.0.0",
|
|
67
|
-
"@cloudflare/workers-shared": "0.19.
|
|
68
|
-
"@cloudflare/workers-
|
|
69
|
-
"@cloudflare/workers-
|
|
67
|
+
"@cloudflare/workers-shared": "0.19.6",
|
|
68
|
+
"@cloudflare/workers-utils": "0.21.0",
|
|
69
|
+
"@cloudflare/workers-tsconfig": "0.0.0"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"vite": "^6.1.0 || ^7.0.0 || ^8.0.0",
|
|
73
|
-
"wrangler": "^4.
|
|
73
|
+
"wrangler": "^4.91.0"
|
|
74
74
|
},
|
|
75
75
|
"workers-sdk": {
|
|
76
76
|
"prerelease": true
|