Skip to content

Commit a2c6a9b

Browse files
committed
feat(node): update eventsource dep from v2 to v4
1 parent 39645d6 commit a2c6a9b

File tree

6 files changed

+36
-14
lines changed

6 files changed

+36
-14
lines changed

examples/todo-server-tests/tsconfig.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,19 @@
77
"declaration": true,
88
"noEmitOnError": true,
99
"verbatimModuleSyntax": false,
10+
// TODO: Remove DOM here!! The Node SDK should not need DOM types.
11+
"lib": ["ESNext", "DOM"],
1012
"types": ["node"],
1113
"paths": {
12-
"featurehub-javascript-node-sdk": ["../../packages/node/src"]
14+
"featurehub-javascript-client-sdk": ["../../packages/js/src"],
15+
"featurehub-javascript-node-sdk": ["../../packages/node/src"],
16+
/*
17+
This is a workaround to bypass Typescript checking of the cross-sha256 package.
18+
The author of the package improperly exported the source .ts file alongside the js file
19+
*/
20+
"cross-sha256": [
21+
"../../node_modules/.pnpm/[email protected]/node_modules/cross-sha256/index.d.ts"
22+
]
1323
}
1424
},
1525
"include": ["src/**/*", "features/**/*"]

packages/js/src/featurehub_eventsource.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ export declare class EventSource {
1717
readonly readyState: number;
1818
readonly withCredentials: boolean;
1919

20-
onopen: (evt: MessageEvent) => any;
21-
onmessage: (evt: MessageEvent) => any;
22-
onerror: (evt: MessageEvent) => any;
20+
onopen?: ((evt: Event) => void) | null;
21+
onmessage?: ((evt: MessageEvent) => void) | null;
22+
onerror?: ((evt: Event) => void) | null;
2323

2424
constructor(url: string, eventSourceInitDict?: EventSource.EventSourceInitDict);
2525

packages/node/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"vite": "7.1.10"
5959
},
6060
"dependencies": {
61-
"eventsource": "^2.0.2",
61+
"eventsource": "^4.0.0",
6262
"featurehub-javascript-client-sdk": "workspace:*"
6363
},
6464
"engines": {

packages/node/src/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable @typescript-eslint/no-require-imports */
1+
import { EventSource } from "eventsource";
22
import {
33
EdgeFeatureHubConfig,
44
type FeatureEnvironmentCollection,
@@ -20,12 +20,10 @@ import {
2020
} from "featurehub-javascript-client-sdk";
2121
import { URL } from "url";
2222

23-
const ES = require("eventsource");
24-
2523
export * from "featurehub-javascript-client-sdk";
2624

2725
FeatureHubEventSourceClient.eventSourceProvider = (url, dict) => {
28-
return new ES(url, dict);
26+
return new EventSource(url, dict);
2927
};
3028

3129
interface PromiseLikeData {

packages/node/tsconfig.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
"paths": {
1414
"featurehub-javascript-client-sdk": ["../js/src"],
1515
/*
16-
This is a workaround to bypass Typescript checking of the cross-sha256 package.
17-
The author of the package improperly exported the source .ts file alongside the js file
18-
*/
16+
This is a workaround to bypass Typescript checking of the cross-sha256 package.
17+
The author of the package improperly exported the source .ts file alongside the js file
18+
*/
1919
"cross-sha256": [
2020
"../../node_modules/.pnpm/[email protected]/node_modules/cross-sha256/index.d.ts"
2121
]

pnpm-lock.yaml

Lines changed: 16 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)