0.1.5 • Published 10 months ago

@cuckoointernet/tsconfig v0.1.5

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

tsconfig

These are base shared tsconfig.jsons 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

  1. 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
  2. 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.

0.1.5

10 months ago

0.1.0

11 months ago

0.1.2

11 months ago

0.1.1

11 months ago

0.1.4

11 months ago

0.1.3

11 months ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago