env-runner 0.2.3 → 0.3.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.
@@ -1,4 +1,4 @@
1
- import { WorkerHooks } from "./types.mjs";
1
+ import { ResolvedVirtualModule, WorkerHooks } from "./types.mjs";
2
2
  import { BaseEnvRunner, EnvRunnerData } from "./common-base-runner.mjs";
3
3
  import { RuntimeDep } from "./common-runtime-deps.mjs";
4
4
  import { IncomingMessage } from "node:http";
@@ -19,11 +19,13 @@ export interface TransformResult {
19
19
  export interface MiniflareExportInfo {
20
20
  type?: "DurableObject" | "WorkerEntrypoint" | "class";
21
21
  }
22
- /** The `miniflare` package namespace, as imported by the app. */
22
+ /** The `miniflare` package namespace (v4 or v5), as imported by the app. */
23
23
  export interface MiniflareModule {
24
24
  Miniflare: new (options: any) => any;
25
- /** Newest date the installed `workerd` supports, clamped to today. */
25
+ /** Newest date the installed `workerd` supports, clamped to today (v4 only). */
26
26
  supportedCompatibilityDate?: string;
27
+ /** Converts v4 options, which the runner builds, to the v5 format (v5 only). */
28
+ convertV4MiniflareOptions?: (options: any) => any;
27
29
  [key: string]: unknown;
28
30
  }
29
31
  export interface MiniflareEnvRunnerOptions {
@@ -51,9 +53,15 @@ export interface MiniflareEnvRunnerOptions {
51
53
  transformRequest?: (id: string) => Promise<TransformResult | null | undefined>;
52
54
  /**
53
55
  * Named exports (Durable Objects, WorkerEntrypoints) to bind and re-export.
54
- * `true` detects `export class`; a record merges with detected ones.
56
+ * Default (or `true`): detect `export class` in the entry and auto-bind them;
57
+ * a record merges with detected ones; `false` disables it.
58
+ * A module specifier (absolute path or `data.virtual` key; relative paths
59
+ * resolve from the entry's directory) is re-exported with `export *` instead:
60
+ * nothing is detected or auto-bound (configure bindings with `wrangler` or
61
+ * `miniflareOptions`) and the entry's own classes are not re-exported.
62
+ * Exports load at startup, so changes need a new runner (not `reloadModule()`).
55
63
  */
56
- exports?: Record<string, MiniflareExportInfo> | boolean;
64
+ exports?: Record<string, MiniflareExportInfo> | boolean | string;
57
65
  /** Reuse the Miniflare instance across runner swaps; only `dispose()` destroys it. */
58
66
  persistent?: boolean;
59
67
  /** Wrap the user's `fetch` in a try/catch that returns structured JSON error responses. Default: `true`. */
@@ -71,10 +79,11 @@ export interface MiniflareEnvRunnerOptions {
71
79
  *
72
80
  * Options a single dev worker can't run (`assets`, services, queue consumers,
73
81
  * workflows, tails, other-script Durable Objects) are dropped with a warning.
74
- * `defaultPersistRoot` defaults to `.wrangler/state/v3` next to the config
75
- * (else cwd), shared with `wrangler dev`. The `wrangler` package gives full
76
- * fidelity (and may run its npm update check); without it only plain JSON is
77
- * read. `miniflareOptions` always win.
82
+ * `defaultPersistRoot` (v5: `resourcePersistencePath`) defaults to
83
+ * `.wrangler/state/v3` next to the config (else cwd), shared with
84
+ * `wrangler dev`. The `wrangler` package gives full fidelity (and may run its
85
+ * npm update check); without it only plain JSON is read. `miniflareOptions`
86
+ * always win.
78
87
  */
79
88
  wrangler?: boolean | string | WranglerInlineConfig;
80
89
  /**
@@ -108,10 +117,10 @@ export declare class MiniflareEnvRunner extends BaseEnvRunner {
108
117
  /** Hot-reload the entry without recreating the Miniflare instance. */
109
118
  reloadModule(timeout?: number): Promise<void>;
110
119
  /**
111
- * Host-side only: the fallback service serves a live map, so bumping versions
112
- * (see {@link rewriteVirtualImports}) is enough.
120
+ * Host-side only: the fallback service serves a live map, so changing it and
121
+ * bumping versions (see {@link applyVirtualVersions}) is enough.
113
122
  */
114
- invalidateModule(specifier: string, _timeout?: number): Promise<void>;
123
+ protected _applyVirtualUpdates(changes: Record<string, ResolvedVirtualModule | null>): Promise<void>;
115
124
  protected _hasRuntime(): boolean;
116
125
  protected _runtimeType(): string;
117
126
  protected _closeRuntime(): Promise<void>;