@cloudflare/vite-plugin 0.0.0-e62b097bb → 0.0.0-e7c7235fd

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 CHANGED
@@ -466,13 +466,6 @@ The value of `MY_VAR` will therefore be `'Production var'`.
466
466
  If you run `vite build --mode staging` then the 'staging' Vite mode will be used and the 'staging' Cloudflare environment will be selected.
467
467
  The value of `MY_VAR` will therefore be `'Staging var'`.
468
468
 
469
- ## Secrets
470
-
471
- Secrets can be provided to your Worker in local development using a [`.dev.vars`](https://developers.cloudflare.com/workers/configuration/secrets/#local-development-with-secrets) file. If you are using [Cloudflare Environments](#cloudflare-environments) then the relevant `.dev.vars` file will be selected. For example, `CLOUDFLARE_ENV=staging vite dev` will load `.dev.vars.staging` if it exists and fall back to `.dev.vars`.
472
-
473
- > [!NOTE]
474
- > The `vite build` command copies the relevant `.dev.vars[.env-name]` file to the output directory. This is only used when running `vite preview` and is not deployed with your Worker.
475
-
476
469
  ## Migrating from `wrangler dev`
477
470
 
478
471
  Migrating from `wrangler dev` is a simple process and you can follow the instructions in the [Quick start](#quick-start) to get started.
@@ -2359,10 +2359,7 @@ var vs = (t, e) => {
2359
2359
  return 0;
2360
2360
  };
2361
2361
  var ks = (t) => [...t.slice(16, 16 + 16)].map((n) => n.toString(16).padStart(2, "0")).join("");
2362
- var Ut = (t) => {
2363
- let e;
2364
- return t?.run_worker_first !== void 0 ? e = t?.run_worker_first : t?.serve_directly !== void 0 ? e = !t.serve_directly : e = false, { html_handling: t?.html_handling ?? "auto-trailing-slash", not_found_handling: t?.not_found_handling ?? "none", run_worker_first: e, serve_directly: !e };
2365
- };
2362
+ var Ut = (t) => ({ html_handling: t?.html_handling ?? "auto-trailing-slash", not_found_handling: t?.not_found_handling ?? "none", serve_directly: t?.serve_directly ?? true });
2366
2363
  var Zn = "public, max-age=0, must-revalidate";
2367
2364
  function Qn(t, e, n) {
2368
2365
  let r = new Headers({ "Content-Type": e, ETag: `"${t}"` });
@@ -2526,11 +2523,8 @@ async function tr(t, e, n, r = 1) {
2526
2523
  return o.value !== null && n && n.captureException(new Error(`Initial request for asset ${e} failed, but subsequent request succeeded.`)), o;
2527
2524
  }
2528
2525
  return i;
2529
- } catch (i) {
2530
- if (s >= r) {
2531
- let o = `KV GET ${e} failed.`;
2532
- throw i instanceof Error && (o = `KV GET ${e} failed: ${i.message}`), new Error(o);
2533
- }
2526
+ } catch {
2527
+ if (s >= r) throw new Error(`Requested asset ${e} could not be fetched from KV namespace.`);
2534
2528
  await new Promise((o) => setTimeout(o, Math.pow(2, s++) * 1e3));
2535
2529
  }
2536
2530
  }
@@ -2542,9 +2536,8 @@ var nr = class extends Bs {
2542
2536
  let i = Ut(this.env.CONFIG), o = t.headers.get("user-agent") ?? "UA UNKNOWN", a = new URL(t.url);
2543
2537
  return this.env.COLO_METADATA && this.env.VERSION_METADATA && this.env.CONFIG && n.setData({ accountId: this.env.CONFIG.account_id, scriptId: this.env.CONFIG.script_id, coloId: this.env.COLO_METADATA.coloId, metalId: this.env.COLO_METADATA.metalId, coloTier: this.env.COLO_METADATA.coloTier, coloRegion: this.env.COLO_METADATA.coloRegion, version: this.env.VERSION_METADATA.id, hostname: a.hostname, htmlHandling: i.html_handling, notFoundHandling: i.not_found_handling, userAgent: o }), await this.env.JAEGER.enterSpan("handleRequest", async (c) => (c.setTags({ hostname: a.hostname, eyeballPath: a.pathname, env: this.env.ENVIRONMENT, version: this.env.VERSION_METADATA?.id }), er(t, this.env, i, this.unstable_exists.bind(this), this.unstable_getByETag.bind(this))));
2544
2538
  } catch (i) {
2545
- return this.handleError(e, n, i);
2546
- } finally {
2547
- this.submitMetrics(n, r, s);
2539
+ let o = this.handleError(e, n, i);
2540
+ return this.submitMetrics(n, r, s), o;
2548
2541
  }
2549
2542
  }
