Skip to content

Commit 1c01e45

Browse files
committed
Remove Safari workaround (bug has been fixed for over a year)
1 parent 494ee77 commit 1c01e45

File tree

3 files changed

+4
-13
lines changed

3 files changed

+4
-13
lines changed

‎README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
This is a super-simple promise-based keyval store implemented with IndexedDB, originally based on [async-storage by Mozilla](https://github.com/mozilla-b2g/gaia/blob/master/shared/js/async_storage.js).
66

7-
It's small and tree-shakeable. If you only use get/set, the library is ~370 bytes (brotli'd), if you use all methods it's ~650 bytes.
8-
9-
Although this is tiny, it's a little larger than previous versions due to a [massive bug in Safari](https://bugs.webkit.org/show_bug.cgi?id=226547). Hopefully this fix can be removed in the not-too-distant future, when a version of Safari without the bug reaches enough users.
7+
It's small and tree-shakeable. If you only use get/set, the library is ~250 bytes (brotli'd), if you use all methods it's ~534 bytes.
108

119
[localForage](https://github.com/localForage/localForage) offers similar functionality, but supports older browsers with broken/absent IDB implementations. Because of that, it's orders of magnitude bigger (~7k).
1210

‎rollup.config.js

-3
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ export default async function ({ watch }) {
8787
{
8888
input: 'src/index.ts',
8989
plugins: [simpleTS('src'), commonjs(), resolve()],
90-
external: ['safari-14-idb-fix'],
9190
output: [
9291
{
9392
file: 'dist/index.js',
@@ -103,7 +102,6 @@ export default async function ({ watch }) {
103102
{
104103
input: 'src/index.ts',
105104
external: (id) => {
106-
if (id === 'safari-14-idb-fix') return true;
107105
if (id.startsWith('@babel/runtime')) return true;
108106
},
109107
plugins: [simpleTS('src', { noBuild: true }), commonjs(), resolve()],
@@ -118,7 +116,6 @@ export default async function ({ watch }) {
118116
{
119117
input: 'src/index.ts',
120118
external: (id) => {
121-
if (id === 'safari-14-idb-fix') return true;
122119
if (id.startsWith('@babel/runtime')) return true;
123120
},
124121
plugins: [simpleTS('src', { noBuild: true }), commonjs(), resolve()],

‎src/index.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import safariFix from 'safari-14-idb-fix';
2-
31
export function promisifyRequest<T = undefined>(
42
request: IDBRequest<T> | IDBTransaction,
53
): Promise<T> {
@@ -12,11 +10,9 @@ export function promisifyRequest<T = undefined>(
1210
}
1311

1412
export function createStore(dbName: string, storeName: string): UseStore {
15-
const dbp = safariFix().then(() => {
16-
const request = indexedDB.open(dbName);
17-
request.onupgradeneeded = () => request.result.createObjectStore(storeName);
18-
return promisifyRequest(request);
19-
});
13+
const request = indexedDB.open(dbName);
14+
request.onupgradeneeded = () => request.result.createObjectStore(storeName);
15+
const dbp = promisifyRequest(request);
2016

2117
return (txMode, callback) =>
2218
dbp.then((db) =>

0 commit comments

Comments
 (0)