Packages

miniflare

4.20260730.0 · 30 Jul 2026MIT57.5M / weekRepositoryHomepagenpmAtom feed

Your version

3.20240403.0

4 Apr 2024Where it was published

3.20250718.3 is the newest release of 3.x.

In short

2 new1 fixed1 internal

Release note

Minor Changes

  • Customisable unsafe direct sockets entrypoints

    Previously, Miniflare provided experimental unsafeDirectHost and unsafeDirectPort options for starting an HTTP server that pointed directly to a specific Worker. This change replaces these options with a single unsafeDirectSockets option that accepts an array of socket objects of the form { host?: string, port?: number, entrypoint?: string, proxy?: boolean }. host defaults to 127.0.0.1, port defaults to 0, entrypoint defaults to default, and proxy defaults to false. This allows you to start HTTP servers for specific entrypoints of specific Workers. proxy controls the Style of the socket.

    Note these sockets set the capnpConnectHost workerd option to "miniflare-unsafe-internal-capnp-connect". external serviceBindings will set their capnpConnectHost option to the same value allowing RPC over multiple Miniflare instances. Refer to #1757 for more information.

  • Support named entrypoints for serviceBindings

    This change allows service bindings to bind to a named export of another Worker using designators of the form { name: string | typeof kCurrentWorker, entrypoint?: string }. Previously, you could only bind to the default entrypoint. With this change, you can bind to any exported entrypoint.

    import { kCurrentWorker, Miniflare } from "miniflare";
    
    const mf = new Miniflare({
        workers: [
            {
                name: "a",
                serviceBindings: {
                    A_RPC_SERVICE: { name: kCurrentWorker, entrypoint: "RpcEntrypoint" },
                    A_NAMED_SERVICE: { name: "a", entrypoint: "namedEntrypoint" },
                    B_NAMED_SERVICE: { name: "b", entrypoint: "anotherNamedEntrypoint" },
                },
                compatibilityFlags: ["rpc"],
                modules: true,
                script: `
                import { WorkerEntrypoint } from "cloudflare:workers";
    
                export class RpcEntrypoint extends WorkerEntrypoint {
                    ping() { return "a:rpc:pong"; }
                }
    
                export const namedEntrypoint = {
                    fetch(request, env, ctx) { return new Response("a:named:pong"); }
                };
    
                ...
                `,
            },
            {
                name: "b",
                modules: true,
                script: `
                export const anotherNamedEntrypoint = {
                    fetch(request, env, ctx) { return new Response("b:named:pong"); }
                };
                `,
            },
        ],
    });

Patch Changes

  • Allow scripts without scriptPaths to import built-in modules

    Previously, if a string script option was specified with modules: true but without a corresponding scriptPath, all imports were forbidden. This change relaxes that restriction to allow imports of built-in node:*, cloudflare:* and workerd:* modules without a scriptPath.

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.