0.0.11 • Published 11 days ago

@cuckoointernet/tsconfig v0.0.11

Weekly downloads
-
License
MIT
Repository
-
Last release
11 days 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.0.11

11 days ago

0.0.10

2 months ago

0.0.9

8 months ago

0.0.8

9 months ago

0.0.7

9 months ago

0.0.6

10 months ago

0.0.5

10 months ago

0.0.4

10 months ago

0.0.3

11 months ago

0.0.2

11 months ago