@neuledge/tsconfig
v3.2.0
Published
This package provides a base TypeScript configuration for Neuledge packages.
Downloads
41
Readme
TypeScript Config
This package provides a base TypeScript configuration for Neuledge packages.
Config Files
base.json
: Base TypeScript configuration.nestjs.json
: TypeScript configuration for Nest.js projects.nextjs.json
: TypeScript configuration for Next.js projects.
Initial Setup
- Install the package:
pnpm add -D rimraf typescript @types/node tsc-alias tsup @neuledge/tsconfig
- Create a
tsconfig.json
file with the following content:
{
"extends": "@neuledge/tsconfig/base.json",
"compilerOptions": {
"baseUrl": "src",
"rootDir": "src",
"outDir": "dist"
},
"include": ["src"],
"exclude": ["node_modules", "**/__ignore__/**"]
}
- Create a
tsup.config.json
file with the following content:
{
"entry": ["src/index.ts"],
"format": ["esm", "cjs"],
"sourcemap": true,
"shims": true
}
- Add the following scripts to your
package.json
:
{
"scripts": {
"types": "rimraf --glob dist/*.{d.ts,d.ts.map} dist/**/*.{d.ts,d.ts.map} && tsc --emitDeclarationOnly && tsc-alias",
"build": "rimraf --glob dist/*.{js,js.map,mjs,mjs.map} && tsup"
}
}
- Add the following to your
.gitignore
:
dist
- Add the following to your
.npmignore
:
/*
!/dist/*.js
!/dist/*.js.map
!/dist/*.mjs
!/dist/*.mjs.map
!/dist/**/*.d.ts
Next.js Setup
If you're using a Next.js project, you should follow the instructions below instead of the ones above:
- Setup new project with TypeScript:
pnpm create next-app
- Install the package:
pnpm add -D @neuledge/tsconfig
- Replace the
tsconfig.json
file with the following content:
{
"extends": "@neuledge/tsconfig/nextjs.json",
"compilerOptions": {
"baseUrl": ".",
"rootDir": ".",
"paths": {
"@/*": ["./src/*"]
},
"plugins": [{ "name": "next" }]
},
"include": [
".eslintrc.cjs",
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
"**/*.cjs",
"**/*.mjs",
".next/types/**/*.ts"
],
"exclude": ["node_modules", "**/__ignore__/**"]
}
Nest.js Setup
If you're using a Nest.js project, you should follow the instructions below instead of the ones above:
- Install the package:
pnpm add -D @neuledge/tsconfig
- Replace the
tsconfig.json
file with the following content:
{
"extends": "@neuledge/tsconfig/nestjs.json",
"compilerOptions": {
"baseUrl": "./",
"rootDir": "./",
"outDir": "./dist"
},
"exclude": ["dist", "node_modules"]
}