github cloudflare/miniflare v1.0.0

latest releases: v2.14.2, v3.20231025.0, v3.20231023.0...
2 years ago

Breaking Changes

  • The first and only argument to the Miniflare constructor is now an object. Scripts should be specified via the script option for strings and the scriptPath option for files:

    // Previous version
    import vm from "vm";
    import { Miniflare } from "miniflare";
    
    const mf1 = new Miniflare(
      new vm.Script(`addEventListener("fetch", (event) => { ... })`),
      { kvPersist: true }
    );
    const mf2 = new Miniflare("script.js", { kvPersist: true });
    // New version
    import { Miniflare } from "miniflare";
    
    const mf1 = new Miniflare({
      script: `addEventListener("fetch", (event) => { ... })`,
      kvPersist: true,
    });
    const mf2 = new Miniflare({
      scriptPath: "script.js",
      kvPersist: true,
    });
  • The Miniflare.getNamespace method has been renamed to Miniflare.getKVNamespace

  • Logged errors will now throw a MiniflareError if no log is provided

  • When using file system KV persistence, key names are now sanitised to replace special characters such as :, /, and \. Reading keys containing these characters may now return null if a value was stored in the previous version.

Features

Fixes

  • Fixed error if options object (containing type and cacheTtl properties) passed as second parameter to KV get method, closes issue #3
  • Fixed error if ArrayBuffer passed as data to crypto.subtle.digest("md5", data)
  • Fixed handling of ignoreMethod option for Cache match and delete
  • Disabled edge caching when using Workers Sites, files are now always loaded from disk
  • Provide Set and WeakSet from Miniflare's realm to sandbox, removing Promise, so (async () => {})() instanceof Promise evaluates to true

Don't miss a new miniflare release

NewReleases is sending notifications on new releases.