Skip to content

Commit

Permalink
Add CustomEvent polyfill for Node 18
Browse files Browse the repository at this point in the history
  • Loading branch information
davidje13 committed Sep 5, 2024
1 parent e197db3 commit 2800384
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@ import { appFactory, type App } from './app';
import { type ConfigT, config } from './config';
import { logError, logInfo } from './log';

// Temporary polyfill for Node 18 support
if (!(global as any).CustomEvent) {
logInfo('Polyfilling CustomEvent');
(global as any).CustomEvent = class CustomEvent extends Event {
public readonly detail: unknown;

constructor(
type: string,
options: {
bubbles?: boolean;
cancelable?: boolean;
composed?: boolean;
detail?: unknown;
},
) {
super(type, options);
this.detail = options?.detail ?? null;
}
};
}

// This file exists mainly to enable hot module replacement.
// app.ts is the main entry point for the application.
// (changes to index.ts will not trigger HMR)
Expand Down

0 comments on commit 2800384

Please sign in to comment.