Skip to content

Commit b9fa4ec

Browse files
committed
build: split esm & cjs configs
1 parent 1af6a02 commit b9fa4ec

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
}
2020
],
2121
"license": "MIT",
22-
"module": "dist/index.es.js",
23-
"main": "dist/index.js",
24-
"types": "dist/index.d.ts",
22+
"module": "dist/esm/index.js",
23+
"main": "dist/cjs/index.js",
24+
"types": "dist/cjs/index.d.ts",
2525
"scripts": {
2626
"prepare": "npm run build",
27-
"build": "tsc",
27+
"build": "tsc && tsc --build tsconfig.esm.json",
2828
"watch": "tsc --watch",
2929
"test": "jest --bail",
3030
"test:watch": "jest --bail --watch",

tsconfig.build.json tsconfig.base.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
"moduleResolution": "Node",
99
"sourceMap": true,
1010
"strict": true,
11-
"target": "es5",
12-
"outDir": "./dist"
11+
"target": "es5"
1312
},
1413
"include": ["src"],
1514
"exclude": ["**/*.test.tsx", "**/*.test.ts", "node_modules", "dist"]

tsconfig.esm.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.base.json",
3+
"compilerOptions": {
4+
"module": "es2020",
5+
"outDir": "./dist/esm"
6+
},
7+
"include": ["src", "index.ts"],
8+
"exclude": ["**/*.test.tsx", "**/*.test.ts"]
9+
}

tsconfig.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
2-
"extends": "./tsconfig.build.json",
2+
"extends": "./tsconfig.base.json",
33
"compilerOptions": {
4-
"module": "commonjs"
4+
"module": "commonjs",
5+
"outDir": "./dist/cjs"
56
},
67
"include": ["src", "index.ts"],
78
"exclude": ["**/*.test.tsx", "**/*.test.ts"]

0 commit comments

Comments
 (0)