@cloudflare/vite-plugin 2.0.0-beta.v.9 → 2.0.0-rc.1

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.
@@ -1,7 +1,7 @@
1
1
  //#region package.json
2
2
  var package_default = {
3
3
  name: "@cloudflare/vite-plugin",
4
- version: "2.0.0-beta.v.9",
4
+ version: "2.0.0-rc.1",
5
5
  description: "Cloudflare plugin for Vite",
6
6
  keywords: [
7
7
  "cloudflare",
@@ -18,8 +18,7 @@ var package_default = {
18
18
  "url": "https://github.com/cloudflare/workers-sdk.git",
19
19
  "directory": "packages/vite-plugin-cloudflare"
20
20
  },
21
- bin: { "cf-vite": "./bin/cf-vite" },
22
- files: ["bin", "dist"],
21
+ files: ["dist"],
23
22
  type: "module",
24
23
  sideEffects: false,
25
24
  main: "./dist/index.mjs",
@@ -81,7 +80,7 @@ var package_default = {
81
80
  "workers-sdk": {
82
81
  "prerelease": true,
83
82
  "npmPrerelease": {
84
- "tag": "beta",
83
+ "tag": "rc",
85
84
  "numbered": true
86
85
  }
87
86
  }
@@ -5189,17 +5189,27 @@ const staticRedirectsMatcher = (configuration, host, pathname) => {
5189
5189
  else return withoutHostMatch;
5190
5190
  return withHostMatch || withoutHostMatch;
5191
5191
  };
5192
- const generateRedirectsMatcher = (configuration) => generateRulesMatcher(configuration.redirects.version === REDIRECTS_VERSION ? configuration.redirects.rules : {}, ({ status, to }, replacements) => {
5193
- const target = replacer(to, replacements).trim();
5194
- if (/^(\w+:\/\/)/.test(target)) return {
5195
- status,
5196
- to: target
5197
- };
5198
- else return {
5199
- status,
5200
- to: target.replace(/\/+/g, "/")
5201
- };
5202
- });
5192
+ const generateRedirectsMatcher = (configuration) => generateRulesMatcher(configuration.redirects.version === REDIRECTS_VERSION ? configuration.redirects.rules : {}, ({ status, to }, replacements) => ({
5193
+ status,
5194
+ to: normalizeRedirectTarget(to, replacements)
5195
+ }));
5196
+ /**
5197
+ * Replace redirect placeholders and normalize relative pathnames without changing
5198
+ * query values, fragments or explicitly configured external URLs.
5199
+ *
5200
+ * @param value The configured redirect target before placeholder replacement.
5201
+ * @param replacements Placeholder values captured from the request.
5202
+ * @returns A substituted target with repeated relative pathname separators collapsed.
5203
+ */
5204
+ function normalizeRedirectTarget(value, replacements) {
5205
+ const isExternal = /^(?:\w+:\/\/|\/\/[^/\\\s?#])/.test(value.trim());
5206
+ const target = replacer(value, replacements).trim();
5207
+ if (isExternal) return target;
5208
+ const suffixStart = target.search(/[?#]/);
5209
+ const pathname = suffixStart === -1 ? target : target.slice(0, suffixStart);
5210
+ const suffix = suffixStart === -1 ? "" : target.slice(suffixStart);
5211
+ return pathname.replace(/[/\\]+/g, "/") + suffix;
5212
+ }
5203
5213
 
5204
5214
  //#endregion
5205
5215
  //#region ../workers-shared/asset-worker/src/utils/headers.ts
@@ -1,4 +1,4 @@
1
- //#region ../../node_modules/.pnpm/vite@7.1.12_@types+node@22.15.17_jiti@2.6.1_lightningcss@1.33.0_tsx@4.21.0_yaml@2.9.0/node_modules/vite/dist/node/module-runner.js
1
+ //#region ../../node_modules/.pnpm/vite@7.1.12_@types+node@22.15.17_jiti@2.6.1_lightningcss@1.33.0_tsx@4.23.15_yaml@2.9.0/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";
@@ -1,4 +1,4 @@
1
- //#region ../../node_modules/.pnpm/vite@8.3.4_@types+node@22.15.17_esbuild@0.28.2_jiti@2.6.1_tsx@4.21.0_yaml@2.9.0/node_modules/vite/dist/node/module-runner.js
1
+ //#region ../../node_modules/.pnpm/vite@8.3.4_@types+node@22.15.17_esbuild@0.28.2_jiti@2.6.1_tsx@4.23.15_yaml@2.9.0/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";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudflare/vite-plugin",
3
- "version": "2.0.0-beta.v.9",
3
+ "version": "2.0.0-rc.1",
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": "0.9.7",
46
- "@cloudflare/config": "0.29.1",
47
- "@cloudflare/runtime-types": "0.1.20",
41
+ "@cloudflare/build-output-utils": "1.0.0-rc.1",
42
+ "@cloudflare/config": "1.0.0-rc.1",
48
43
  "@cloudflare/unenv-preset": "2.16.2",
49
- "miniflare": "5.20261101.0-beta"
44
+ "miniflare": "5.20261117.0-beta",
45
+ "@cloudflare/runtime-types": "0.1.30"
50
46
  },
51
47
  "devDependencies": {
52
- "@cloudflare/workers-types": "^5.20261101.1",
48
+ "@cloudflare/workers-types": "^5.20261117.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",
@@ -69,14 +65,14 @@
69
65
  "vite": "8.3.4",
70
66
  "vite-legacy": "npm:vite@7.1.12",
71
67
  "vitest": "5.0.4",
72
- "@cloudflare/cli-shared-helpers": "0.3.1",
73
- "@cloudflare/containers-shared": "0.23.6",
68
+ "@cloudflare/cli-shared-helpers": "0.3.10",
69
+ "@cloudflare/containers-shared": "0.26.3",
70
+ "@cloudflare/remote-bindings": "0.0.67",
71
+ "@cloudflare/workers-auth": "0.18.4",
74
72
  "@cloudflare/mock-npm-registry": "0.0.0",
75
- "@cloudflare/remote-bindings": "0.0.57",
76
- "@cloudflare/workers-auth": "0.15.4",
77
- "@cloudflare/workers-shared": "0.20.2",
78
- "@cloudflare/workers-tsconfig": "0.0.0",
79
- "@cloudflare/workers-utils": "0.50.2"
73
+ "@cloudflare/workers-shared": "0.20.3",
74
+ "@cloudflare/workers-utils": "0.54.2",
75
+ "@cloudflare/workers-tsconfig": "0.0.0"
80
76
  },
81
77
  "peerDependencies": {
82
78
  "vite": "^7.0.0 || ^8.0.0"
@@ -84,7 +80,7 @@
84
80
  "workers-sdk": {
85
81
  "prerelease": true,
86
82
  "npmPrerelease": {
87
- "tag": "beta",
83
+ "tag": "rc",
88
84
  "numbered": true
89
85
  }
90
86
  },
package/bin/cf-vite DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import("../dist/cf-vite.mjs");
package/dist/cf-vite.mjs DELETED
@@ -1,158 +0,0 @@
1
- import { parseArgs } from "node:util";
2
- import { createBuilder, createServer } from "vite";
3
-
4
- //#region src/build-output-env.ts
5
- /** Internal caller name set by the `cf-vite` delegate. */
6
- const CLI_DISPLAY_NAME_ENV_VAR = "CLOUDFLARE_VITE_CLI_DISPLAY_NAME";
7
-
8
- //#endregion
9
- //#region src/cf-vite.ts
10
- /**
11
- * `cf-vite` delegate binary entry point for `@cloudflare/vite-plugin`.
12
- *
13
- * EXPERIMENTAL / internal: spawned by Cloudflare's "cf-dev" parent
14
- * process, not invoked directly by end users. Contract may change.
15
- *
16
- * Usage: `<pkgRoot>/bin/cf-vite <verb> [flags...]`. `dev` and `build`
17
- * are the verbs today; future verbs follow the same shape.
18
- * Unknown/missing verbs exit 2 (also the parent's version-detection
19
- * signal).
20
- *
21
- * Spawn contract for `dev`: parent uses `stdio: "inherit"` and forwards
22
- * SIGINT/SIGTERM. Accepted flags mirror the sibling `cf-wrangler`
23
- * delegate (`--mode`, `--port`, `--host`, `--local`) so the parent can
24
- * drive either impl interchangeably; everything else lives in the user's
25
- * `vite.config.ts` / `cloudflare.config.ts`. `cf-vite` boots
26
- * Vite via `createServer()` against the user's own config (expected to
27
- * include `cloudflare()`); flags are bridged to it as documented inline.
28
- *
29
- * `build` runs Vite's full multi-environment app build via
30
- * `createBuilder().buildApp()` (NOT the legacy single-environment
31
- * `build()` helper, which would skip the plugin's worker builds). It
32
- * accepts only `--mode`. Preview build context is supplied through the
33
- * `CLOUDFLARE_PREVIEW_BUILD` environment variable so framework-owned build
34
- * commands can use the same contract.
35
- *
36
- * Exit codes: 0 graceful, 2 unknown verb / parse error, 130 SIGINT,
37
- * 143 SIGTERM.
38
- */
39
- var ArgParseError = class extends Error {
40
- constructor(message) {
41
- super(message);
42
- this.name = "ArgParseError";
43
- }
44
- };
45
- /** Strict argv parser; mirrors `cf-wrangler`'s flags (unknown → throw). */
46
- function parseDevArgs(argv) {
47
- let parsed;
48
- try {
49
- parsed = parseArgs({
50
- args: argv,
51
- options: {
52
- mode: { type: "string" },
53
- host: { type: "string" },
54
- port: { type: "string" },
55
- local: { type: "boolean" }
56
- },
57
- strict: true,
58
- allowPositionals: false
59
- });
60
- } catch (err) {
61
- throw new ArgParseError(err instanceof Error ? err.message : String(err));
62
- }
63
- const out = {};
64
- if (parsed.values.mode !== void 0) out.mode = parsed.values.mode;
65
- if (parsed.values.host !== void 0) out.host = parsed.values.host;
66
- if (parsed.values.port !== void 0) {
67
- const raw = parsed.values.port;
68
- const n = Number(raw);
69
- if (!Number.isInteger(n) || n < 0 || n > 65535) throw new ArgParseError(`--port expects an integer between 0 and 65535, got "${raw}"`);
70
- out.port = n;
71
- }
72
- if (parsed.values.local !== void 0) out.local = parsed.values.local;
73
- return out;
74
- }
75
- function parseBuildArgs(argv) {
76
- let parsed;
77
- try {
78
- parsed = parseArgs({
79
- args: argv,
80
- options: { mode: { type: "string" } },
81
- strict: true,
82
- allowPositionals: false
83
- });
84
- } catch (err) {
85
- throw new ArgParseError(err instanceof Error ? err.message : String(err));
86
- }
87
- const out = {};
88
- if (parsed.values.mode !== void 0) out.mode = parsed.values.mode;
89
- return out;
90
- }
91
- async function main() {
92
- process.env[CLI_DISPLAY_NAME_ENV_VAR] = "cf";
93
- const verb = process.argv[2];
94
- const userArgv = process.argv.slice(3);
95
- if (verb === "dev") return runDev(userArgv);
96
- if (verb === "build") return runBuild(userArgv);
97
- process.stderr.write(`Error: unknown subcommand "${verb ?? ""}".\nUsage: cf-vite <dev|build> [args]\n`);
98
- return 2;
99
- }
100
- async function runDev(userArgv) {
101
- let args;
102
- try {
103
- args = parseDevArgs(userArgv);
104
- } catch (err) {
105
- if (err instanceof ArgParseError) {
106
- process.stderr.write(`Error: ${err.message}\n`);
107
- return 2;
108
- }
109
- throw err;
110
- }
111
- if (args.local) process.env.CLOUDFLARE_VITE_FORCE_LOCAL = "true";
112
- const serverOptions = {};
113
- if (args.port !== void 0) serverOptions.port = args.port;
114
- if (args.host !== void 0) serverOptions.host = args.host;
115
- const inlineConfig = { server: serverOptions };
116
- if (args.mode !== void 0) inlineConfig.mode = args.mode;
117
- const server = await createServer(inlineConfig);
118
- await server.listen();
119
- server.printUrls();
120
- server.bindCLIShortcuts({ print: true });
121
- let closing = false;
122
- const shutdown = (signal) => {
123
- if (closing) return;
124
- closing = true;
125
- (async () => {
126
- try {
127
- await server.close();
128
- process.exit(0);
129
- } catch {
130
- process.exit(signal === "SIGINT" ? 130 : 143);
131
- }
132
- })();
133
- };
134
- process.on("SIGINT", () => shutdown("SIGINT"));
135
- process.on("SIGTERM", () => shutdown("SIGTERM"));
136
- return new Promise(() => {});
137
- }
138
- async function runBuild(userArgv) {
139
- let args;
140
- try {
141
- args = parseBuildArgs(userArgv);
142
- } catch (err) {
143
- if (err instanceof ArgParseError) {
144
- process.stderr.write(`Error: ${err.message}\n`);
145
- return 2;
146
- }
147
- throw err;
148
- }
149
- const inlineConfig = {};
150
- if (args.mode !== void 0) inlineConfig.mode = args.mode;
151
- await (await createBuilder(inlineConfig)).buildApp();
152
- return 0;
153
- }
154
- const exitCode = await main();
155
- process.exit(exitCode);
156
-
157
- //#endregion
158
- export { };