Skip to content

Commit

Permalink
improve tsconfig patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Aug 3, 2023
1 parent 8c371a3 commit acc304c
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 31 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.*.swp
/deleteme
/old
/*.tap
/dist
Expand Down
6 changes: 4 additions & 2 deletions fixup.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
#!/usr/bin/env bash

cat >dist/cjs/package.json <<!EOF
cat >dist-tmp/cjs/package.json <<!EOF
{
"version": "$(node -p 'require("./package.json").version')",
"type": "commonjs"
}
!EOF

cat >dist/mjs/package.json <<!EOF
cat >dist-tmp/mjs/package.json <<!EOF
{
"version": "$(node -p 'require("./package.json").version')",
"type": "module"
}
!EOF

sync-content dist-tmp dist
chmod 0755 dist/cjs/src/bin.js
rm -rf dist-tmp
77 changes: 77 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
"preversion": "npm test",
"postversion": "npm publish",
"prepublishOnly": "git push origin --follow-tags",
"preprepare": "rm -rf dist",
"prepare": "tsc -p tsconfig.json && tsc -p tsconfig-esm.json && bash fixup.sh",
"prepare": "tsc -p tsconfig/cjs.json && tsc -p tsconfig/esm.json && bash fixup.sh",
"pretest": "npm run prepare",
"presnap": "npm run prepare",
"test": "c8 tap",
Expand Down Expand Up @@ -73,6 +72,7 @@
"mkdirp": "^2.1.4",
"prettier": "^2.8.3",
"rimraf": "^4.1.3",
"sync-content": "^1.0.2",
"tap": "^16.3.4",
"ts-node": "^10.9.1",
"typedoc": "^0.23.24",
Expand Down
16 changes: 0 additions & 16 deletions tsconfig-base.json

This file was deleted.

8 changes: 0 additions & 8 deletions tsconfig-esm.json

This file was deleted.

14 changes: 11 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
{
"extends": "./tsconfig-base.json",
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"declaration": true,
"declarationMap": true,
"inlineSources": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"module": "commonjs",
"outDir": "dist/cjs",
"moduleResolution": "Node"
"sourceMap": true,
"strict": true,
"target": "es2022",
"outDir": "deleteme"
}
}
5 changes: 5 additions & 0 deletions tsconfig/build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "../tsconfig.json",
"exclude": ["../test", "../tap-snapshots"],
"include": ["../src/**/*.ts"]
}
6 changes: 6 additions & 0 deletions tsconfig/cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./build.json",
"compilerOptions": {
"outDir": "../dist-tmp/cjs"
}
}
8 changes: 8 additions & 0 deletions tsconfig/esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./build.json",
"exclude": ["../test", "../tap-snapshots", "../src/bin.ts"],
"compilerOptions": {
"module": "esnext",
"outDir": "../dist-tmp/mjs"
}
}

0 comments on commit acc304c

Please sign in to comment.