Skip to content

Commit 9a80a2a

Browse files
authored
fix: support node esm (#30)
1 parent 585f917 commit 9a80a2a

File tree

5 files changed

+35
-34
lines changed

5 files changed

+35
-34
lines changed

package.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
"description": "A parser for git diff",
55
"main": "./build/cjs/index.js",
66
"module": "./build/mjs/index.js",
7-
"types": "./build/types/index.d.ts",
7+
"types": "./build/cjs/index.d.ts",
88
"scripts": {
99
"prepublish": "yarn build",
10-
"build": "rimraf build && tsc -p tsconfig.json && tsc -p tsconfig-esm.json",
11-
"postbuild": "bash fixup.sh",
10+
"build": "rimraf build && tsc -p tsconfig-esm.json && tsc -p tsconfig-cjs.json && bash fixup.sh",
1211
"format": "prettier . --write",
1312
"test": "jest --coverage",
1413
"prebuild": "yarn check:all",
@@ -18,7 +17,6 @@
1817
},
1918
"exports": {
2019
".": {
21-
"types": "./build/types/index.d.ts",
2220
"import": "./build/mjs/index.js",
2321
"require": "./build/cjs/index.js",
2422
"default": "./build/mjs/index.js"

tsconfig-base.json

-26
This file was deleted.

tsconfig-cjs.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"module": "CommonJS",
5+
"outDir": "build/cjs",
6+
"declarationDir": "build/cjs",
7+
"target": "es2022"
8+
}
9+
}

tsconfig-esm.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"extends": "./tsconfig.json",
33
"compilerOptions": {
44
"module": "esnext",
5-
"outDir": "build/mjs"
5+
"outDir": "build/mjs",
6+
"declarationDir": "build/mjs",
7+
"target": "ESNext"
68
}
79
}

tsconfig.json

+21-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
11
{
2-
"extends": "./tsconfig-base.json",
2+
"exclude": [
3+
"src/__tests__",
4+
"src/__fixtures__",
5+
"build",
6+
"node_modules",
7+
"demo"
8+
],
9+
"include": ["src/**/*.ts"],
310
"compilerOptions": {
411
"module": "CommonJS",
5-
"outDir": "build/cjs",
6-
"moduleResolution": "Node"
12+
"allowSyntheticDefaultImports": true,
13+
"declaration": true,
14+
"declarationMap": true,
15+
"inlineSources": true,
16+
"esModuleInterop": true,
17+
"forceConsistentCasingInFileNames": true,
18+
"isolatedModules": true,
19+
"moduleResolution": "node",
20+
"resolveJsonModule": true,
21+
"sourceMap": true,
22+
"strict": true,
23+
"skipLibCheck": true,
24+
"target": "es2022"
725
}
826
}

0 commit comments

Comments
 (0)