@cloudflare/vite-plugin 2.0.0-rc.0 → 2.0.0-rc.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 +3951 -4
- package/dist/index.mjs +65413 -85192
- package/dist/{open-PCXX3ZDZ-BXBWVkHI.mjs → open-BPppUKSJ-B1ds-b_1.mjs} +96 -116
- package/dist/{package-DdTPrOmV.mjs → package-ymw0HTMv.mjs} +4 -6
- package/dist/rolldown-runtime-BMUeFane-CwDF_oX0.mjs +30 -0
- package/dist/workers/asset-worker/index.js +131 -267
- package/dist/workers/router-worker/index.js +93 -202
- package/dist/workers/runner-worker/index.js +11 -20
- package/dist/workers/runner-worker/module-runner-legacy.js +61 -19
- package/dist/workers/runner-worker/module-runner.js +104 -55
- package/dist/workers/vite-proxy-worker/index.js +1 -3
- package/package.json +13 -17
- package/bin/cf-vite +0 -2
- package/dist/cf-vite.mjs +0 -152
- package/dist/chunk-U6NEESU5-BzWFpRaS.mjs +0 -43
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudflare/vite-plugin",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.2",
|
|
4
4
|
"description": "Cloudflare plugin for Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -19,11 +19,7 @@
|
|
|
19
19
|
"url": "https://github.com/cloudflare/workers-sdk.git",
|
|
20
20
|
"directory": "packages/vite-plugin-cloudflare"
|
|
21
21
|
},
|
|
22
|
-
"bin": {
|
|
23
|
-
"cf-vite": "./bin/cf-vite"
|
|
24
|
-
},
|
|
25
22
|
"files": [
|
|
26
|
-
"bin",
|
|
27
23
|
"dist"
|
|
28
24
|
],
|
|
29
25
|
"type": "module",
|
|
@@ -42,14 +38,14 @@
|
|
|
42
38
|
"dependencies": {
|
|
43
39
|
"unenv": "2.0.0-rc.24",
|
|
44
40
|
"ws": "8.21.0",
|
|
45
|
-
"@cloudflare/build-output-utils": "1.0.0-rc.
|
|
46
|
-
"@cloudflare/config": "1.0.0-rc.
|
|
47
|
-
"@cloudflare/
|
|
48
|
-
"
|
|
49
|
-
"
|
|
41
|
+
"@cloudflare/build-output-utils": "1.0.0-rc.2",
|
|
42
|
+
"@cloudflare/config": "1.0.0-rc.2",
|
|
43
|
+
"@cloudflare/unenv-preset": "2.16.2",
|
|
44
|
+
"@cloudflare/runtime-types": "0.1.31",
|
|
45
|
+
"miniflare": "5.20261118.0-beta"
|
|
50
46
|
},
|
|
51
47
|
"devDependencies": {
|
|
52
|
-
"@cloudflare/workers-types": "^5.
|
|
48
|
+
"@cloudflare/workers-types": "^5.20261118.1",
|
|
53
49
|
"@remix-run/node-fetch-server": "^1.0.0",
|
|
54
50
|
"@types/node": "22.15.17",
|
|
55
51
|
"@types/semver": "^7.5.1",
|
|
@@ -64,19 +60,19 @@
|
|
|
64
60
|
"semver": "^7.7.1",
|
|
65
61
|
"tinyglobby": "0.2.16",
|
|
66
62
|
"tree-kill": "1.2.2",
|
|
67
|
-
"tsdown": "0.
|
|
63
|
+
"tsdown": "0.22.14",
|
|
68
64
|
"typescript": "5.8.3",
|
|
69
65
|
"vite": "8.3.4",
|
|
70
66
|
"vite-legacy": "npm:vite@7.1.12",
|
|
71
67
|
"vitest": "5.0.4",
|
|
72
|
-
"@cloudflare/
|
|
73
|
-
"@cloudflare/containers-shared": "0.26.2",
|
|
68
|
+
"@cloudflare/containers-shared": "0.27.0",
|
|
74
69
|
"@cloudflare/mock-npm-registry": "0.0.0",
|
|
75
|
-
"@cloudflare/remote-bindings": "0.0.
|
|
76
|
-
"@cloudflare/workers-auth": "0.18.
|
|
70
|
+
"@cloudflare/remote-bindings": "0.0.68",
|
|
71
|
+
"@cloudflare/workers-auth": "0.18.5",
|
|
77
72
|
"@cloudflare/workers-shared": "0.20.3",
|
|
78
73
|
"@cloudflare/workers-tsconfig": "0.0.0",
|
|
79
|
-
"@cloudflare/workers-utils": "0.
|
|
74
|
+
"@cloudflare/workers-utils": "0.55.0",
|
|
75
|
+
"@cloudflare/cli-shared-helpers": "0.3.11"
|
|
80
76
|
},
|
|
81
77
|
"peerDependencies": {
|
|
82
78
|
"vite": "^7.0.0 || ^8.0.0"
|
package/bin/cf-vite
DELETED
package/dist/cf-vite.mjs
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { parseArgs } from "node:util";
|
|
2
|
-
import { createBuilder, createServer } from "vite";
|
|
3
|
-
|
|
4
|
-
//#region src/cf-vite.ts
|
|
5
|
-
/**
|
|
6
|
-
* `cf-vite` delegate binary entry point for `@cloudflare/vite-plugin`.
|
|
7
|
-
*
|
|
8
|
-
* EXPERIMENTAL / internal: spawned by Cloudflare's "cf-dev" parent
|
|
9
|
-
* process, not invoked directly by end users. Contract may change.
|
|
10
|
-
*
|
|
11
|
-
* Usage: `<pkgRoot>/bin/cf-vite <verb> [flags...]`. `dev` and `build`
|
|
12
|
-
* are the verbs today; future verbs follow the same shape.
|
|
13
|
-
* Unknown/missing verbs exit 2 (also the parent's version-detection
|
|
14
|
-
* signal).
|
|
15
|
-
*
|
|
16
|
-
* Spawn contract for `dev`: parent uses `stdio: "inherit"` and forwards
|
|
17
|
-
* SIGINT/SIGTERM. Accepted flags mirror the sibling `cf-wrangler`
|
|
18
|
-
* delegate (`--mode`, `--port`, `--host`, `--local`) so the parent can
|
|
19
|
-
* drive either impl interchangeably; everything else lives in the user's
|
|
20
|
-
* `vite.config.ts` / `cloudflare.config.ts`. `cf-vite` boots
|
|
21
|
-
* Vite via `createServer()` against the user's own config (expected to
|
|
22
|
-
* include `cloudflare()`); flags are bridged to it as documented inline.
|
|
23
|
-
*
|
|
24
|
-
* `build` runs Vite's full multi-environment app build via
|
|
25
|
-
* `createBuilder().buildApp()` (NOT the legacy single-environment
|
|
26
|
-
* `build()` helper, which would skip the plugin's worker builds). It
|
|
27
|
-
* accepts only `--mode`. Preview build context is supplied through the
|
|
28
|
-
* `CLOUDFLARE_PREVIEW_BUILD` environment variable so framework-owned build
|
|
29
|
-
* commands can use the same contract.
|
|
30
|
-
*
|
|
31
|
-
* Exit codes: 0 graceful, 2 unknown verb / parse error, 130 SIGINT,
|
|
32
|
-
* 143 SIGTERM.
|
|
33
|
-
*/
|
|
34
|
-
var ArgParseError = class extends Error {
|
|
35
|
-
constructor(message) {
|
|
36
|
-
super(message);
|
|
37
|
-
this.name = "ArgParseError";
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
/** Strict argv parser; mirrors `cf-wrangler`'s flags (unknown → throw). */
|
|
41
|
-
function parseDevArgs(argv) {
|
|
42
|
-
let parsed;
|
|
43
|
-
try {
|
|
44
|
-
parsed = parseArgs({
|
|
45
|
-
args: argv,
|
|
46
|
-
options: {
|
|
47
|
-
mode: { type: "string" },
|
|
48
|
-
host: { type: "string" },
|
|
49
|
-
port: { type: "string" },
|
|
50
|
-
local: { type: "boolean" }
|
|
51
|
-
},
|
|
52
|
-
strict: true,
|
|
53
|
-
allowPositionals: false
|
|
54
|
-
});
|
|
55
|
-
} catch (err) {
|
|
56
|
-
throw new ArgParseError(err instanceof Error ? err.message : String(err));
|
|
57
|
-
}
|
|
58
|
-
const out = {};
|
|
59
|
-
if (parsed.values.mode !== void 0) out.mode = parsed.values.mode;
|
|
60
|
-
if (parsed.values.host !== void 0) out.host = parsed.values.host;
|
|
61
|
-
if (parsed.values.port !== void 0) {
|
|
62
|
-
const raw = parsed.values.port;
|
|
63
|
-
const n = Number(raw);
|
|
64
|
-
if (!Number.isInteger(n) || n < 0 || n > 65535) throw new ArgParseError(`--port expects an integer between 0 and 65535, got "${raw}"`);
|
|
65
|
-
out.port = n;
|
|
66
|
-
}
|
|
67
|
-
if (parsed.values.local !== void 0) out.local = parsed.values.local;
|
|
68
|
-
return out;
|
|
69
|
-
}
|
|
70
|
-
function parseBuildArgs(argv) {
|
|
71
|
-
let parsed;
|
|
72
|
-
try {
|
|
73
|
-
parsed = parseArgs({
|
|
74
|
-
args: argv,
|
|
75
|
-
options: { mode: { type: "string" } },
|
|
76
|
-
strict: true,
|
|
77
|
-
allowPositionals: false
|
|
78
|
-
});
|
|
79
|
-
} catch (err) {
|
|
80
|
-
throw new ArgParseError(err instanceof Error ? err.message : String(err));
|
|
81
|
-
}
|
|
82
|
-
const out = {};
|
|
83
|
-
if (parsed.values.mode !== void 0) out.mode = parsed.values.mode;
|
|
84
|
-
return out;
|
|
85
|
-
}
|
|
86
|
-
async function main() {
|
|
87
|
-
const verb = process.argv[2];
|
|
88
|
-
const userArgv = process.argv.slice(3);
|
|
89
|
-
if (verb === "dev") return runDev(userArgv);
|
|
90
|
-
if (verb === "build") return runBuild(userArgv);
|
|
91
|
-
process.stderr.write(`Error: unknown subcommand "${verb ?? ""}".\nUsage: cf-vite <dev|build> [args]\n`);
|
|
92
|
-
return 2;
|
|
93
|
-
}
|
|
94
|
-
async function runDev(userArgv) {
|
|
95
|
-
let args;
|
|
96
|
-
try {
|
|
97
|
-
args = parseDevArgs(userArgv);
|
|
98
|
-
} catch (err) {
|
|
99
|
-
if (err instanceof ArgParseError) {
|
|
100
|
-
process.stderr.write(`Error: ${err.message}\n`);
|
|
101
|
-
return 2;
|
|
102
|
-
}
|
|
103
|
-
throw err;
|
|
104
|
-
}
|
|
105
|
-
if (args.local) process.env.CLOUDFLARE_VITE_FORCE_LOCAL = "true";
|
|
106
|
-
const serverOptions = {};
|
|
107
|
-
if (args.port !== void 0) serverOptions.port = args.port;
|
|
108
|
-
if (args.host !== void 0) serverOptions.host = args.host;
|
|
109
|
-
const inlineConfig = { server: serverOptions };
|
|
110
|
-
if (args.mode !== void 0) inlineConfig.mode = args.mode;
|
|
111
|
-
const server = await createServer(inlineConfig);
|
|
112
|
-
await server.listen();
|
|
113
|
-
server.printUrls();
|
|
114
|
-
server.bindCLIShortcuts({ print: true });
|
|
115
|
-
let closing = false;
|
|
116
|
-
const shutdown = (signal) => {
|
|
117
|
-
if (closing) return;
|
|
118
|
-
closing = true;
|
|
119
|
-
(async () => {
|
|
120
|
-
try {
|
|
121
|
-
await server.close();
|
|
122
|
-
process.exit(0);
|
|
123
|
-
} catch {
|
|
124
|
-
process.exit(signal === "SIGINT" ? 130 : 143);
|
|
125
|
-
}
|
|
126
|
-
})();
|
|
127
|
-
};
|
|
128
|
-
process.on("SIGINT", () => shutdown("SIGINT"));
|
|
129
|
-
process.on("SIGTERM", () => shutdown("SIGTERM"));
|
|
130
|
-
return new Promise(() => {});
|
|
131
|
-
}
|
|
132
|
-
async function runBuild(userArgv) {
|
|
133
|
-
let args;
|
|
134
|
-
try {
|
|
135
|
-
args = parseBuildArgs(userArgv);
|
|
136
|
-
} catch (err) {
|
|
137
|
-
if (err instanceof ArgParseError) {
|
|
138
|
-
process.stderr.write(`Error: ${err.message}\n`);
|
|
139
|
-
return 2;
|
|
140
|
-
}
|
|
141
|
-
throw err;
|
|
142
|
-
}
|
|
143
|
-
const inlineConfig = {};
|
|
144
|
-
if (args.mode !== void 0) inlineConfig.mode = args.mode;
|
|
145
|
-
await (await createBuilder(inlineConfig)).buildApp();
|
|
146
|
-
return 0;
|
|
147
|
-
}
|
|
148
|
-
const exitCode = await main();
|
|
149
|
-
process.exit(exitCode);
|
|
150
|
-
|
|
151
|
-
//#endregion
|
|
152
|
-
export { };
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
|
|
3
|
-
//#region ../workers-utils/dist/chunk-U6NEESU5.mjs
|
|
4
|
-
const require$1 = createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
5
|
-
var __create = Object.create;
|
|
6
|
-
var __defProp = Object.defineProperty;
|
|
7
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
8
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
9
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
-
var __name = (target, value) => __defProp(target, "name", {
|
|
12
|
-
value,
|
|
13
|
-
configurable: true
|
|
14
|
-
});
|
|
15
|
-
var __require = /* @__PURE__ */ ((x) => typeof require$1 !== "undefined" ? require$1 : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require$1 !== "undefined" ? require$1 : a)[b] }) : x)(function(x) {
|
|
16
|
-
if (typeof require$1 !== "undefined") return require$1.apply(this, arguments);
|
|
17
|
-
throw Error("Dynamic require of \"" + x + "\" is not supported");
|
|
18
|
-
});
|
|
19
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
20
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
21
|
-
};
|
|
22
|
-
var __export = (target, all) => {
|
|
23
|
-
for (var name in all) __defProp(target, name, {
|
|
24
|
-
get: all[name],
|
|
25
|
-
enumerable: true
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
var __copyProps = (to, from, except, desc) => {
|
|
29
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
30
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
31
|
-
get: () => from[key],
|
|
32
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
return to;
|
|
36
|
-
};
|
|
37
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
38
|
-
value: mod,
|
|
39
|
-
enumerable: true
|
|
40
|
-
}) : target, mod));
|
|
41
|
-
|
|
42
|
-
//#endregion
|
|
43
|
-
export { __toESM as a, __require as i, __export as n, __name as r, __commonJS as t };
|