@cloudflare/vite-plugin 1.0.13 → 1.1.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.
package/dist/index.js CHANGED
@@ -1558,7 +1558,7 @@ var MagicString = class _MagicString {
1558
1558
 
1559
1559
  // src/index.ts
1560
1560
  import { Miniflare } from "miniflare";
1561
- import colors2 from "picocolors";
1561
+ import colors3 from "picocolors";
1562
1562
  import * as vite7 from "vite";
1563
1563
 
1564
1564
  // src/constants.ts
@@ -13355,6 +13355,7 @@ import {
13355
13355
  LogLevel,
13356
13356
  Response as MiniflareResponse
13357
13357
  } from "miniflare";
13358
+ import colors2 from "picocolors";
13358
13359
  import { globSync } from "tinyglobby";
13359
13360
  import "vite";
13360
13361
  import { unstable_getMiniflareWorkerOptions } from "wrangler";
@@ -13459,6 +13460,29 @@ function getEntryWorkerConfig(resolvedPluginConfig) {
13459
13460
  }
13460
13461
  return resolvedPluginConfig.workers[resolvedPluginConfig.entryWorkerEnvironmentName];
13461
13462
  }
13463
+ function filterTails(tails, userWorkers, log) {
13464
+ return tails?.filter((tailService) => {
13465
+ let name;
13466
+ if (typeof tailService === "string") {
13467
+ name = tailService;
13468
+ } else if (typeof tailService === "object" && "name" in tailService && typeof tailService.name === "string") {
13469
+ name = tailService.name;
13470
+ } else {
13471
+ return true;
13472
+ }
13473
+ const found = userWorkers.some((w) => w.name === name);
13474
+ if (!found) {
13475
+ log(
13476
+ colors2.dim(
13477
+ colors2.yellow(
13478
+ `Tail consumer "${name}" was not found in your config. Make sure you add it if you'd like to simulate receiving tail events locally.`
13479
+ )
13480
+ )
13481
+ );
13482
+ }
13483
+ return found;
13484
+ });
13485
+ }
13462
13486
  function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer, inspectorPort) {
13463
13487
  const resolvedViteConfig = viteDevServer.config;
13464
13488
  const entryWorkerConfig = getEntryWorkerConfig(resolvedPluginConfig);
@@ -13650,6 +13674,11 @@ function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer, inspectorPo
13650
13674
  }
13651
13675
  return {
13652
13676
  ...workerOptions,
13677
+ tails: filterTails(
13678
+ workerOptions.tails,
13679
+ userWorkers,
13680
+ viteDevServer.config.logger.warn
13681
+ ),
13653
13682
  modules: [
13654
13683
  {
13655
13684
  type: "ESModule",
@@ -13740,6 +13769,11 @@ function getPreviewMiniflareOptions(vitePreviewServer, workerConfigs, persistSta
13740
13769
  return [
13741
13770
  {
13742
13771
  ...workerOptions,
13772
+ tails: filterTails(
13773
+ workerOptions.tails,
13774
+ workerConfigs,
13775
+ vitePreviewServer.config.logger.warn
13776
+ ),
13743
13777
  name: workerOptions.name ?? config.name,
13744
13778
  unsafeInspectorProxy: inspectorPort !== false,
13745
13779
  ...miniflareWorkerOptions.main ? getPreviewModules(miniflareWorkerOptions.main, modulesRules) : { modules: true, script: "" }
@@ -14426,10 +14460,6 @@ function cloudflare2(pluginConfig = {}) {
14426
14460
  }
14427
14461
  },
14428
14462
  async configureServer(viteDevServer) {
14429
- assert10(
14430
- viteDevServer.httpServer,
14431
- "Unexpected error: No Vite HTTP server"
14432
- );
14433
14463
  const inputInspectorPort = await getInputInspectorPortOption(
14434
14464
  pluginConfig,
14435
14465
  viteDevServer
@@ -14462,11 +14492,13 @@ function cloudflare2(pluginConfig = {}) {
14462
14492
  },
14463
14493
  { alwaysCallNext: false }
14464
14494
  );
14465
- handleWebSocket(viteDevServer.httpServer, async () => {
14466
- assert10(miniflare, `Miniflare not defined`);
14467
- const routerWorker = await getRouterWorker(miniflare);
14468
- return routerWorker.fetch;
14469
- });
14495
+ if (viteDevServer.httpServer) {
14496
+ handleWebSocket(viteDevServer.httpServer, async () => {
14497
+ assert10(miniflare, `Miniflare not defined`);
14498
+ const routerWorker = await getRouterWorker(miniflare);
14499
+ return routerWorker.fetch;
14500
+ });
14501
+ }
14470
14502
  return () => {
14471
14503
  viteDevServer.middlewares.use((req, res, next) => {
14472
14504
  middleware(req, res, next);
@@ -14839,7 +14871,7 @@ async function getInputInspectorPortOption(pluginConfig, viteServer) {
14839
14871
  const inputInspectorPort = pluginConfig.inspectorPort ?? await getFirstAvailablePort(DEFAULT_INSPECTOR_PORT);
14840
14872
  if (pluginConfig.inspectorPort === void 0 && inputInspectorPort !== DEFAULT_INSPECTOR_PORT) {
14841
14873
  viteServer.config.logger.warn(
14842
- colors2.dim(
14874
+ colors3.dim(
14843
14875
  `Default inspector port ${DEFAULT_INSPECTOR_PORT} not available, using ${inputInspectorPort} instead
14844
14876
  `
14845
14877
  )
@@ -29,7 +29,7 @@ function stripInternalEnv(internalEnv) {
29
29
  return userEnv;
30
30
  }
31
31
 
32
- // ../../node_modules/.pnpm/vite@6.1.0_@types+node@18.19.76_jiti@2.4.2_lightningcss@1.29.2/node_modules/vite/dist/node/module-runner.js
32
+ // ../../node_modules/.pnpm/vite@6.1.0_@types+node@20.17.32_jiti@2.4.2_lightningcss@1.29.2/node_modules/vite/dist/node/module-runner.js
33
33
  var VALID_ID_PREFIX = "/@id/";
34
34
  var NULL_BYTE_PLACEHOLDER = "__x00__";
35
35
  var SOURCEMAPPING_URL = "sourceMa";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudflare/vite-plugin",
3
- "version": "1.0.13",
3
+ "version": "1.1.1",
4
4
  "description": "Cloudflare plugin for Vite",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -41,11 +41,11 @@
41
41
  "unenv": "2.0.0-rc.15",
42
42
  "ws": "8.18.0",
43
43
  "@cloudflare/unenv-preset": "2.3.1",
44
- "miniflare": "4.20250428.0",
45
- "wrangler": "4.14.0"
44
+ "miniflare": "4.20250507.0",
45
+ "wrangler": "4.14.3"
46
46
  },
47
47
  "devDependencies": {
48
- "@cloudflare/workers-types": "^4.20250428.0",
48
+ "@cloudflare/workers-types": "^4.20250507.0",
49
49
  "@types/node": "^22.10.1",
50
50
  "@types/ws": "^8.5.13",
51
51
  "magic-string": "^0.30.12",