Skip to content

Commit

Permalink
fix: support node esm (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
yeonjuan committed Feb 8, 2024
1 parent 585f917 commit 9a80a2a
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 34 deletions.
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
"description": "A parser for git diff",
"main": "./build/cjs/index.js",
"module": "./build/mjs/index.js",
"types": "./build/types/index.d.ts",
"types": "./build/cjs/index.d.ts",
"scripts": {
"prepublish": "yarn build",
"build": "rimraf build && tsc -p tsconfig.json && tsc -p tsconfig-esm.json",
"postbuild": "bash fixup.sh",
"build": "rimraf build && tsc -p tsconfig-esm.json && tsc -p tsconfig-cjs.json && bash fixup.sh",
"format": "prettier . --write",
"test": "jest --coverage",
"prebuild": "yarn check:all",
Expand All @@ -18,7 +17,6 @@
},
"exports": {
".": {
"types": "./build/types/index.d.ts",
"import": "./build/mjs/index.js",
"require": "./build/cjs/index.js",
"default": "./build/mjs/index.js"
Expand Down
26 changes: 0 additions & 26 deletions tsconfig-base.json

This file was deleted.

9 changes: 9 additions & 0 deletions tsconfig-cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "CommonJS",
"outDir": "build/cjs",
"declarationDir": "build/cjs",
"target": "es2022"
}
}
4 changes: 3 additions & 1 deletion tsconfig-esm.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "esnext",
"outDir": "build/mjs"
"outDir": "build/mjs",
"declarationDir": "build/mjs",
"target": "ESNext"
}
}
24 changes: 21 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
{
"extends": "./tsconfig-base.json",
"exclude": [
"src/__tests__",
"src/__fixtures__",
"build",
"node_modules",
"demo"
],
"include": ["src/**/*.ts"],
"compilerOptions": {
"module": "CommonJS",
"outDir": "build/cjs",
"moduleResolution": "Node"
"allowSyntheticDefaultImports": true,
"declaration": true,
"declarationMap": true,
"inlineSources": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"sourceMap": true,
"strict": true,
"skipLibCheck": true,
"target": "es2022"
}
}

0 comments on commit 9a80a2a

Please sign in to comment.