Skip to content

Commit

Permalink
Finalize changelog for v4
Browse files Browse the repository at this point in the history
  • Loading branch information
dumbmatter committed Jul 2, 2022
1 parent 9d9af56 commit cc4b9fa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# 4.0.0 (beta)
# 4.0.0 (2022-07-02)

TLDR: Most users can upgrade without doing any extra work, but you might need to change `require("fake-indexeddb")` to `require("fake-indexeddb").default`. All other ways of importing fake-indexeddb (such as with `import`, or requiring sub-modules like `require("fake-indexeddb/auto")` or `require("fake-indexeddb/lib/FDBKeyRange")`) should continue working like normal.

Details:

- #23 - TypeScript support! As of version 4, fake-indexeddb includes TypeScript types. As you can see in types.d.ts, it's just using TypeScript's built-in IndexedDB types, rather than generating types from the fake-indexeddb code base. The reason I did this is for compatibility with your application code that may already be using TypeScript's IndexedDB types, so if I used something different for fake-indexeddb, it could lead to spurious type errors. In theory this could lead to other errors if there are differences between Typescript's IndexedDB types and fake-indexeddb's API, but currently I'm not aware of any difference.

Expand All @@ -16,7 +20,7 @@
const { indexedDB, IDBKeyRange } = require("fake-indexeddb");
```

For backwards compatibility, the `require("fake-indexeddb/lib/FDBKeyRange")` syntax still is supported, but the new exports of the main module are a breaking change. `indexedDB` is still the default export, but in CommonJS you can't have both default and named exports, so the default export is really just an export named `"default"`. Depending on how you're using it, some tools may be smart enough to figure that out, but some would require you to either switch to a named export or switch to the ES module version.
For backwards compatibility, the `require("fake-indexeddb/lib/FDBKeyRange")` syntax still is supported, but the new exports of the main module are a breaking change. `indexedDB` is still the default export, but in CommonJS you can't have both default and named exports, so the default export is really just an property named `"default"`. This may requrie changing requires of the root module like `require("fake-indexeddb")` to `require("fake-indexeddb").default`. Or switch to ES modules and `import` it :)

- **Breaking change:** Dropped support for versions of Node.js older than Node 12.

Expand Down
36 changes: 19 additions & 17 deletions test/dexie.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,27 @@ import assert from "node:assert";
import "../auto/index.mjs";
import Dexie from "dexie";

const db = new Dexie("MyDatabase");
(async () => {
const db = new Dexie("MyDatabase");

db.version(1).stores({
friends: "++id, name, age",
});
db.version(1).stores({
friends: "++id, name, age",
});

await db.friends.add({
name: "Alice",
age: 25,
street: "East 13:th Street",
});
await db.friends.add({
name: "Alice",
age: 25,
street: "East 13:th Street",
});

await db.friends.add({
name: "Bob",
age: 80,
street: "East 13:th Street",
});
await db.friends.add({
name: "Bob",
age: 80,
street: "East 13:th Street",
});

const oldFriends = await db.friends.where("age").above(75).toArray();
const oldFriends = await db.friends.where("age").above(75).toArray();

assert.equal(oldFriends.length, 1);
process.exit(0);
assert.equal(oldFriends.length, 1);
process.exit(0);
})();

0 comments on commit cc4b9fa

Please sign in to comment.