Skip to content

Commit 46b321f

Browse files
authored
Resolve 'tiny-invariant' import error (#557)
There was a dependency "tiny-invariant" that was not being resolved because it has not been added as a dependency to "packages/magicbell-js". The error was not showing up in local development only because it was being resolved in the root node_modules.
1 parent 2512db6 commit 46b321f

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

.changeset/busy-crabs-peel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'magicbell-js': patch
3+
---
4+
5+
Fixes invariant import error

packages/magicbell-js/src/socket.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import invariant from 'tiny-invariant';
2-
31
import { type Notification, Client } from './user-client.js';
42

53
export class Socket {
@@ -165,14 +163,20 @@ export class Socket {
165163
invariant(data?.token, 'Unexpected server response, missing token');
166164

167165
this.#inboxToken = data.token;
168-
return this.#inboxToken;
166+
return data.token;
169167
}
170168
}
171169

172170
function isOK(response: { status: number }) {
173171
return response.status >= 200 && response.status < 300;
174172
}
175173

174+
function invariant(condition: any, message: string): asserts condition {
175+
if (!condition) {
176+
throw new Error(message);
177+
}
178+
}
179+
176180
function getSessionId() {
177181
if (typeof sessionStorage === 'undefined') {
178182
return generateID(64);

0 commit comments

Comments
 (0)