diff --git a/package.json b/package.json index c9a0f1e..31ab382 100644 --- a/package.json +++ b/package.json @@ -3,13 +3,14 @@ "version": "1.1.0", "description": "TypeScript library for easy socket upgrades (STARTTLS).", "type": "module", - "main": "lib/index.js", - "types": "lib/index.d.ts", - "module": "lib/index.js", + "main": "./lib/cjs/index.js", + "module": "./lib/esm/index.js", + "types": "./lib/esm/index.d.ts", "exports": { ".": { - "import": "./lib/index.js", - "types": "./lib/index.d.ts" + "require": "./lib/cjs/index.js", + "import": "./lib/esm/index.js", + "types": "./lib/esm/index.d.ts" } }, "keywords": [ @@ -23,7 +24,9 @@ ], "scripts": { "prepare": "npm run build", - "build": "tsc", + "build": "npm run build:cjs && npm run build:esm", + "build:esm": "tsc --module esnext --outDir lib/esm && echo '{\"type\": \"module\"}' > lib/esm/package.json", + "build:cjs": "tsc --module commonjs --outDir lib/cjs && echo '{\"type\": \"commonjs\"}' > lib/cjs/package.json", "test": "vitest", "coverage": "vitest --coverage --run" }, diff --git a/tsconfig.json b/tsconfig.json index d5f898c..5632cea 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,12 +1,14 @@ { "compilerOptions": { - "target": "ESNext", - "module": "NodeNext", + "target": "ES2020", + "module": "CommonJS", + "moduleResolution": "node", + "esModuleInterop": false, "declaration": true, "outDir": "./lib", - "lib": ["ESNext"], + "lib": ["ES2020", "DOM"], "strict": true }, "include": ["src"], - "exclude": ["node_modules", "**/__tests__/*", "src/run.ts"] + "exclude": ["node_modules", "**/__tests__/*"] }