diff --git a/package.json b/package.json index abc9e5c..056cb51 100644 --- a/package.json +++ b/package.json @@ -19,12 +19,15 @@ "mcp" ], "exports": { - "./*": "./dist/*" + "./*": { + "import": "./dist/esm/*", + "require": "./dist/cjs/*" + } }, "typesVersions": { "*": { "*": [ - "./dist/*" + "./dist/esm/*" ] } }, @@ -32,8 +35,10 @@ "dist" ], "scripts": { - "build": "tsc -p tsconfig.prod.json", - "prepack": "tsc -p tsconfig.prod.json", + "build": "npm run build:esm && npm run build:cjs", + "build:esm": "tsc -p tsconfig.prod.json && echo '{\"type\": \"module\"}' > dist/esm/package.json", + "build:cjs": "tsc -p tsconfig.cjs.json && echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json", + "prepack": "npm run build:esm && npm run build:cjs", "lint": "eslint src/", "test": "jest", "start": "npm run server", diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json new file mode 100644 index 0000000..058a5d9 --- /dev/null +++ b/tsconfig.cjs.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "moduleResolution": "node", + "outDir": "./dist/cjs" + }, + "exclude": ["**/*.test.ts"] +} diff --git a/tsconfig.prod.json b/tsconfig.prod.json index e7fd55c..2c68666 100644 --- a/tsconfig.prod.json +++ b/tsconfig.prod.json @@ -1,6 +1,7 @@ { "extends": "./tsconfig.json", - "exclude": [ - "**/*.test.ts", - ] + "compilerOptions": { + "outDir": "./dist/esm" + }, + "exclude": ["**/*.test.ts"] }