Eneris / push-receiver

A library to subscribe to GCM/FCM and receive notifications within a node process.
https://medium.com/@MatthieuLemoine/my-journey-to-bring-web-push-support-to-node-and-electron-ce70eea1c0b0
MIT License
16 stars 15 forks source link

refactor: add named export to client.ts #7

Closed erikian closed 1 year ago

erikian commented 1 year ago

This makes it easier to work with this library in ESM projects.

Currently, when I import this library using...

import PushReceiver from '@eneris/push-receiver'

...with moduleResolution set to Node and module set to ES2015 in the tsconfig.json, my project builds fine, but I get a TypeError: PushReceiver is not a constructor when I try to run it.

The workaround would be setting moduleResolution to Node16 or NodeNext and do something like this, which is not ideal:

import _PushReceiver from '@eneris/push-receiver'
const PushReceiver = _PushReceiver.default

Using the named export I've added, everything just works:

import { PushReceiver } from '@eneris/push-receiver'