2550
2543
  handleError(t, e, n) {
package/dist/index.js CHANGED
@@ -1637,13 +1637,10 @@ function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer) {
1637
1637
  ];
1638
1638
  const userWorkers = resolvedPluginConfig.type === "workers" ? Object.entries(resolvedPluginConfig.workers).map(
1639
1639
  ([environmentName, workerConfig]) => {
1640
- const miniflareWorkerOptions = unstable_getMiniflareWorkerOptions(
1641
- {
1642
- ...workerConfig,
1643
- assets: void 0
1644
- },
1645
- resolvedPluginConfig.cloudflareEnv
1646
- );
1640
+ const miniflareWorkerOptions = unstable_getMiniflareWorkerOptions({
1641
+ ...workerConfig,
1642
+ assets: void 0
1643
+ });
1647
1644
  const { ratelimits, ...workerOptions } = miniflareWorkerOptions.workerOptions;
1648
1645
  return {
1649
1646
  ...workerOptions,
@@ -2067,21 +2064,20 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
2067
2064
  const configPaths = /* @__PURE__ */ new Set();
2068
2065
  const persistState = pluginConfig.persistState ?? true;
2069
2066
  const root = userConfig.root ? path5.resolve(userConfig.root) : process.cwd();
2070
- const { CLOUDFLARE_ENV: cloudflareEnv } = vite5.loadEnv(
2071
- viteEnv.mode,
2072
- root,
2073
- /* prefixes */
2074
- ""
2075
- );
2067
+ const { CLOUDFLARE_ENV } = vite5.loadEnv(viteEnv.mode, root, "");
2076
2068
  const configPath = pluginConfig.configPath ? path5.resolve(root, pluginConfig.configPath) : findWranglerConfig(root);
2077
2069
  assert6(
2078
2070
  configPath,
2079
2071
  `Config not found. Have you created a wrangler.json(c) or wrangler.toml file?`
2080
2072
  );
2081
- const entryWorkerResolvedConfig = getWorkerConfig(configPath, cloudflareEnv, {
2082
- visitedConfigPaths: configPaths,
2083
- isEntryWorker: true
2084
- });
2073
+ const entryWorkerResolvedConfig = getWorkerConfig(
2074
+ configPath,
2075
+ CLOUDFLARE_ENV,
2076
+ {
2077
+ visitedConfigPaths: configPaths,
2078
+ isEntryWorker: true
2079
+ }
2080
+ );
2085
2081
  if (entryWorkerResolvedConfig.type === "assets-only") {
2086
2082
  return {
2087
2083
  type: "assets-only",
@@ -2090,8 +2086,7 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
2090
2086
  persistState,
2091
2087
  rawConfigs: {
2092
2088
  entryWorker: entryWorkerResolvedConfig
2093
- },
2094
- cloudflareEnv
2089
+ }
2095
2090
  };
2096
2091
  }
2097
2092
  const entryWorkerConfig = entryWorkerResolvedConfig.config;
@@ -2103,7 +2098,7 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
2103
2098
  for (const auxiliaryWorker of pluginConfig.auxiliaryWorkers ?? []) {
2104
2099
  const workerResolvedConfig = getWorkerConfig(
2105
2100
  path5.resolve(root, auxiliaryWorker.configPath),
2106
- cloudflareEnv,
2101
+ CLOUDFLARE_ENV,
2107
2102
  {
2108
2103
  visitedConfigPaths: configPaths
2109
2104
  }
@@ -2131,8 +2126,7 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
2131
2126
  rawConfigs: {
2132
2127
  entryWorker: entryWorkerResolvedConfig,
2133
2128
  auxiliaryWorkers: auxiliaryWorkersResolvedConfigs
2134
- },
2135
- cloudflareEnv
2129
+ }
2136
2130
  };
2137
2131
  }
2138
2132
 
@@ -2323,28 +2317,13 @@ function cloudflare2(pluginConfig = {}) {
2323
2317
  );
2324
2318
  }
2325
2319
  config = workerConfig;
