@cloudflare/vite-plugin 0.0.0-e2f5756c2 → 0.0.0-e3efd68e3
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/README.md +60 -34
- package/dist/asset-workers/asset-worker.js +1305 -1584
- package/dist/asset-workers/router-worker.js +1191 -1488
- package/dist/index.d.ts +8 -1
- package/dist/index.js +7714 -533
- package/dist/runner-worker/index.js +15 -3
- package/package.json +23 -15
|
@@ -5,9 +5,13 @@ import {
|
|
|
5
5
|
WorkflowEntrypoint
|
|
6
6
|
} from "cloudflare:workers";
|
|
7
7
|
|
|
8
|
+
// src/constants.ts
|
|
9
|
+
var MODULE_TYPES = ["CompiledWasm"];
|
|
10
|
+
|
|
8
11
|
// src/shared.ts
|
|
9
12
|
var UNKNOWN_HOST = "http://localhost";
|
|
10
13
|
var INIT_PATH = "/__vite_plugin_cloudflare_init__";
|
|
14
|
+
var MODULE_PATTERN = `__CLOUDFLARE_MODULE__(${MODULE_TYPES.join("|")})__(.*?)__`;
|
|
11
15
|
|
|
12
16
|
// src/runner-worker/env.ts
|
|
13
17
|
function stripInternalEnv(internalEnv) {
|
|
@@ -21,7 +25,7 @@ function stripInternalEnv(internalEnv) {
|
|
|
21
25
|
return userEnv;
|
|
22
26
|
}
|
|
23
27
|
|
|
24
|
-
// ../../node_modules/.pnpm/vite@6.
|
|
28
|
+
// ../../node_modules/.pnpm/vite@6.1.0_@types+node@18.19.76_jiti@2.4.2/node_modules/vite/dist/node/module-runner.js
|
|
25
29
|
var VALID_ID_PREFIX = "/@id/";
|
|
26
30
|
var NULL_BYTE_PLACEHOLDER = "__x00__";
|
|
27
31
|
var SOURCEMAPPING_URL = "sourceMa";
|
|
@@ -1409,7 +1413,8 @@ async function createModuleRunner(env, webSocket) {
|
|
|
1409
1413
|
}
|
|
1410
1414
|
},
|
|
1411
1415
|
async runExternalModule(filepath) {
|
|
1412
|
-
|
|
1416
|
+
const moduleRE = new RegExp(MODULE_PATTERN);
|
|
1417
|
+
if (!moduleRE.test(filepath) && filepath.includes("/node_modules") && !filepath.includes("/node_modules/.vite")) {
|
|
1413
1418
|
throw new Error(
|
|
1414
1419
|
`[Error] Trying to import non-prebundled module (only prebundled modules are allowed): ${filepath}
|
|
1415
1420
|
|
|
@@ -1531,7 +1536,14 @@ function createWorkerEntrypointWrapper(entrypoint) {
|
|
|
1531
1536
|
const url = new URL(request.url);
|
|
1532
1537
|
if (url.pathname === INIT_PATH) {
|
|
1533
1538
|
const { 0: client, 1: server } = new WebSocketPair();
|
|
1534
|
-
|
|
1539
|
+
try {
|
|
1540
|
+
await createModuleRunner(this.env, server);
|
|
1541
|
+
} catch (e) {
|
|
1542
|
+
return new Response(
|
|
1543
|
+
e instanceof Error ? e.message : JSON.stringify(e),
|
|
1544
|
+
{ status: 500 }
|
|
1545
|
+
);
|
|
1546
|
+
}
|
|
1535
1547
|
return new Response(null, { status: 101, webSocket: client });
|
|
1536
1548
|
}
|
|
1537
1549
|
}
|
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-e3efd68e3",
|
|
4
4
|
"description": "Cloudflare plugin for Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -33,26 +33,32 @@
|
|
|
33
33
|
"dist"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
+
"@cloudflare/unenv-preset": "1.1.1",
|
|
36
37
|
"@hattip/adapter-node": "^0.0.49",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
38
|
+
"tinyglobby": "^0.2.12",
|
|
39
|
+
"unenv": "2.0.0-rc.1",
|
|
40
|
+
"ws": "8.18.0",
|
|
41
|
+
"miniflare": "0.0.0-e3efd68e3",
|
|
42
|
+
"wrangler": "0.0.0-e3efd68e3"
|
|
40
43
|
},
|
|
41
44
|
"devDependencies": {
|
|
42
|
-
"@cloudflare/workers-types": "^4.
|
|
45
|
+
"@cloudflare/workers-types": "^4.20250224.0",
|
|
43
46
|
"@types/node": "^22.10.1",
|
|
44
47
|
"@types/ws": "^8.5.13",
|
|
45
48
|
"magic-string": "^0.30.12",
|
|
46
|
-
"
|
|
49
|
+
"mlly": "^1.7.4",
|
|
50
|
+
"tsup": "8.3.0",
|
|
47
51
|
"typescript": "^5.7.2",
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"@cloudflare/
|
|
52
|
+
"undici": "^5.28.5",
|
|
53
|
+
"vite": "^6.1.0",
|
|
54
|
+
"vitest": "~3.0.5",
|
|
55
|
+
"@cloudflare/mock-npm-registry": "0.0.0",
|
|
56
|
+
"@cloudflare/workers-shared": "0.0.0-e3efd68e3",
|
|
57
|
+
"@cloudflare/workers-tsconfig": "0.0.0"
|
|
52
58
|
},
|
|
53
59
|
"peerDependencies": {
|
|
54
|
-
"vite": "^6.0
|
|
55
|
-
"wrangler": "
|
|
60
|
+
"vite": "^6.1.0",
|
|
61
|
+
"wrangler": "0.0.0-e3efd68e3"
|
|
56
62
|
},
|
|
57
63
|
"publishConfig": {
|
|
58
64
|
"access": "public"
|
|
@@ -63,8 +69,10 @@
|
|
|
63
69
|
"scripts": {
|
|
64
70
|
"build": "tsup",
|
|
65
71
|
"check:type": "tsc --build",
|
|
66
|
-
"
|
|
67
|
-
"test
|
|
68
|
-
"
|
|
72
|
+
"dev": "tsup --watch",
|
|
73
|
+
"test": "vitest run",
|
|
74
|
+
"test:ci": "pnpm test",
|
|
75
|
+
"test:e2e": "vitest run -c e2e/vitest.config.ts",
|
|
76
|
+
"test:watch": "vitest"
|
|
69
77
|
}
|
|
70
78
|
}
|