Skip to content

Commit 5f8a641

Browse files
Merge pull request #81 from mailtrap/es-module-interop-iisue
Enhance package configuration with module exports and TypeScript settings
2 parents 70796f4 + 1d55982 commit 5f8a641

4 files changed

Lines changed: 15 additions & 3 deletions

File tree

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@
3939
],
4040
"license": "MIT",
4141
"main": "dist/index.js",
42+
"exports": {
43+
".": {
44+
"require": "./dist/index.js",
45+
"types": "./dist/index.d.ts"
46+
},
47+
"./package.json": "./package.json"
48+
},
4249
"peerDependencies": {
4350
"@types/nodemailer": "^6.4.9",
4451
"nodemailer": "^7.0.7"

src/lib/transport.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Transport } from "nodemailer";
2-
import MailMessage from "nodemailer/lib/mailer/mail-message";
32

43
import MailtrapClient from "./MailtrapClient";
54
import normalizeCallback from "./normalizer";
@@ -11,6 +10,7 @@ import {
1110
MailtrapResponse,
1211
MailtrapTransporter,
1312
NormalizeCallback,
13+
MailMessage,
1414
} from "../types/transport";
1515

1616
const { TRANSPORT_SETTINGS } = CONFIG;

src/types/transport.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import NodemailerMail = require("nodemailer/lib/mailer");
22

3-
import { Transporter } from "nodemailer";
3+
import { Transport, Transporter } from "nodemailer";
44
import {
55
SendResponse,
66
SendError,
@@ -51,3 +51,5 @@ export interface MailtrapTransporter extends Transporter<MailtrapResponse> {
5151
mailOptions: MailtrapMailOptions | MailtrapMailOptionsSandbox
5252
): Promise<MailtrapResponse>;
5353
}
54+
55+
export type MailMessage<T> = Parameters<Transport<T>["send"]>[0];

tsconfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
"declaration": true,
88
"outDir": "./dist",
99
"skipLibCheck": true,
10-
"esModuleInterop": true
10+
"esModuleInterop": true,
11+
"allowSyntheticDefaultImports": true,
12+
"declarationMap": true,
13+
"forceConsistentCasingInFileNames": true
1114
},
1215
"include": ["src"],
1316
"exclude": ["node_modules", "examples"]

0 commit comments

Comments
 (0)