Skip to content

Commit cc4b9fa

Browse files
committed
Finalize changelog for v4
1 parent 9d9af56 commit cc4b9fa

2 files changed

Lines changed: 25 additions & 19 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# 4.0.0 (beta)
1+
# 4.0.0 (2022-07-02)
2+
3+
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.
4+
5+
Details:
26

37
- #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.
48

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

19-
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.
23+
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 :)
2024

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

test/dexie.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,27 @@ import assert from "node:assert";
22
import "../auto/index.mjs";
33
import Dexie from "dexie";
44

5-
const db = new Dexie("MyDatabase");
5+
(async () => {
6+
const db = new Dexie("MyDatabase");
67

7-
db.version(1).stores({
8-
friends: "++id, name, age",
9-
});
8+
db.version(1).stores({
9+
friends: "++id, name, age",
10+
});
1011

11-
await db.friends.add({
12-
name: "Alice",
13-
age: 25,
14-
street: "East 13:th Street",
15-
});
12+
await db.friends.add({
13+
name: "Alice",
14+
age: 25,
15+
street: "East 13:th Street",
16+
});
1617

17-
await db.friends.add({
18-
name: "Bob",
19-
age: 80,
20-
street: "East 13:th Street",
21-
});
18+
await db.friends.add({
19+
name: "Bob",
20+
age: 80,
21+
street: "East 13:th Street",
22+
});
2223

23-
const oldFriends = await db.friends.where("age").above(75).toArray();
24+
const oldFriends = await db.friends.where("age").above(75).toArray();
2425

25-
assert.equal(oldFriends.length, 1);
26-
process.exit(0);
26+
assert.equal(oldFriends.length, 1);
27+
process.exit(0);
28+
})();

0 commit comments

Comments
 (0)