@neuledge/tsconfig

3.2.0 • Public • Published

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

  1. Install the package:
pnpm add -D rimraf typescript @types/node tsc-alias tsup @neuledge/tsconfig
  1. 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__/**"]
}
  1. Create a tsup.config.json file with the following content:
{
  "entry": ["src/index.ts"],
  "format": ["esm", "cjs"],
  "sourcemap": true,
  "shims": true
}
  1. 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"
  }
}
  1. Add the following to your .gitignore:
dist
  1. 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:

  1. Setup new project with TypeScript:
pnpm create next-app
  1. Install the package:
pnpm add -D @neuledge/tsconfig
  1. 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:

  1. Install the package:
pnpm add -D @neuledge/tsconfig
  1. Replace the tsconfig.json file with the following content:
{
  "extends": "@neuledge/tsconfig/nestjs.json",
  "compilerOptions": {
    "baseUrl": "./",
    "rootDir": "./",
    "outDir": "./dist"
  },
  "exclude": ["dist", "node_modules"]
}

Readme

Keywords

none

Package Sidebar

Install

npm i @neuledge/tsconfig

Weekly Downloads

7

Version

3.2.0

License

MIT

Unpacked Size

5.22 kB

Total Files

6

Last publish

Collaborators

  • moshe