@cuckoointernet/tsconfig
v0.1.5
Published
These are base shared `tsconfig.json`s from which all other `tsconfig.json`'s inherit from.
Downloads
19
Readme
tsconfig
These are base shared tsconfig.json
s from which all other tsconfig.json
's inherit from.
@cuckoointernet/tsconfig/base.json
├── @cuckoointernet/tsconfig/esm.json
│ └── @cuckoointernet/tsconfig/esm-jsx.json
├── @cuckoointernet/tsconfig/cjs.json
│ └── @cuckoointernet/tsconfig/cjs-jsx.json
└── @cuckoointernet/tsconfig/nextjs.json
Usage
Finding source files
Define include, exclude, compilerOptions.rootDir, and compilerOptions.outDir yourself.
{
"extends": "@cuckoointernet/tsconfig/nextjs.json",
"include": ["next-env.d.ts", "src/**/*.mdx", "src/**/*.ts", "src/**/*.tsx"],
"exclude": ["node_modules", "out"],
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist"
}
}
Managing test files
- If you include test files in your
tsconfig.json
- ✅ TypeScript and VSCode will type check your test files
- ❌ Test files will end up in your
./dist
- If you exclude test files from your
tsconfig.json
- ❌ TypeScript and VSCode will not type check your test files
- ✅ Test files will not end up in your
./dist
To avoid this, use your tsconfig.json
for type checking everything (source and tests) but define separate eg. tsconfig.build.json
files which exclude your tests when building your project.
Example
{
"main": "./dist/cjs/index.js",
"types": "./dist/esm/index.d.ts",
"exports": {
".": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
}
},
"files": ["./dist/**"],
"scripts": {
"build:cjs": "tsc --project tsconfig.cjs.json",
"build:esm": "tsc --project tsconfig.esm.json",
"build": "npm run clean && npm run build:esm && npm run build:cjs",
"clean": "rm -rf dist",
"dev:cjs": "tsc --watch --project tsconfig.cjs.json",
"dev:esm": "tsc --watch --project tsconfig.esm.json",
"dev": "concurrently 'npm:dev:esm' 'npm:dev:cjs'"
}
}
Summary
@cuckoointernet/tsconfig/base.json
The Default/Base/Root config which everything else inherits from, here we define how strict we want our packages to be by default.
@cuckoointernet/tsconfig/esm.json
To be used when building for modern browsers.
@cuckoointernet/tsconfig/esm-jsx.json
To be used when building React projects for modern browsers.
@cuckoointernet/tsconfig/cjs.json
To be used when building for older browsers.
@cuckoointernet/tsconfig/cjs-jsx.json
To be used when building React projects for older browsers.
@cuckoointernet/tsconfig/nextjs.json
To be used with Next.js projects.