Skip to content

Commit 29d08ff

Browse files
Merge pull request #110 from ycjcl868/fix/module-format
fix: add cjs format support
2 parents 00c7ab0 + b2b1920 commit 29d08ff

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,26 @@
1919
"mcp"
2020
],
2121
"exports": {
22-
"./*": "./dist/*"
22+
"./*": {
23+
"import": "./dist/esm/*",
24+
"require": "./dist/cjs/*"
25+
}
2326
},
2427
"typesVersions": {
2528
"*": {
2629
"*": [
27-
"./dist/*"
30+
"./dist/esm/*"
2831
]
2932
}
3033
},
3134
"files": [
3235
"dist"
3336
],
3437
"scripts": {
35-
"build": "tsc -p tsconfig.prod.json",
36-
"prepack": "tsc -p tsconfig.prod.json",
38+
"build": "npm run build:esm && npm run build:cjs",
39+
"build:esm": "tsc -p tsconfig.prod.json && echo '{\"type\": \"module\"}' > dist/esm/package.json",
40+
"build:cjs": "tsc -p tsconfig.cjs.json && echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json",
41+
"prepack": "npm run build:esm && npm run build:cjs",
3742
"lint": "eslint src/",
3843
"test": "jest",
3944
"start": "npm run server",

tsconfig.cjs.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"module": "commonjs",
5+
"moduleResolution": "node",
6+
"outDir": "./dist/cjs"
7+
},
8+
"exclude": ["**/*.test.ts"]
9+
}

tsconfig.prod.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"extends": "./tsconfig.json",
3-
"exclude": [
4-
"**/*.test.ts",
5-
]
3+
"compilerOptions": {
4+
"outDir": "./dist/esm"
5+
},
6+
"exclude": ["**/*.test.ts"]
67
}

0 commit comments

Comments
 (0)