@cloudflare/vite-plugin 1.10.2 → 1.11.0

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
@@ -486,8 +486,10 @@ var require_mime = __commonJS({
486
486
 
487
487
  // src/index.ts
488
488
  import assert12 from "node:assert";
489
+ import { randomUUID as randomUUID2 } from "node:crypto";
489
490
  import * as fsp2 from "node:fs/promises";
490
491
  import * as path13 from "node:path";
492
+ import util3 from "node:util";
491
493
 
492
494
  // ../containers-shared/src/utils.ts
493
495
  import { execFileSync, spawn as spawn2 } from "child_process";
@@ -1786,6 +1788,7 @@ var MagicString = class _MagicString {
1786
1788
 
1787
1789
  // src/index.ts
1788
1790
  import { Miniflare } from "miniflare";
1791
+ import colors4 from "picocolors";
1789
1792
  import * as vite6 from "vite";
1790
1793
 
1791
1794
  // src/constants.ts
@@ -2298,36 +2301,36 @@ function maybeGetFile(filePath) {
2298
2301
 
2299
2302
  // ../../node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/index.mjs
2300
2303
  var util;
2301
- (function(util2) {
2302
- util2.assertEqual = (val) => val;
2304
+ (function(util4) {
2305
+ util4.assertEqual = (val) => val;
2303
2306
  function assertIs(_arg) {
2304
2307
  }
2305
- util2.assertIs = assertIs;
2308
+ util4.assertIs = assertIs;
2306
2309
  function assertNever(_x) {
2307
2310
  throw new Error();
2308
2311
  }
2309
- util2.assertNever = assertNever;
2310
- util2.arrayToEnum = (items) => {
2312
+ util4.assertNever = assertNever;
2313
+ util4.arrayToEnum = (items) => {
2311
2314
  const obj = {};
2312
2315
  for (const item of items) {
2313
2316
  obj[item] = item;
2314
2317
  }
2315
2318
  return obj;
2316
2319
  };
2317
- util2.getValidEnumValues = (obj) => {
2318
- const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
2320
+ util4.getValidEnumValues = (obj) => {
2321
+ const validKeys = util4.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
2319
2322
  const filtered = {};
2320
2323
  for (const k of validKeys) {
2321
2324
  filtered[k] = obj[k];
2322
2325
  }
2323
- return util2.objectValues(filtered);
2326
+ return util4.objectValues(filtered);
2324
2327
  };
2325
- util2.objectValues = (obj) => {
2326
- return util2.objectKeys(obj).map(function(e) {
2328
+ util4.objectValues = (obj) => {
2329
+ return util4.objectKeys(obj).map(function(e) {
2327
2330
  return obj[e];
2328
2331
  });
2329
2332
  };
2330
- util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
2333
+ util4.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
2331
2334
  const keys = [];
2332
2335
  for (const key in object) {
2333
2336
  if (Object.prototype.hasOwnProperty.call(object, key)) {
@@ -2336,19 +2339,19 @@ var util;
2336
2339
  }
2337
2340
  return keys;
2338
2341
  };
2339
- util2.find = (arr, checker) => {
2342
+ util4.find = (arr, checker) => {
2340
2343
  for (const item of arr) {
2341
2344
  if (checker(item))
2342
2345
  return item;
2343
2346
  }
2344
2347
  return void 0;
2345
2348
  };
2346
- util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
2349
+ util4.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
2347
2350
  function joinValues(array, separator = " | ") {
2348
2351
  return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
2349
2352
  }
2350
- util2.joinValues = joinValues;
2351
- util2.jsonStringifyReplacer = (_, value) => {
2353
+ util4.joinValues = joinValues;
2354
+ util4.jsonStringifyReplacer = (_, value) => {
2352
2355
  if (typeof value === "bigint") {
2353
2356
  return value.toString();
2354
2357
  }
@@ -6285,6 +6288,7 @@ function getImportedAssetPaths(viteManifest) {
6285
6288
 
6286
6289
  // src/cloudflare-environment.ts
6287
6290
  import assert4 from "node:assert";
6291
+ import util2 from "node:util";
6288
6292
  import * as vite2 from "vite";
6289
6293
 
6290
6294
  // src/node-js-compat.ts
@@ -13454,6 +13458,7 @@ function toMiniflareRequest(request2) {
13454
13458
 
13455
13459
  // src/cloudflare-environment.ts
13456
13460
  var webSocketUndefinedError = "The WebSocket is undefined";
13461
+ var debuglog = util2.debuglog("@cloudflare:vite-plugin");
13457
13462
  function createHotChannel(webSocketContainer) {
13458
13463
  const listenersMap = /* @__PURE__ */ new Map();
13459
13464
  const client = {
@@ -13507,14 +13512,15 @@ var CloudflareDevEnvironment = class extends vite2.DevEnvironment {
13507
13512
  });
13508
13513
  this.#webSocketContainer = webSocketContainer;
13509
13514
  }
13510
- async initRunner(worker, workerConfig) {
13515
+ async initRunner(worker, workerConfig, configId) {
13511
13516
  this.#worker = worker;
13512
13517
  const response = await this.#worker.fetch(
13513
13518
  new URL(INIT_PATH, UNKNOWN_HOST),
13514
13519
  {
13515
13520
  headers: {
13516
13521
  [VITE_DEV_METADATA_HEADER]: JSON.stringify({
13517
- entryPath: workerConfig.main
13522
+ entryPath: workerConfig.main,
13523
+ configId
13518
13524
  }),
13519
13525
  upgrade: "websocket"
13520
13526
  }
@@ -13598,12 +13604,13 @@ function createCloudflareEnvironmentOptions(workerConfig, userConfig, environmen
13598
13604
  keepProcessEnv: isNodeCompat(workerConfig)
13599
13605
  };
13600
13606
  }
13601
- function initRunners(resolvedPluginConfig, viteDevServer, miniflare2) {
13607
+ function initRunners(resolvedPluginConfig, viteDevServer, miniflare2, configId) {
13602
13608
  return Promise.all(
13603
13609
  Object.entries(resolvedPluginConfig.workers).map(
13604
13610
  async ([environmentName, workerConfig]) => {
13611
+ debuglog(configId, "Initializing worker:", workerConfig.name);
13605
13612
  const worker = await miniflare2.getWorker(workerConfig.name);
13606
- return viteDevServer.environments[environmentName].initRunner(worker, workerConfig);
13613
+ return viteDevServer.environments[environmentName].initRunner(worker, workerConfig, configId);
13607
13614
  }
13608
13615
  )
13609
13616
  );
@@ -14826,36 +14833,45 @@ function writeDeployConfig(resolvedPluginConfig, resolvedViteConfig) {
14826
14833
  }
14827
14834
 
14828
14835
  // src/dev-vars.ts
14829
- import * as fs4 from "node:fs";
14830
14836
  import * as path9 from "node:path";
14831
- function getDotDevDotVarsContent(configPath, cloudflareEnv) {
14832
- const configDir = path9.dirname(configPath);
14833
- const defaultDotDevDotVarsPath = `${configDir}/.dev.vars`;
14834
- const inputDotDevDotVarsPath = `${defaultDotDevDotVarsPath}${cloudflareEnv ? `.${cloudflareEnv}` : ""}`;
14835
- const targetPath = fs4.existsSync(inputDotDevDotVarsPath) ? inputDotDevDotVarsPath : fs4.existsSync(defaultDotDevDotVarsPath) ? defaultDotDevDotVarsPath : null;
14836
- if (targetPath) {
14837
- const dotDevDotVarsContent = fs4.readFileSync(targetPath);
14837
+ import { unstable_getVarsForDev } from "wrangler";
14838
+ function getLocalDevVarsForPreview(configPath, cloudflareEnv) {
14839
+ const dotDevDotVars = unstable_getVarsForDev(
14840
+ configPath,
14841
+ void 0,
14842
+ // We don't currently support setting a list of custom `.env` files.
14843
+ {},
14844
+ // Don't pass actual vars since these will be loaded from the wrangler.json.
14845
+ cloudflareEnv
14846
+ );
14847
+ const dotDevDotVarsEntries = Array.from(Object.entries(dotDevDotVars));
14848
+ if (dotDevDotVarsEntries.length > 0) {
14849
+ const dotDevDotVarsContent = dotDevDotVarsEntries.map(([key, value]) => {
14850
+ return `${key} = "${value?.toString().replaceAll(`"`, `\\"`)}"
14851
+ `;
14852
+ }).join("");
14838
14853
  return dotDevDotVarsContent;
14839
14854
  }
14840
- return null;
14841
14855
  }
14842
- function hasDotDevDotVarsFileChanged(resolvedPluginConfig, changedFilePath) {
14843
- return [...resolvedPluginConfig.configPaths].some((configPath) => {
14844
- const dotDevDotVars = path9.join(path9.dirname(configPath), ".dev.vars");
14845
- if (dotDevDotVars === changedFilePath) {
14846
- return true;
14847
- }
14848
- if (resolvedPluginConfig.cloudflareEnv) {
14849
- const dotDevDotVarsForEnv = `${dotDevDotVars}.${resolvedPluginConfig.cloudflareEnv}`;
14850
- return dotDevDotVarsForEnv === changedFilePath;
14851
- }
14852
- return false;
14856
+ function hasLocalDevVarsFileChanged({
14857
+ configPaths,
14858
+ cloudflareEnv
14859
+ }, changedFilePath) {
14860
+ return [...configPaths].some((configPath) => {
14861
+ const configDir = path9.dirname(configPath);
14862
+ return [
14863
+ ".dev.vars",
14864
+ ".env",
14865
+ ...cloudflareEnv ? [`.dev.vars.${cloudflareEnv}`, `.env.${cloudflareEnv}`] : []
14866
+ ].some(
14867
+ (localDevFile) => changedFilePath === path9.join(configDir, localDevFile)
14868
+ );
14853
14869
  });
14854
14870
  }
14855
14871
 
14856
14872
  // src/miniflare-options.ts
14857
14873
  import assert8 from "node:assert";
14858
- import * as fs5 from "node:fs";
14874
+ import * as fs4 from "node:fs";
14859
14875
  import * as fsp from "node:fs/promises";
14860
14876
  import * as path10 from "node:path";
14861
14877
  import { fileURLToPath as fileURLToPath2 } from "node:url";
@@ -15015,7 +15031,7 @@ async function getDevMiniflareOptions(config) {
15015
15031
  {
15016
15032
  type: "ESModule",
15017
15033
  path: path10.join(miniflareModulesRoot, ROUTER_WORKER_PATH),
15018
- contents: fs5.readFileSync(
15034
+ contents: fs4.readFileSync(
15019
15035
  fileURLToPath2(new URL(ROUTER_WORKER_PATH, import.meta.url))
15020
15036
  )
15021
15037
  }
@@ -15038,7 +15054,7 @@ async function getDevMiniflareOptions(config) {
15038
15054
  {
15039
15055
  type: "ESModule",
15040
15056
  path: path10.join(miniflareModulesRoot, ASSET_WORKER_PATH),
15041
- contents: fs5.readFileSync(
15057
+ contents: fs4.readFileSync(
15042
15058
  fileURLToPath2(new URL(ASSET_WORKER_PATH, import.meta.url))
15043
15059
  )
15044
15060
  }
@@ -15258,7 +15274,7 @@ async function getDevMiniflareOptions(config) {
15258
15274
  {
15259
15275
  type: "ESModule",
15260
15276
  path: path10.join(miniflareModulesRoot, RUNNER_PATH),
15261
- contents: fs5.readFileSync(
15277
+ contents: fs4.readFileSync(
15262
15278
  fileURLToPath2(new URL(RUNNER_PATH, import.meta.url))
15263
15279
  )
15264
15280
  }
@@ -15524,7 +15540,7 @@ import * as vite5 from "vite";
15524
15540
 
15525
15541
  // src/workers-configs.ts
15526
15542
  import assert9 from "node:assert";
15527
- import * as fs6 from "node:fs";
15543
+ import * as fs5 from "node:fs";
15528
15544
  import * as path11 from "node:path";
15529
15545
  import { unstable_readConfig as unstable_readConfig2 } from "wrangler";
15530
15546
  var nonApplicableWorkerConfigs = {
@@ -15708,7 +15724,7 @@ function getWorkerConfig(configPath, env2, opts) {
15708
15724
  if (!config.main) {
15709
15725
  throw new Error(missingFieldErrorMessage(`'main'`, configPath, env2));
15710
15726
  }
15711
- const mainStat = fs6.statSync(config.main, { throwIfNoEntry: false });
15727
+ const mainStat = fs5.statSync(config.main, { throwIfNoEntry: false });
15712
15728
  if (!mainStat) {
15713
15729
  throw new Error(
15714
15730
  `The provided Wrangler config main field (${config.main}) doesn't point to an existing file`
@@ -15742,7 +15758,7 @@ function getValidatedWranglerConfigPath(root, requestedConfigPath, isForAuxiliar
15742
15758
  `${errorMessagePrefix} doesn't point to a file with the correct file extension. It should point to a jsonc, json or toml file (${foundExtensionMessage} instead)`
15743
15759
  );
15744
15760
  }
15745
- const mainStat = fs6.statSync(configPath2, { throwIfNoEntry: false });
15761
+ const mainStat = fs5.statSync(configPath2, { throwIfNoEntry: false });
15746
15762
  if (!mainStat) {
15747
15763
  throw new Error(
15748
15764
  `${errorMessagePrefix} doesn't point to an existing file`
@@ -15770,7 +15786,7 @@ function getValidatedWranglerConfigPath(root, requestedConfigPath, isForAuxiliar
15770
15786
  function findWranglerConfig(root) {
15771
15787
  for (const extension of allowedWranglerConfigExtensions) {
15772
15788
  const configPath = path11.join(root, `wrangler.${extension}`);
15773
- if (fs6.existsSync(configPath)) {
15789
+ if (fs5.existsSync(configPath)) {
15774
15790
  return configPath;
15775
15791
  }
15776
15792
  }
@@ -15968,6 +15984,7 @@ function handleWebSocket(httpServer, getFetcher) {
15968
15984
  }
15969
15985
 
15970
15986
  // src/index.ts
15987
+ var debuglog2 = util3.debuglog("@cloudflare:vite-plugin");
15971
15988
  var workersConfigsWarningShown = false;
15972
15989
  var miniflare;
15973
15990
  function cloudflare(pluginConfig = {}) {
@@ -15977,6 +15994,7 @@ function cloudflare(pluginConfig = {}) {
15977
15994
  const nodeJsCompatWarningsMap = /* @__PURE__ */ new Map();
15978
15995
  let containerImageTagsSeen;
15979
15996
  let runningContainerIds;
15997
+ let restartingServer = false;
15980
15998
  return [
15981
15999
  {
15982
16000
  name: "vite-plugin-cloudflare",
@@ -16114,15 +16132,15 @@ if (import.meta.hot) {
16114
16132
  }
16115
16133
  config = workerConfig;
16116
16134
  if (workerConfig.configPath) {
16117
- const dotDevDotVarsContent = getDotDevDotVarsContent(
16135
+ const localDevVars = getLocalDevVarsForPreview(
16118
16136
  workerConfig.configPath,
16119
16137
  resolvedPluginConfig.cloudflareEnv
16120
16138
  );
16121
- if (dotDevDotVarsContent) {
16139
+ if (localDevVars) {
16122
16140
  this.emitFile({
16123
16141
  type: "asset",
16124
16142
  fileName: ".dev.vars",
16125
- source: dotDevDotVarsContent
16143
+ source: localDevVars
16126
16144
  });
16127
16145
  }
16128
16146
  }
@@ -16159,27 +16177,44 @@ if (import.meta.hot) {
16159
16177
  writeDeployConfig(resolvedPluginConfig, resolvedViteConfig);
16160
16178
  }
16161
16179
  },
16162
- hotUpdate(options) {
16163
- assertIsNotPreview(resolvedPluginConfig);
16164
- const changedFilePath = path13.resolve(options.file);
16165
- if (resolvedPluginConfig.configPaths.has(changedFilePath) || hasDotDevDotVarsFileChanged(resolvedPluginConfig, changedFilePath) || hasAssetsConfigChanged(
16166
- resolvedPluginConfig,
16167
- resolvedViteConfig,
16168
- changedFilePath
16169
- )) {
16170
- options.server.restart();
16171
- return [];
16172
- }
16173
- },
16174
16180
  // Vite `configureServer` Hook
16175
16181
  // see https://vite.dev/guide/api-plugin.html#configureserver
16176
16182
  async configureServer(viteDevServer) {
16183
+ const restartServer = viteDevServer.restart.bind(viteDevServer);
16184
+ viteDevServer.restart = async () => {
16185
+ try {
16186
+ restartingServer = true;
16187
+ debuglog2(configId, "From server.restart(): Restarting server...");
16188
+ await restartServer();
16189
+ debuglog2(configId, "From server.restart(): Restarted server...");
16190
+ } finally {
16191
+ restartingServer = false;
16192
+ }
16193
+ };
16177
16194
  assertIsNotPreview(resolvedPluginConfig);
16195
+ const configId = randomUUID2();
16178
16196
  const inputInspectorPort = await getInputInspectorPortOption(
16179
16197
  resolvedPluginConfig,
16180
16198
  viteDevServer,
16181
16199
  miniflare
16182
16200
  );
16201
+ const configChangedHandler = async (changedFilePath) => {
16202
+ assertIsNotPreview(resolvedPluginConfig);
16203
+ if (resolvedPluginConfig.configPaths.has(changedFilePath) || hasLocalDevVarsFileChanged(resolvedPluginConfig, changedFilePath) || hasAssetsConfigChanged(
16204
+ resolvedPluginConfig,
16205
+ resolvedViteConfig,
16206
+ changedFilePath
16207
+ )) {
16208
+ debuglog2(configId, "Config changed: " + changedFilePath);
16209
+ viteDevServer.watcher.off("change", configChangedHandler);
16210
+ debuglog2(
16211
+ configId,
16212
+ "Restarting dev server and aborting previous setup"
16213
+ );
16214
+ await viteDevServer.restart();
16215
+ }
16216
+ };
16217
+ viteDevServer.watcher.on("change", configChangedHandler);
16183
16218
  let containerBuildId;
16184
16219
  const entryWorkerConfig = getEntryWorkerConfig(resolvedPluginConfig);
16185
16220
  const hasDevContainers = entryWorkerConfig?.containers?.length && entryWorkerConfig.dev.enable_containers;
@@ -16195,14 +16230,23 @@ if (import.meta.hot) {
16195
16230
  containerBuildId
16196
16231
  });
16197
16232
  if (!miniflare) {
16233
+ debuglog2(configId, "Creating new Miniflare instance");
16198
16234
  miniflare = new Miniflare(miniflareDevOptions);
16199
16235
  } else {
16236
+ debuglog2(configId, "Updating the Miniflare instance");
16200
16237
  await miniflare.setOptions(miniflareDevOptions);
16238
+ debuglog2(configId, "Miniflare is ready");
16201
16239
  }
16202
16240
  let preMiddleware;
16203
16241
  if (resolvedPluginConfig.type === "workers") {
16204
16242
  assert12(entryWorkerConfig, `No entry Worker config`);
16205
- await initRunners(resolvedPluginConfig, viteDevServer, miniflare);
16243
+ debuglog2(configId, "Initializing the Vite module runners");
16244
+ await initRunners(
16245
+ resolvedPluginConfig,
16246
+ viteDevServer,
16247
+ miniflare,
16248
+ configId
16249
+ );
16206
16250
  const entryWorkerName = entryWorkerConfig.name;
16207
16251
  if (viteDevServer.httpServer) {
16208
16252
  handleWebSocket(viteDevServer.httpServer, async () => {
@@ -16240,6 +16284,13 @@ if (import.meta.hot) {
16240
16284
  };
16241
16285
  }
16242
16286
  if (hasDevContainers) {
16287
+ viteDevServer.config.logger.info(
16288
+ colors4.dim(
16289
+ colors4.yellow(
16290
+ "\u2237 Building container images for local development...\n"
16291
+ )
16292
+ )
16293
+ );
16243
16294
  containerImageTagsSeen = await prepareContainerImages({
16244
16295
  containersConfig: entryWorkerConfig.containers,
16245
16296
  containerBuildId,
@@ -16247,6 +16298,13 @@ if (import.meta.hot) {
16247
16298
  dockerPath,
16248
16299
  configPath: entryWorkerConfig.configPath
16249
16300
  });
16301
+ viteDevServer.config.logger.info(
16302
+ colors4.dim(
16303
+ colors4.yellow(
16304
+ "\n\u26A1\uFE0F Containers successfully built. To rebuild your containers during development, restart the Vite dev server (r + enter)."
16305
+ )
16306
+ )
16307
+ );
16250
16308
  const dockerPollIntervalId = setInterval(async () => {
16251
16309
  if (containerImageTagsSeen?.size) {
16252
16310
  runningContainerIds = await getContainerIdsByImageTags(
@@ -16316,6 +16374,13 @@ if (import.meta.hot) {
16316
16374
  );
16317
16375
  if (hasDevContainers) {
16318
16376
  const dockerPath = getDockerPath();
16377
+ vitePreviewServer.config.logger.info(
16378
+ colors4.dim(
16379
+ colors4.yellow(
16380
+ "\u2237 Building container images for local preview...\n"
16381
+ )
16382
+ )
16383
+ );
16319
16384
  containerImageTagsSeen = await prepareContainerImages({
16320
16385
  containersConfig: entryWorkerConfig.containers,
16321
16386
  containerBuildId,
@@ -16323,6 +16388,9 @@ if (import.meta.hot) {
16323
16388
  dockerPath,
16324
16389
  configPath: entryWorkerConfig.configPath
16325
16390
  });
16391
+ vitePreviewServer.config.logger.info(
16392
+ colors4.dim(colors4.yellow("\n\u26A1\uFE0F Containers successfully built.\n"))
16393
+ );
16326
16394
  const dockerPollIntervalId = setInterval(async () => {
16327
16395
  if (containerImageTagsSeen?.size) {
16328
16396
  runningContainerIds = await getContainerIdsByImageTags(
@@ -16358,6 +16426,14 @@ if (import.meta.hot) {
16358
16426
  containerImageTagsSeen.clear();
16359
16427
  runningContainerIds = [];
16360
16428
  }
16429
+ debuglog2("buildEnd:", restartingServer ? "restarted" : "disposing");
16430
+ if (!restartingServer) {
16431
+ debuglog2("buildEnd: disposing Miniflare instance");
16432
+ await miniflare?.dispose().catch((error) => {
16433
+ debuglog2("buildEnd: failed to dispose Miniflare instance:", error);
16434
+ });
16435
+ miniflare = void 0;
16436
+ }
16361
16437
  }
16362
16438
  },
16363
16439
  // Plugin to provide a fallback entry file
@@ -1224,9 +1224,12 @@ function exportAll(exports, sourceModule) {
1224
1224
 
1225
1225
  // src/runner-worker/module-runner.ts
1226
1226
  var moduleRunner;
1227
- async function createModuleRunner(env, webSocket) {
1227
+ var oldConfigId;
1228
+ async function createModuleRunner(env, webSocket, configId) {
1228
1229
  if (moduleRunner) {
1229
- throw new Error("Runner already initialized");
1230
+ throw new Error(
1231
+ "Runner already initialized; old configId: " + oldConfigId + ", new configId: " + configId
1232
+ );
1230
1233
  }
1231
1234
  const transport = createWebSocketModuleRunnerTransport({
1232
1235
  createConnection() {
@@ -1234,6 +1237,7 @@ async function createModuleRunner(env, webSocket) {
1234
1237
  return webSocket;
1235
1238
  }
1236
1239
  });
1240
+ oldConfigId = configId;
1237
1241
  moduleRunner = new ModuleRunner(
1238
1242
  {
1239
1243
  sourcemapInterceptor: "prepareStackTrace",
@@ -1369,6 +1373,8 @@ async function getWorkerEntrypointRpcProperty(entrypoint, key) {
1369
1373
  }
1370
1374
  function createWorkerEntrypointWrapper(entrypoint) {
1371
1375
  class Wrapper extends WorkerEntrypoint {
1376
+ /** A unique identifier used for debugging errors when config updates. */
1377
+ configId;
1372
1378
  constructor(ctx, env) {
1373
1379
  super(ctx, env);
1374
1380
  return new Proxy(this, {
@@ -1402,7 +1408,11 @@ function createWorkerEntrypointWrapper(entrypoint) {
1402
1408
  entryPath = viteDevMetadata.entryPath;
1403
1409
  const { 0: client, 1: server } = new WebSocketPair();
1404
1410
  webSocket = client;
1405
- await createModuleRunner(this.env, server);
1411
+ await createModuleRunner(
1412
+ this.env,
1413
+ server,
1414
+ viteDevMetadata.configId
1415
+ );
1406
1416
  } catch (e) {
1407
1417
  return new Response(
1408
1418
  e instanceof Error ? e.message : JSON.stringify(e),
@@ -1563,13 +1573,13 @@ function getViteDevMetadata(request) {
1563
1573
  `Unexpected internal error, vite dev metadata header JSON parsing failed, value = ${viteDevMetadataHeader}`
1564
1574
  );
1565
1575
  }
1566
- const { entryPath: entryPath2 } = parsedViteDevMetadataHeader;
1576
+ const { entryPath: entryPath2, configId } = parsedViteDevMetadataHeader;
1567
1577
  if (entryPath2 === void 0) {
1568
1578
  throw new Error(
1569
1579
  "Unexpected internal error, vite dev metadata header doesn't contain an entryPath value"
1570
1580
  );
1571
1581
  }
1572
- return { entryPath: entryPath2 };
1582
+ return { entryPath: entryPath2, configId };
1573
1583
  }
1574
1584
  export {
1575
1585
  createDurableObjectWrapper,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudflare/vite-plugin",
3
- "version": "1.10.2",
3
+ "version": "1.11.0",
4
4
  "description": "Cloudflare plugin for Vite",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -41,11 +41,11 @@
41
41
  "unenv": "2.0.0-rc.19",
42
42
  "ws": "8.18.0",
43
43
  "@cloudflare/unenv-preset": "2.5.0",
44
- "miniflare": "4.20250726.0",
45
- "wrangler": "4.26.1"
44
+ "miniflare": "4.20250730.0",
45
+ "wrangler": "4.27.0"
46
46
  },
47
47
  "devDependencies": {
48
- "@cloudflare/workers-types": "^4.20250726.0",
48
+ "@cloudflare/workers-types": "^4.20250730.0",
49
49
  "@types/node": "^22.10.1",
50
50
  "@types/ws": "^8.5.13",
51
51
  "magic-string": "^0.30.12",
@@ -61,7 +61,7 @@
61
61
  },
62
62
  "peerDependencies": {
63
63
  "vite": "^6.1.0 || ^7.0.0",
64
- "wrangler": "^4.26.1"
64
+ "wrangler": "^4.27.0"
65
65
  },
66
66
  "publishConfig": {
67
67
  "access": "public"