novuhq / novu

Open-Source Notification Platform. Embeddable Notification Center, E-mail, Push and Slack Integrations.
https://novu.co
Other
34.63k stars 3.55k forks source link

🐛 Bug Report: Angular 17 with SSR #5174

Open sihu opened 7 months ago

sihu commented 7 months ago

📜 Description

The bug occures only when using SSR because of the line in customElements.define('notification-center-web-component', NotificationCenterWebComponent);

SSR does not know a "window"-Instance and thus also does not know customElements. A solution would be to check whether it's an SSR and only register then. It seems also to be only related with Angular 17 apps, it worked in earlier versions where there was not Vite and esbuild in use.

👟 Reproduction steps

  1. follow the instructions on https://docs.novu.co/quickstarts/angular (chosing to use ssr)
  2. open the browser and you will see the error:

👍 Expected behavior

It would be nice that it would work with SSR and Angular 17.

👎 Actual Behavior with Screenshots

Error:

customElements is not defined
    at eval (/Users/sihu/demo4/node_modules/@novu/notification-center-angular/dist/fesm2022/novu-notification-center-angular.mjs:4:1)
    at async instantiateModule (file:///Users/sihu/demo4/node_modules/vite/dist/node/chunks/

Novu version

@novu/notification-center-angular "^0.23.1"

npm version

10.4.0

node version

v20.11.0

📃 Provide any additional context for the Bug.

No response

👀 Have you spent some time to check if this bug has been raised before?

🏢 Have you read the Contributing Guidelines?

Are you willing to submit PR?

None

linear[bot] commented 7 months ago

NV-3487 🐛 Bug Report: Angular 17 with SSR