Skip to content

Conversation

@bhousel
Copy link
Member

@bhousel bhousel commented Nov 4, 2025

Followup from #126
I added a mock localStorage for environments where localStorage isn't available, and to remove the 'store' dependency.

I've been testing more with Bun and I found that there, the previous code doesn't reliably create the mock. Attempting to access window.localStorage would throw an exception in Node, but that's not necessarily the case in other JS runtimes.

This commit changes the check to use the if (!('localStorage' in globalThis)) syntax, which should work more reliably everywhere.

Followup from #126
I added a mock `localStorage` for environments where localStorage isn't
available, and to remove the 'store' dependency.

I've been testing more with [Bun](https://bun.com/) and I found that there,
this code doesn't reliably create the mock.

I guess in Node trying to access `window.localStorage` would throw an exception,
but that's not necessarily the case in other JS runtimes.

This commit changes it to use the `if (!('localStorage' in globalThis))` syntax,
which should work more reliably everywhere.
@bhousel bhousel merged commit 79a2dc8 into main Nov 4, 2025
1 check passed
@bhousel bhousel deleted the test_localstorage branch November 4, 2025 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants