@cloudflare/vite-plugin 1.30.1 → 1.30.3

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: "1.30.1",
4
+ version: "1.30.3",
5
5
  description: "Cloudflare plugin for Vite",
6
6
  keywords: [
7
7
  "cloudflare",
@@ -78,4 +78,4 @@ var package_default = {
78
78
 
79
79
  //#endregion
80
80
  export { package_default as default };
81
- //# sourceMappingURL=package-BOguDXuZ.mjs.map
81
+ //# sourceMappingURL=package-BTG2r6Qf.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"package-BOguDXuZ.mjs","names":[],"sources":["../package.json"],"sourcesContent":["{\n\t\"name\": \"@cloudflare/vite-plugin\",\n\t\"version\": \"1.30.1\",\n\t\"description\": \"Cloudflare plugin for Vite\",\n\t\"keywords\": [\n\t\t\"cloudflare\",\n\t\t\"cloudflare-workers\",\n\t\t\"vite\",\n\t\t\"vite-plugin\",\n\t\t\"workers\"\n\t],\n\t\"homepage\": \"https://github.com/cloudflare/workers-sdk/tree/main/packages/vite-plugin-cloudflare#readme\",\n\t\"bugs\": {\n\t\t\"url\": \"https://github.com/cloudflare/workers-sdk/issues\"\n\t},\n\t\"license\": \"MIT\",\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"https://github.com/cloudflare/workers-sdk.git\",\n\t\t\"directory\": \"packages/vite-plugin-cloudflare\"\n\t},\n\t\"files\": [\n\t\t\"dist\"\n\t],\n\t\"type\": \"module\",\n\t\"sideEffects\": false,\n\t\"main\": \"./dist/index.mjs\",\n\t\"types\": \"./dist/index.d.mts\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./dist/index.d.mts\",\n\t\t\t\"import\": \"./dist/index.mjs\"\n\t\t}\n\t},\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t},\n\t\"scripts\": {\n\t\t\"build\": \"tsdown\",\n\t\t\"check:type\": \"tsc --build\",\n\t\t\"dev\": \"tsdown --watch\",\n\t\t\"test\": \"vitest run\",\n\t\t\"test:ci\": \"pnpm test\",\n\t\t\"test:e2e\": \"vitest run -c e2e/vitest.config.ts\",\n\t\t\"test:watch\": \"vitest\"\n\t},\n\t\"dependencies\": {\n\t\t\"@cloudflare/unenv-preset\": \"workspace:*\",\n\t\t\"miniflare\": \"workspace:*\",\n\t\t\"unenv\": \"2.0.0-rc.24\",\n\t\t\"wrangler\": \"workspace:*\",\n\t\t\"ws\": \"catalog:default\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@cloudflare/containers-shared\": \"workspace:*\",\n\t\t\"@cloudflare/mock-npm-registry\": \"workspace:*\",\n\t\t\"@cloudflare/workers-shared\": \"workspace:*\",\n\t\t\"@cloudflare/workers-tsconfig\": \"workspace:*\",\n\t\t\"@cloudflare/workers-types\": \"catalog:default\",\n\t\t\"@cloudflare/workers-utils\": \"workspace:*\",\n\t\t\"@remix-run/node-fetch-server\": \"^0.8.0\",\n\t\t\"@types/node\": \"catalog:default\",\n\t\t\"@types/semver\": \"^7.5.1\",\n\t\t\"@types/ws\": \"^8.5.13\",\n\t\t\"defu\": \"^6.1.4\",\n\t\t\"get-port\": \"^7.1.0\",\n\t\t\"magic-string\": \"^0.30.12\",\n\t\t\"mlly\": \"^1.7.4\",\n\t\t\"picocolors\": \"^1.1.1\",\n\t\t\"semver\": \"^7.7.1\",\n\t\t\"tinyglobby\": \"^0.2.12\",\n\t\t\"tree-kill\": \"catalog:default\",\n\t\t\"tsdown\": \"0.16.3\",\n\t\t\"typescript\": \"catalog:default\",\n\t\t\"vite\": \"catalog:default\",\n\t\t\"vite-legacy\": \"npm:vite@7.1.12\",\n\t\t\"vitest\": \"catalog:default\"\n\t},\n\t\"peerDependencies\": {\n\t\t\"vite\": \"^6.1.0 || ^7.0.0 || ^8.0.0\",\n\t\t\"wrangler\": \"workspace:^\"\n\t},\n\t\"workers-sdk\": {\n\t\t\"prerelease\": true\n\t}\n}\n"],"mappings":";sBAAA;OACS;UACG;cACI;WACH;EACX;EACA;EACA;EACA;EACA;EACA;WACW;OACJ,EACP,OAAO,oDACP;UACU;aACG;EACb,QAAQ;EACR,OAAO;EACP,aAAa;EACb;QACQ,CACR,OACA;OACO;cACO;OACP;QACC;UACE,EACV,KAAK;EACJ,SAAS;EACT,UAAU;EACV,EACD;gBACgB,EAChB,UAAU,UACV;UACU;EACV,SAAS;EACT,cAAc;EACd,OAAO;EACP,QAAQ;EACR,WAAW;EACX,YAAY;EACZ,cAAc;EACd;eACe;EACf,4BAA4B;EAC5B,aAAa;EACb,SAAS;EACT,YAAY;EACZ,MAAM;EACN;kBACkB;EAClB,iCAAiC;EACjC,iCAAiC;EACjC,8BAA8B;EAC9B,gCAAgC;EAChC,6BAA6B;EAC7B,6BAA6B;EAC7B,gCAAgC;EAChC,eAAe;EACf,iBAAiB;EACjB,aAAa;EACb,QAAQ;EACR,YAAY;EACZ,gBAAgB;EAChB,QAAQ;EACR,cAAc;EACd,UAAU;EACV,cAAc;EACd,aAAa;EACb,UAAU;EACV,cAAc;EACd,QAAQ;EACR,eAAe;EACf,UAAU;EACV;mBACmB;EACnB,QAAQ;EACR,YAAY;EACZ;CACD,eAAe,EACd,cAAc,MACd;CACD"}
1
+ {"version":3,"file":"package-BTG2r6Qf.mjs","names":[],"sources":["../package.json"],"sourcesContent":["{\n\t\"name\": \"@cloudflare/vite-plugin\",\n\t\"version\": \"1.30.3\",\n\t\"description\": \"Cloudflare plugin for Vite\",\n\t\"keywords\": [\n\t\t\"cloudflare\",\n\t\t\"cloudflare-workers\",\n\t\t\"vite\",\n\t\t\"vite-plugin\",\n\t\t\"workers\"\n\t],\n\t\"homepage\": \"https://github.com/cloudflare/workers-sdk/tree/main/packages/vite-plugin-cloudflare#readme\",\n\t\"bugs\": {\n\t\t\"url\": \"https://github.com/cloudflare/workers-sdk/issues\"\n\t},\n\t\"license\": \"MIT\",\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"https://github.com/cloudflare/workers-sdk.git\",\n\t\t\"directory\": \"packages/vite-plugin-cloudflare\"\n\t},\n\t\"files\": [\n\t\t\"dist\"\n\t],\n\t\"type\": \"module\",\n\t\"sideEffects\": false,\n\t\"main\": \"./dist/index.mjs\",\n\t\"types\": \"./dist/index.d.mts\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./dist/index.d.mts\",\n\t\t\t\"import\": \"./dist/index.mjs\"\n\t\t}\n\t},\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t},\n\t\"scripts\": {\n\t\t\"build\": \"tsdown\",\n\t\t\"check:type\": \"tsc --build\",\n\t\t\"dev\": \"tsdown --watch\",\n\t\t\"test\": \"vitest run\",\n\t\t\"test:ci\": \"pnpm test\",\n\t\t\"test:e2e\": \"vitest run -c e2e/vitest.config.ts\",\n\t\t\"test:watch\": \"vitest\"\n\t},\n\t\"dependencies\": {\n\t\t\"@cloudflare/unenv-preset\": \"workspace:*\",\n\t\t\"miniflare\": \"workspace:*\",\n\t\t\"unenv\": \"2.0.0-rc.24\",\n\t\t\"wrangler\": \"workspace:*\",\n\t\t\"ws\": \"catalog:default\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@cloudflare/containers-shared\": \"workspace:*\",\n\t\t\"@cloudflare/mock-npm-registry\": \"workspace:*\",\n\t\t\"@cloudflare/workers-shared\": \"workspace:*\",\n\t\t\"@cloudflare/workers-tsconfig\": \"workspace:*\",\n\t\t\"@cloudflare/workers-types\": \"catalog:default\",\n\t\t\"@cloudflare/workers-utils\": \"workspace:*\",\n\t\t\"@remix-run/node-fetch-server\": \"^0.8.0\",\n\t\t\"@types/node\": \"catalog:default\",\n\t\t\"@types/semver\": \"^7.5.1\",\n\t\t\"@types/ws\": \"^8.5.13\",\n\t\t\"defu\": \"^6.1.4\",\n\t\t\"get-port\": \"^7.1.0\",\n\t\t\"magic-string\": \"^0.30.12\",\n\t\t\"mlly\": \"^1.7.4\",\n\t\t\"picocolors\": \"^1.1.1\",\n\t\t\"semver\": \"^7.7.1\",\n\t\t\"tinyglobby\": \"^0.2.12\",\n\t\t\"tree-kill\": \"catalog:default\",\n\t\t\"tsdown\": \"0.16.3\",\n\t\t\"typescript\": \"catalog:default\",\n\t\t\"vite\": \"catalog:default\",\n\t\t\"vite-legacy\": \"npm:vite@7.1.12\",\n\t\t\"vitest\": \"catalog:default\"\n\t},\n\t\"peerDependencies\": {\n\t\t\"vite\": \"^6.1.0 || ^7.0.0 || ^8.0.0\",\n\t\t\"wrangler\": \"workspace:^\"\n\t},\n\t\"workers-sdk\": {\n\t\t\"prerelease\": true\n\t}\n}\n"],"mappings":";sBAAA;OACS;UACG;cACI;WACH;EACX;EACA;EACA;EACA;EACA;EACA;WACW;OACJ,EACP,OAAO,oDACP;UACU;aACG;EACb,QAAQ;EACR,OAAO;EACP,aAAa;EACb;QACQ,CACR,OACA;OACO;cACO;OACP;QACC;UACE,EACV,KAAK;EACJ,SAAS;EACT,UAAU;EACV,EACD;gBACgB,EAChB,UAAU,UACV;UACU;EACV,SAAS;EACT,cAAc;EACd,OAAO;EACP,QAAQ;EACR,WAAW;EACX,YAAY;EACZ,cAAc;EACd;eACe;EACf,4BAA4B;EAC5B,aAAa;EACb,SAAS;EACT,YAAY;EACZ,MAAM;EACN;kBACkB;EAClB,iCAAiC;EACjC,iCAAiC;EACjC,8BAA8B;EAC9B,gCAAgC;EAChC,6BAA6B;EAC7B,6BAA6B;EAC7B,gCAAgC;EAChC,eAAe;EACf,iBAAiB;EACjB,aAAa;EACb,QAAQ;EACR,YAAY;EACZ,gBAAgB;EAChB,QAAQ;EACR,cAAc;EACd,UAAU;EACV,cAAc;EACd,aAAa;EACb,UAAU;EACV,cAAc;EACd,QAAQ;EACR,eAAe;EACf,UAAU;EACV;mBACmB;EACnB,QAAQ;EACR,YAAY;EACZ;CACD,eAAe,EACd,cAAc,MACd;CACD"}
@@ -1,5 +1,5 @@
1
1
  import { DurableObject, WorkerEntrypoint, WorkflowEntrypoint } from "cloudflare:workers";
2
- import { ModuleRunner, ssrModuleExportsKey } from "vite/module-runner";
2
+ import { ModuleRunner, ssrDynamicImportKey, ssrModuleExportsKey } from "vite/module-runner";
3
3
 
4
4
  //#region src/shared.ts
5
5
  const UNKNOWN_HOST = "http://localhost";
@@ -62,6 +62,7 @@ async function maybeCaptureError(options, fn) {
62
62
  const IGNORED_KEYS = ["self"];
63
63
  /** Available methods for `WorkerEntrypoint` class */
64
64
  const WORKER_ENTRYPOINT_KEYS = [
65
+ "connect",
65
66
  "email",
66
67
  "fetch",
67
68
  "queue",
@@ -74,6 +75,7 @@ const WORKER_ENTRYPOINT_KEYS = [
74
75
  /** Available methods for `DurableObject` class */
75
76
  const DURABLE_OBJECT_KEYS = [
76
77
  "alarm",
78
+ "connect",
77
79
  "fetch",
78
80
  "webSocketClose",
79
81
  "webSocketError",
@@ -84,41 +86,43 @@ const WORKFLOW_ENTRYPOINT_KEYS = ["run"];
84
86
 
85
87
  //#endregion
86
88
  //#region src/workers/runner-worker/module-runner.ts
87
- /**
88
- * Custom `ModuleRunner`.
89
- * The `cachedModule` method is overridden to ensure compatibility with the Workers runtime.
90
- */
91
- var CustomModuleRunner = class extends ModuleRunner {
92
- #env;
93
- #environmentName;
94
- constructor(options, evaluator, env, environmentName) {
95
- super(options, evaluator);
96
- this.#env = env;
97
- this.#environmentName = environmentName;
98
- }
99
- async cachedModule(url, importer) {
100
- const moduleId = await this.#env.__VITE_RUNNER_OBJECT__.get("singleton").getFetchedModuleId(this.#environmentName, url, importer);
101
- const module = this.evaluatedModules.getModuleById(moduleId);
102
- if (!module) throw new Error(`Module "${moduleId}" is undefined`);
103
- return module;
104
- }
105
- };
106
89
  /** Module runner instances keyed by environment name */
107
90
  const moduleRunners = /* @__PURE__ */ new Map();
108
91
  /** The parent environment name (set explicitly via IS_PARENT_ENVIRONMENT_HEADER) */
109
92
  let parentEnvironmentName;
93
+ let nextCallbackId = 0;
94
+ const pendingCallbacks = /* @__PURE__ */ new Map();
95
+ const callbackResults = /* @__PURE__ */ new Map();
96
+ /**
97
+ * Executes a callback in the runner Durable Object's IoContext via RPC + shared memory.
98
+ * The callback function is stored in a module-scope map (shared with the DO
99
+ * since both run in the same V8 isolate). Only a numeric ID crosses the RPC
100
+ * boundary.
101
+ */
102
+ async function runInRunnerObject(env, callback) {
103
+ const id = nextCallbackId++;
104
+ pendingCallbacks.set(id, callback);
105
+ try {
106
+ await env.__VITE_RUNNER_OBJECT__.get("singleton").executeCallback(id);
107
+ return callbackResults.get(id);
108
+ } finally {
109
+ pendingCallbacks.delete(id);
110
+ callbackResults.delete(id);
111
+ }
112
+ }
110
113
  /**
111
- * Durable Object that creates the module runner and handles WebSocket communication with the Vite dev server.
114
+ * Durable Object that provides an IoContext for module evaluation and handles
115
+ * WebSocket communication with the Vite dev server.
116
+ *
117
+ * In workerd, a Durable Object has a single shared IoContext across all
118
+ * incoming events, so promises are freely shareable within the DO without
119
+ * cross-context issues.
112
120
  */
113
121
  var __VITE_RUNNER_OBJECT__ = class extends DurableObject {
114
- /** Per-environment state containing WebSocket and concurrent module node promises */
115
- #environments = /* @__PURE__ */ new Map();
122
+ /** Per-environment WebSockets */
123
+ #webSockets = /* @__PURE__ */ new Map();
116
124
  /**
117
- * Handles fetch requests to initialize a module runner for an environment.
118
125
  * Creates a WebSocket pair for communication with the Vite dev server and initializes the ModuleRunner.
119
- * @param request - The incoming fetch request
120
- * @returns Response with WebSocket
121
- * @throws Error if the path is invalid or the module runner is already initialized
122
126
  */
123
127
  async fetch(request) {
124
128
  const { pathname } = new URL(request.url);
@@ -126,16 +130,19 @@ var __VITE_RUNNER_OBJECT__ = class extends DurableObject {
126
130
  const environmentName = request.headers.get(ENVIRONMENT_NAME_HEADER);
127
131
  if (!environmentName) throw new Error(`__VITE_RUNNER_OBJECT__ received request without "${ENVIRONMENT_NAME_HEADER}" header`);
128
132
  if (moduleRunners.has(environmentName)) throw new Error(`Module runner already initialized for environment: "${environmentName}"`);
129
- if (request.headers.get(IS_PARENT_ENVIRONMENT_HEADER) === "true") parentEnvironmentName = environmentName;
133
+ if (request.headers.get(IS_PARENT_ENVIRONMENT_HEADER) === "true") {
134
+ parentEnvironmentName = environmentName;
135
+ globalThis.__VITE_ENVIRONMENT_RUNNER_IMPORT__ = async (envName, id) => {
136
+ const runner = moduleRunners.get(envName);
137
+ if (!runner) throw new Error(`Module runner not initialized for environment: "${envName}". Do you need to set \`childEnvironments: ["${envName}"]\` in the plugin config?`);
138
+ return runInRunnerObject(this.env, () => runner.import(id));
139
+ };
140
+ }
130
141
  const { 0: client, 1: server } = new WebSocketPair();
131
142
  server.accept();
132
- const environmentState = {
133
- webSocket: server,
134
- concurrentModuleNodePromises: /* @__PURE__ */ new Map()
135
- };
136
- this.#environments.set(environmentName, environmentState);
137
- const moduleRunner = await createModuleRunner(this.env, environmentState.webSocket, environmentName);
143
+ const moduleRunner = await createModuleRunner(this.env, server, environmentName);
138
144
  moduleRunners.set(environmentName, moduleRunner);
145
+ this.#webSockets.set(environmentName, server);
139
146
  return new Response(null, {
140
147
  status: 101,
141
148
  webSocket: client
@@ -143,37 +150,22 @@ var __VITE_RUNNER_OBJECT__ = class extends DurableObject {
143
150
  }
144
151
  /**
145
152
  * Sends data to the Vite dev server via the WebSocket for a specific environment.
146
- * @param environmentName - The environment name
147
- * @param data - The data to send as a string
148
- * @throws Error if the WebSocket is not initialized
149
153
  */
150
154
  send(environmentName, data) {
151
- const environmentState = this.#environments.get(environmentName);
152
- if (!environmentState) throw new Error(`Module runner WebSocket not initialized for environment: "${environmentName}"`);
153
- environmentState.webSocket.send(data);
155
+ const webSocket = this.#webSockets.get(environmentName);
156
+ if (!webSocket) throw new Error(`Module runner not initialized for environment: "${environmentName}"`);
157
+ webSocket.send(data);
154
158
  }
155
159
  /**
156
- * Based on the implementation of `cachedModule` from Vite's `ModuleRunner`.
157
- * Running this in the DO enables us to share promises across invocations.
158
- * @param environmentName - The environment name
159
- * @param url - The module URL
160
- * @param importer - The module's importer
161
- * @returns The ID of the fetched module
160
+ * Executes a callback stored in the module-scope `pendingCallbacks` map.
161
+ * The callback runs in the DO's IoContext, ensuring all promises created
162
+ * during execution belong to the DO's shared context.
162
163
  */
163
- async getFetchedModuleId(environmentName, url, importer) {
164
- const moduleRunner = moduleRunners.get(environmentName);
165
- if (!moduleRunner) throw new Error(`Module runner not initialized for environment: "${environmentName}"`);
166
- const environmentState = this.#environments.get(environmentName);
167
- if (!environmentState) throw new Error(`Environment state not found for environment: "${environmentName}"`);
168
- let cached = environmentState.concurrentModuleNodePromises.get(url);
169
- if (!cached) {
170
- const cachedModule = moduleRunner.evaluatedModules.getModuleByUrl(url);
171
- cached = moduleRunner.getModuleInformation(url, importer, cachedModule).finally(() => {
172
- environmentState.concurrentModuleNodePromises.delete(url);
173
- });
174
- environmentState.concurrentModuleNodePromises.set(url, cached);
175
- } else moduleRunner.debug?.("[module runner] using cached module info for", url);
176
- return (await cached).id;
164
+ async executeCallback(id) {
165
+ const callback = pendingCallbacks.get(id);
166
+ if (!callback) throw new Error(`No pending callback with id ${id}`);
167
+ const result = await callback();
168
+ callbackResults.set(id, result);
177
169
  }
178
170
  };
179
171
  /**
@@ -184,7 +176,7 @@ var __VITE_RUNNER_OBJECT__ = class extends DurableObject {
184
176
  * @returns Configured module runner instance
185
177
  */
186
178
  async function createModuleRunner(env, webSocket, environmentName) {
187
- return new CustomModuleRunner({
179
+ return new ModuleRunner({
188
180
  sourcemapInterceptor: "prepareStackTrace",
189
181
  transport: {
190
182
  connect({ onMessage }) {
@@ -214,6 +206,10 @@ async function createModuleRunner(env, webSocket, environmentName) {
214
206
  hmr: true
215
207
  }, {
216
208
  async runInlinedModule(context, transformed, module) {
209
+ const originalDynamicImport = context[ssrDynamicImportKey];
210
+ context[ssrDynamicImportKey] = (dep) => {
211
+ return runInRunnerObject(env, () => originalDynamicImport(dep));
212
+ };
217
213
  const code = `"use strict";async (${Object.keys(context).join(",")})=>{${transformed}}`;
218
214
  await env.__VITE_UNSAFE_EVAL__.eval(code, module.id)(...Object.values(context));
219
215
  Object.seal(context[ssrModuleExportsKey]);
@@ -228,44 +224,26 @@ async function createModuleRunner(env, webSocket, environmentName) {
228
224
  }
229
225
  return import(filepath);
230
226
  }
231
- }, env, environmentName);
227
+ });
232
228
  }
233
229
  /**
234
230
  * Retrieves a specific export from a Worker entry module using the module runner.
235
- * @param workerEntryPath - Path to the Worker entry module
236
- * @param exportName - Name of the export to retrieve
237
- * @returns The requested export value
238
- * @throws Error if the module runner has not been initialized or the module does not define the requested export
239
231
  */
240
232
  async function getWorkerEntryExport(workerEntryPath$1, exportName) {
241
233
  if (!parentEnvironmentName) throw new Error(`Parent environment not initialized`);
242
- const moduleRunner = moduleRunners.get(parentEnvironmentName);
243
- if (!moduleRunner) throw new Error(`Module runner not initialized`);
244
- const module = await moduleRunner.import(VIRTUAL_WORKER_ENTRY);
234
+ const module = await globalThis.__VITE_ENVIRONMENT_RUNNER_IMPORT__(parentEnvironmentName, VIRTUAL_WORKER_ENTRY);
245
235
  const exportValue = typeof module === "object" && module !== null && exportName in module && module[exportName];
246
236
  if (!exportValue) throw new Error(`"${workerEntryPath$1}" does not define a "${exportName}" export.`);
247
237
  return exportValue;
248
238
  }
249
- async function getWorkerEntryExportTypes() {
250
- if (!parentEnvironmentName) throw new Error(`Parent environment not initialized`);
251
- const moduleRunner = moduleRunners.get(parentEnvironmentName);
252
- if (!moduleRunner) throw new Error(`Module runner not initialized`);
253
- const { getExportTypes } = await moduleRunner.import(VIRTUAL_EXPORT_TYPES);
254
- return getExportTypes(await moduleRunner.import(VIRTUAL_WORKER_ENTRY));
255
- }
256
239
  /**
257
- * Imports a module from a specific environment's module runner.
258
- * @param environmentName - The name of the environment to import from
259
- * @param id - The module ID to import
260
- * @returns The imported module
261
- * @throws Error if the environment's module runner has not been initialized
240
+ * Retrieves the export types of the Worker entry module.
262
241
  */
263
- async function importFromEnvironment(environmentName, id) {
264
- const moduleRunner = moduleRunners.get(environmentName);
265
- if (!moduleRunner) throw new Error(`Module runner not initialized for environment: "${environmentName}". Do you need to set \`childEnvironments: ["${environmentName}"]\` in the plugin config?`);
266
- return moduleRunner.import(id);
242
+ async function getWorkerEntryExportTypes() {
243
+ if (!parentEnvironmentName) throw new Error(`Parent environment not initialized`);
244
+ const { getExportTypes } = await globalThis.__VITE_ENVIRONMENT_RUNNER_IMPORT__(parentEnvironmentName, VIRTUAL_EXPORT_TYPES);
245
+ return getExportTypes(await globalThis.__VITE_ENVIRONMENT_RUNNER_IMPORT__(parentEnvironmentName, VIRTUAL_WORKER_ENTRY));
267
246
  }
268
- globalThis.__VITE_ENVIRONMENT_RUNNER_IMPORT__ = importFromEnvironment;
269
247
 
270
248
  //#endregion
271
249
  //#region src/workers/runner-worker/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudflare/vite-plugin",
3
- "version": "1.30.1",
3
+ "version": "1.30.3",
4
4
  "description": "Cloudflare plugin for Vite",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -39,11 +39,11 @@
39
39
  "unenv": "2.0.0-rc.24",
40
40
  "ws": "8.18.0",
41
41
  "@cloudflare/unenv-preset": "2.16.0",
42
- "miniflare": "4.20260317.2",
43
- "wrangler": "4.77.0"
42
+ "miniflare": "4.20260329.0",
43
+ "wrangler": "4.79.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@cloudflare/workers-types": "^4.20260317.1",
46
+ "@cloudflare/workers-types": "^4.20260329.1",
47
47
  "@remix-run/node-fetch-server": "^0.8.0",
48
48
  "@types/node": "^22.10.1",
49
49
  "@types/semver": "^7.5.1",
@@ -61,15 +61,15 @@
61
61
  "vite": "^8.0.0",
62
62
  "vite-legacy": "npm:vite@7.1.12",
63
63
  "vitest": "4.1.0",
64
- "@cloudflare/containers-shared": "0.13.0",
64
+ "@cloudflare/containers-shared": "0.13.1",
65
65
  "@cloudflare/mock-npm-registry": "0.0.0",
66
66
  "@cloudflare/workers-shared": "0.19.1",
67
67
  "@cloudflare/workers-tsconfig": "0.0.0",
68
- "@cloudflare/workers-utils": "0.13.0"
68
+ "@cloudflare/workers-utils": "0.14.0"
69
69
  },
70
70
  "peerDependencies": {
71
71
  "vite": "^6.1.0 || ^7.0.0 || ^8.0.0",
72
- "wrangler": "^4.77.0"
72
+ "wrangler": "^4.79.0"
73
73
  },
74
74
  "workers-sdk": {
75
75
  "prerelease": true