@cloudflare/vite-plugin 0.0.0-cf14e17d4 → 0.0.0-d1d5b5313
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/asset-workers/asset-worker.js +17 -17
- package/dist/index.js +25 -5
- package/package.json +7 -6
|
@@ -2238,6 +2238,21 @@ async function Wn(t, e, n, r = 1) {
|
|
|
2238
2238
|
await new Promise((i) => setTimeout(i, Math.pow(2, s++) * 1e3));
|
|
2239
2239
|
}
|
|
2240
2240
|
}
|
|
2241
|
+
function $s(t, e, n) {
|
|
2242
|
+
try {
|
|
2243
|
+
let r = new $(n);
|
|
2244
|
+
return t && t.captureException(n), n instanceof Error && e.setData({ error: n.message }), r;
|
|
2245
|
+
} catch (r) {
|
|
2246
|
+
return console.error("Error handling error", r), new $(r);
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2249
|
+
function Bs(t, e, n) {
|
|
2250
|
+
try {
|
|
2251
|
+
t.setData({ requestTime: e.now() - n }), t.write();
|
|
2252
|
+
} catch (r) {
|
|
2253
|
+
console.error("Error submitting metrics", r);
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2241
2256
|
var Kn = class extends Us {
|
|
2242
2257
|
async fetch(t) {
|
|
2243
2258
|
let e, n = new ze(this.env.ANALYTICS), r = new ee(this.env.UNSAFE_PERFORMANCE), s = r.now();
|
|
@@ -2250,24 +2265,9 @@ var Kn = class extends Us {
|
|
|
2250
2265
|
return n.setData({ status: u.status }), u;
|
|
2251
2266
|
});
|
|
2252
2267
|
} catch (o) {
|
|
2253
|
-
return
|
|
2268
|
+
return $s(e, n, o);
|
|
2254
2269
|
} finally {
|
|
2255
|
-
|
|
2256
|
-
}
|
|
2257
|
-
}
|
|
2258
|
-
handleError(t, e, n) {
|
|
2259
|
-
try {
|
|
2260
|
-
let r = new $(n);
|
|
2261
|
-
return t && t.captureException(n), n instanceof Error && e.setData({ error: n.message }), r;
|
|
2262
|
-
} catch (r) {
|
|
2263
|
-
return console.error("Error handling error", r), new $(r);
|
|
2264
|
-
}
|
|
2265
|
-
}
|
|
2266
|
-
submitMetrics(t, e, n) {
|
|
2267
|
-
try {
|
|
2268
|
-
t.setData({ requestTime: e.now() - n }), t.write();
|
|
2269
|
-
} catch (r) {
|
|
2270
|
-
console.error("Error submitting metrics", r);
|
|
2270
|
+
Bs(n, r, s);
|
|
2271
2271
|
}
|
|
2272
2272
|
}
|
|
2273
2273
|
async unstable_canFetch(t) {
|
package/dist/index.js
CHANGED
|
@@ -1370,6 +1370,7 @@ import {
|
|
|
1370
1370
|
LogLevel,
|
|
1371
1371
|
Response as MiniflareResponse
|
|
1372
1372
|
} from "miniflare";
|
|
1373
|
+
import { globSync } from "tinyglobby";
|
|
1373
1374
|
import "vite";
|
|
1374
1375
|
import {
|
|
1375
1376
|
unstable_getMiniflareWorkerOptions,
|
|
@@ -1713,6 +1714,26 @@ function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer) {
|
|
|
1713
1714
|
}
|
|
1714
1715
|
};
|
|
1715
1716
|
}
|
|
1717
|
+
function getPreviewModules(main, modulesRules) {
|
|
1718
|
+
assert4(modulesRules, `Unexpected error: 'modulesRules' is undefined`);
|
|
1719
|
+
const rootPath = path3.dirname(main);
|
|
1720
|
+
const entryPath = path3.basename(main);
|
|
1721
|
+
return {
|
|
1722
|
+
rootPath,
|
|
1723
|
+
modules: [
|
|
1724
|
+
{
|
|
1725
|
+
type: "ESModule",
|
|
1726
|
+
path: entryPath
|
|
1727
|
+
},
|
|
1728
|
+
...modulesRules.flatMap(
|
|
1729
|
+
({ type, include }) => globSync(include, { cwd: rootPath, ignore: entryPath }).map((path8) => ({
|
|
1730
|
+
type,
|
|
1731
|
+
path: path8
|
|
1732
|
+
}))
|
|
1733
|
+
)
|
|
1734
|
+
]
|
|
1735
|
+
};
|
|
1736
|
+
}
|
|
1716
1737
|
function getPreviewMiniflareOptions(vitePreviewServer, persistState) {
|
|
1717
1738
|
const resolvedViteConfig = vitePreviewServer.config;
|
|
1718
1739
|
const configPaths = getWorkerConfigPaths(resolvedViteConfig.root);
|
|
@@ -1721,13 +1742,12 @@ function getPreviewMiniflareOptions(vitePreviewServer, persistState) {
|
|
|
1721
1742
|
);
|
|
1722
1743
|
const workers = workerConfigs.map((config) => {
|
|
1723
1744
|
const miniflareWorkerOptions = unstable_getMiniflareWorkerOptions(config);
|
|
1724
|
-
const { ratelimits, ...workerOptions } = miniflareWorkerOptions.workerOptions;
|
|
1745
|
+
const { ratelimits, modulesRules, ...workerOptions } = miniflareWorkerOptions.workerOptions;
|
|
1725
1746
|
return {
|
|
1726
1747
|
...workerOptions,
|
|
1727
1748
|
// We have to add the name again because `unstable_getMiniflareWorkerOptions` sets it to `undefined`
|
|
1728
1749
|
name: config.name,
|
|
1729
|
-
modules: true,
|
|
1730
|
-
...miniflareWorkerOptions.main ? { scriptPath: miniflareWorkerOptions.main } : { script: "" }
|
|
1750
|
+
...miniflareWorkerOptions.main ? getPreviewModules(miniflareWorkerOptions.main, modulesRules) : { modules: true, script: "" }
|
|
1731
1751
|
};
|
|
1732
1752
|
});
|
|
1733
1753
|
const logger = new ViteMiniflareLogger(resolvedViteConfig);
|
|
@@ -7370,7 +7390,7 @@ var isAbsolute = function(p) {
|
|
|
7370
7390
|
import { fileURLToPath as fileURLToPath$1, URL as URL$1, pathToFileURL as pathToFileURL$1 } from "node:url";
|
|
7371
7391
|
import assert5 from "node:assert";
|
|
7372
7392
|
import process$1 from "node:process";
|
|
7373
|
-
import path4, { dirname as
|
|
7393
|
+
import path4, { dirname as dirname4 } from "node:path";
|
|
7374
7394
|
import v8 from "node:v8";
|
|
7375
7395
|
import { format as format2, inspect } from "node:util";
|
|
7376
7396
|
var BUILTIN_MODULES = new Set(builtinModules);
|
|
@@ -9309,7 +9329,7 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
9309
9329
|
return;
|
|
9310
9330
|
}
|
|
9311
9331
|
config.no_bundle = true;
|
|
9312
|
-
config.rules = [{ type: "ESModule", globs: ["**/*.js"] }];
|
|
9332
|
+
config.rules = [{ type: "ESModule", globs: ["**/*.js", "**/*.mjs"] }];
|
|
9313
9333
|
if (config.unsafe && Object.keys(config.unsafe).length === 0) {
|
|
9314
9334
|
config.unsafe = void 0;
|
|
9315
9335
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudflare/vite-plugin",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-d1d5b5313",
|
|
4
4
|
"description": "Cloudflare plugin for Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -35,12 +35,13 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@cloudflare/unenv-preset": "1.1.1",
|
|
37
37
|
"@hattip/adapter-node": "^0.0.49",
|
|
38
|
+
"tinyglobby": "^0.2.12",
|
|
38
39
|
"unenv": "2.0.0-rc.1",
|
|
39
40
|
"ws": "8.18.0",
|
|
40
|
-
"miniflare": "0.0.0-
|
|
41
|
+
"miniflare": "0.0.0-d1d5b5313"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
|
-
"@cloudflare/workers-types": "^4.
|
|
44
|
+
"@cloudflare/workers-types": "^4.20250224.0",
|
|
44
45
|
"@types/node": "^22.10.1",
|
|
45
46
|
"@types/ws": "^8.5.13",
|
|
46
47
|
"magic-string": "^0.30.12",
|
|
@@ -50,10 +51,10 @@
|
|
|
50
51
|
"undici": "^5.28.5",
|
|
51
52
|
"vite": "^6.1.0",
|
|
52
53
|
"vitest": "~3.0.5",
|
|
54
|
+
"@cloudflare/mock-npm-registry": "0.0.0",
|
|
55
|
+
"@cloudflare/workers-shared": "0.0.0-d1d5b5313",
|
|
53
56
|
"@cloudflare/workers-tsconfig": "0.0.0",
|
|
54
|
-
"wrangler": "0.0.0-
|
|
55
|
-
"@cloudflare/workers-shared": "0.0.0-cf14e17d4",
|
|
56
|
-
"@cloudflare/mock-npm-registry": "0.0.0"
|
|
57
|
+
"wrangler": "0.0.0-d1d5b5313"
|
|
57
58
|
},
|
|
58
59
|
"peerDependencies": {
|
|
59
60
|
"vite": "^6.1.0",
|