2326
- if (workerConfig.configPath) {
2327
- const dotDevDotVarsContent = getDotDevDotVarsContent(
2328
- workerConfig.configPath,
2329
- resolvedPluginConfig.cloudflareEnv
2330
- );
2331
- if (dotDevDotVarsContent) {
2332
- this.emitFile({
2333
- type: "asset",
2334
- fileName: ".dev.vars",
2335
- source: dotDevDotVarsContent
2336
- });
2337
- }
2338
- }
2339
2320
  } else if (this.environment.name === "client") {
2340
2321
  const assetsOnlyConfig = resolvedPluginConfig.config;
2341
2322
  assetsOnlyConfig.assets.directory = ".";
2342
- const filesToAssetsIgnore = ["wrangler.json", ".dev.vars"];
2343
2323
  this.emitFile({
2344
2324
  type: "asset",
2345
2325
  fileName: ".assetsignore",
2346
- source: `${filesToAssetsIgnore.join("\n")}
2347
- `
2326
+ source: "wrangler.json"
2348
2327
  });
2349
2328
  config = assetsOnlyConfig;
2350
2329
  }
@@ -2424,17 +2403,6 @@ function cloudflare2(pluginConfig = {}) {
2424
2403
  }
2425
2404
  };
2426
2405
  }
2427
- function getDotDevDotVarsContent(configPath, cloudflareEnv) {
2428
- const configDir = path6.dirname(configPath);
2429
- const defaultDotDevDotVarsPath = `${configDir}/.dev.vars`;
2430
- const inputDotDevDotVarsPath = `${defaultDotDevDotVarsPath}${cloudflareEnv ? `.${cloudflareEnv}` : ""}`;
2431
- const targetPath = fs4.existsSync(inputDotDevDotVarsPath) ? inputDotDevDotVarsPath : fs4.existsSync(defaultDotDevDotVarsPath) ? defaultDotDevDotVarsPath : null;
2432
- if (targetPath) {
2433
- const dotDevDotVarsContent = fs4.readFileSync(targetPath);
2434
- return dotDevDotVarsContent;
2435
- }
2436
- return null;
2437
- }
2438
2406
  export {
2439
2407
  cloudflare2 as cloudflare
2440
2408
  };
@@ -21,7 +21,7 @@ function stripInternalEnv(internalEnv) {
21
21
  return userEnv;
22
22
  }
23
23
 
24
- // ../../node_modules/.pnpm/vite@6.0.7_@types+node@18.19.74_jiti@2.4.2/node_modules/vite/dist/node/module-runner.js
24
+ // ../../node_modules/.pnpm/vite@6.0.7_@types+node@18.19.59_jiti@2.4.2/node_modules/vite/dist/node/module-runner.js
25
25
  var VALID_ID_PREFIX = "/@id/";
26
26
  var NULL_BYTE_PLACEHOLDER = "__x00__";
27
27
  var SOURCEMAPPING_URL = "sourceMa";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudflare/vite-plugin",
3
- "version": "0.0.0-e62b097bb",
3
+ "version": "0.0.0-e7c7235fd",
4
4
  "description": "Cloudflare plugin for Vite",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -36,10 +36,10 @@
36
36
  "@hattip/adapter-node": "^0.0.49",
37
37
  "unenv": "npm:unenv-nightly@2.0.0-20241218-183400-5d6aec3",
38
38
  "ws": "^8.18.0",
39
- "miniflare": "0.0.0-e62b097bb"
39
+ "miniflare": "0.0.0-e7c7235fd"
40
40
  },
41
41
  "devDependencies": {
42
- "@cloudflare/workers-types": "^4.20250204.0",
42
+ "@cloudflare/workers-types": "^4.20250121.0",
43
43
  "@types/node": "^22.10.1",
44
44
  "@types/ws": "^8.5.13",
45
45
  "magic-string": "^0.30.12",
@@ -47,8 +47,8 @@
47
47
  "typescript": "^5.7.2",
48
48
  "vite": "^6.0.7",
49
49
  "@cloudflare/workers-tsconfig": "0.0.0",
50
- "@cloudflare/workers-shared": "0.0.0-e62b097bb",
51
- "wrangler": "0.0.0-e62b097bb"
50
+ "wrangler": "0.0.0-e7c7235fd",
51
+ "@cloudflare/workers-shared": "0.0.0-e7c7235fd"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "vite": "^6.0.7",