@oselvar/sveltekit-add-worker-exports 2.0.0 → 2.1.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.d.ts CHANGED
@@ -38,6 +38,17 @@ export interface AddWorkerExportsOptions {
38
38
  wranglerConfig?: string;
39
39
  /** Port for the dev worker server (default: 8787) */
40
40
  devPort?: number;
41
+ /**
42
+ * Handles each structured log line emitted by the sidecar worker (one entry
43
+ * per `console.log` / `console.error` / etc. call). When omitted, a default
44
+ * handler prints each line to the host's stdout (or stderr for `error`
45
+ * level) prefixed with the sidecar name. Pass `() => {}` to silence.
46
+ */
47
+ structuredLogsHandler?: (log: {
48
+ level: string;
49
+ message: string;
50
+ timestamp: number;
51
+ }) => void;
41
52
  }
42
53
  /**
43
54
  * Returns two Vite plugins: one for build (patches _worker.js) and one for
package/dist/index.js CHANGED
@@ -210,6 +210,7 @@ function devPlugin(options) {
210
210
  delete activeScope.migrations;
211
211
  proxyConfigPath = resolve('.platform-proxy-wrangler.jsonc');
212
212
  await writeFile(proxyConfigPath, JSON.stringify(proxyConfig, null, '\t'));
213
+ const structuredLogsHandler = options.structuredLogsHandler ?? makeDefaultWorkerLogHandler(sidecarName);
213
214
  worker = await unstable_startWorker({
214
215
  config: tempConfigPath,
215
216
  // `testScheduled` mounts a `/__scheduled` endpoint on the sidecar
@@ -217,7 +218,19 @@ function devPlugin(options) {
217
218
  // never auto-fires crons. Curl
218
219
  // `http://localhost:<devPort>/__scheduled?cron=*+*+*+*+*` to
219
220
  // trigger your `scheduled` handler.
220
- dev: { registry: getWranglerRegistryPath(), testScheduled: true },
221
+ //
222
+ // `structuredLogsHandler` (added in wrangler 4.99) routes each
223
+ // worker log line through `onWorkerLog`. Without it, wrangler
224
+ // pipes worker logs through its own Logger which can get
225
+ // swallowed when `unstable_startWorker` is driven
226
+ // programmatically — `console.log` inside the worker
227
+ // disappears. Cast is needed because peer wrangler types may
228
+ // be older.
229
+ dev: {
230
+ registry: getWranglerRegistryPath(),
231
+ testScheduled: true,
232
+ structuredLogsHandler
233
+ },
221
234
  build: {
222
235
  nodejsCompatMode: (parsedConfig) => getNodejsCompatMode(parsedConfig.compatibility_date, parsedConfig.compatibility_flags)
223
236
  }
@@ -237,6 +250,18 @@ function devPlugin(options) {
237
250
  }
238
251
  };
239
252
  }
253
+ /**
254
+ * Default handler for sidecar worker logs. Writes each line to stdout (or
255
+ * stderr for `error` level) tagged with the sidecar name so it's obvious
256
+ * which process produced it.
257
+ */
258
+ function makeDefaultWorkerLogHandler(sidecarName) {
259
+ const prefix = `[${sidecarName}]`;
260
+ return ({ level, message }) => {
261
+ const stream = level === 'error' ? process.stderr : process.stdout;
262
+ stream.write(`${prefix} ${message}\n`);
263
+ };
264
+ }
240
265
  async function exists(path) {
241
266
  try {
242
267
  await access(path);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oselvar/sveltekit-add-worker-exports",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Vite plugin that adds Durable Object and Workflow exports to SvelteKit Cloudflare workers",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -37,15 +37,15 @@
37
37
  },
38
38
  "devDependencies": {
39
39
  "@release-it/conventional-changelog": "^11.0.1",
40
- "@sveltejs/kit": "^2.62.0",
41
- "@types/node": "^25.9.1",
40
+ "@sveltejs/kit": "^2.64.0",
41
+ "@types/node": "^25.9.2",
42
42
  "esbuild": "^0.28.0",
43
- "miniflare": "^4.20260601.0",
43
+ "miniflare": "^4.20260609.0",
44
44
  "release-it": "^20.2.0",
45
45
  "typescript": "^6.0.3",
46
46
  "vite": "^8.0.16",
47
47
  "vitest": "^4.1.8",
48
- "wrangler": "^4.98.0"
48
+ "wrangler": "^4.99.0"
49
49
  },
50
50
  "scripts": {
51
51
  "build": "tsc",