From b41b66b9806841ed0bf273968731149600651d59 Mon Sep 17 00:00:00 2001 From: Andrew Barba Date: Wed, 27 Nov 2024 16:58:34 -0500 Subject: [PATCH] ESM --- package.json | 6 +++++- src/apns.ts | 4 ++-- src/errors.ts | 2 +- src/index.ts | 8 ++++---- src/notifications/notification.ts | 4 ++-- src/notifications/silent-notification.ts | 2 +- test/apns2.test.ts | 2 +- 7 files changed, 16 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 56a320c..d707121 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,13 @@ "version": "12.0.0", "description": "Node client for connecting to Apple's Push Notification Service using the new HTTP/2 protocol with JSON web tokens.", "author": "Andrew Barba ", + "license": "MIT", + "type": "module", "main": "dist/index.js", "types": "dist/index.d.ts", - "license": "MIT", + "exports": { + ".": "./dist/index.js" + }, "engines": { "node": ">=20" }, diff --git a/src/apns.ts b/src/apns.ts index 59c0d7f..cc694a0 100644 --- a/src/apns.ts +++ b/src/apns.ts @@ -1,8 +1,8 @@ import { EventEmitter } from "node:events" import { type PrivateKey, createSigner } from "fast-jwt" import { type Dispatcher, Pool } from "undici" -import { ApnsError, type ApnsResponseError, Errors } from "./errors" -import { type Notification, Priority } from "./notifications/notification" +import { ApnsError, type ApnsResponseError, Errors } from "./errors.js" +import { type Notification, Priority } from "./notifications/notification.js" // APNS version const API_VERSION = 3 diff --git a/src/errors.ts b/src/errors.ts index 2e48076..6238480 100644 --- a/src/errors.ts +++ b/src/errors.ts @@ -1,4 +1,4 @@ -import type { Notification } from "./notifications/notification" +import type { Notification } from "./notifications/notification.js" export enum Errors { badCertificate = "BadCertificate", diff --git a/src/index.ts b/src/index.ts index 03967a2..b402109 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -export * from "./apns" -export * from "./errors" -export * from "./notifications/notification" -export * from "./notifications/silent-notification" +export * from "./apns.js" +export * from "./errors.js" +export * from "./notifications/notification.js" +export * from "./notifications/silent-notification.js" diff --git a/src/notifications/notification.ts b/src/notifications/notification.ts index 91d5fa3..b67dcc9 100644 --- a/src/notifications/notification.ts +++ b/src/notifications/notification.ts @@ -1,5 +1,5 @@ -import { Priority } from "./constants/priority" -import { PushType } from "./constants/push-type" +import { Priority } from "./constants/priority.js" +import { PushType } from "./constants/push-type.js" export { PushType, Priority } diff --git a/src/notifications/silent-notification.ts b/src/notifications/silent-notification.ts index 48c9f65..7450882 100644 --- a/src/notifications/silent-notification.ts +++ b/src/notifications/silent-notification.ts @@ -1,4 +1,4 @@ -import { Notification, type NotificationOptions, Priority, PushType } from "./notification" +import { Notification, type NotificationOptions, Priority, PushType } from "./notification.js" export class SilentNotification extends Notification { constructor( diff --git a/test/apns2.test.ts b/test/apns2.test.ts index c6ee794..8b68de9 100644 --- a/test/apns2.test.ts +++ b/test/apns2.test.ts @@ -1,7 +1,7 @@ import "dotenv/config" import { assert } from "chai" import { beforeAll, describe, it } from "vitest" -import { ApnsClient, Errors, Notification, SilentNotification } from "../src" +import { ApnsClient, Errors, Notification, SilentNotification } from "../src/index.js" describe("apns", () => { const deviceToken = process.env.APNS_PUSH_TOKEN ?? ""