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.
- package/README.md +154 -19
- package/dist/_chunks/common-base-runner.d.mts +52 -14
- package/dist/_chunks/common-base-runner.mjs +123 -32
- package/dist/_chunks/common-process-data.mjs +13 -0
- package/dist/_chunks/common-worker-utils.mjs +464 -73
- package/dist/_chunks/deno-process-runner.mjs +2 -6
- package/dist/_chunks/lexer.mjs +2 -0
- package/dist/_chunks/libs/cjs-module-lexer.mjs +6 -1
- package/dist/_chunks/miniflare-runner.d.mts +21 -12
- package/dist/_chunks/miniflare-runner.mjs +266 -96
- package/dist/_chunks/node-worker-runner.mjs +1 -2
- package/dist/_chunks/server.mjs +20 -5
- package/dist/_chunks/types.d.mts +36 -0
- package/dist/_chunks/virtual-loader.mjs +303 -29
- package/dist/index.d.mts +17 -4
- package/dist/runners/bun-process/runner.mjs +4 -8
- package/dist/runners/bun-process/worker.mjs +8 -8
- package/dist/runners/deno-process/worker.mjs +8 -8
- package/dist/runners/node-process/runner.mjs +2 -6
- package/dist/runners/node-process/worker.mjs +8 -8
- package/dist/runners/node-worker/worker.mjs +6 -7
- package/dist/runners/self/runner.d.mts +2 -1
- package/dist/runners/self/runner.mjs +8 -0
- package/package.json +11 -11
- package/dist/_chunks/common-host-env.mjs +0 -11
|
@@ -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`
|
|
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`
|
|
75
|
-
* (else cwd), shared with
|
|
76
|
-
*
|
|
77
|
-
* read. `miniflareOptions`
|
|
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
|
|
112
|
-
* (see {@link
|
|
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
|
-
|
|
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>;
|