@infinitetoken/tsconfig 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +34 -8
  2. package/package.json +22 -6
  3. package/tsup.cjs +21 -0
package/README.md CHANGED
@@ -1,24 +1,50 @@
1
1
  # @infinitetoken/tsconfig
2
2
 
3
- Shared base `tsconfig.json` for InfiniteToken TypeScript packages. Holds the compiler flags every repo agrees on (strictness, declaration output, consistent casing). Build-mechanics options that vary per repo (`target`, `module`, `moduleResolution`, `rootDir`, `types`, `include`/`exclude`) stay local to each consumer.
3
+ Shared base `tsconfig.json` for InfiniteToken TypeScript packages. Holds the compiler flags every repo agrees on (strictness, declaration output, consistent casing). Also ships an opt-in `tsup` build config factory (`@infinitetoken/tsconfig/tsup`) see [tsup config](#tsup-config) below.
4
+
5
+ ## Presets
6
+
7
+ | Export | Use for |
8
+ | --- | --- |
9
+ | `@infinitetoken/tsconfig` / `@infinitetoken/tsconfig/tsconfig.json` | Universal core — strictness-only flags (`strict`, `declaration`, `noUnusedLocals`, etc). Rarely used directly; every variant below extends it. |
10
+ | `@infinitetoken/tsconfig/node` | Node/kit packages, RN library packages (via `/react-native`, below) — `target: esnext`, `module: preserve`, `moduleResolution: bundler`, `types: [jest, node]` |
11
+ | `@infinitetoken/tsconfig/server` | Express/server apps (unpublished) — `module: commonjs`, `resolveJsonModule: true`, `types: [jest, node]`, and relaxes six strictness flags (`declaration`, `declarationMap`, `noUnusedLocals`, `noUnusedParameters`, `noImplicitReturns`, `noFallthroughCasesInSwitch`) back to `false` |
12
+ | `@infinitetoken/tsconfig/react-native` | React Native packages — extends `/node`, adds `target: ES2020`, `lib: [ES2020, DOM]`, `jsx: react-jsx`, `module: ESNext`, `sourceMap: true`, `allowSyntheticDefaultImports: true`, `resolveJsonModule: true` |
4
13
 
5
14
  ## Usage
6
15
 
7
16
  ```json
8
17
  {
9
- "extends": "@infinitetoken/tsconfig/tsconfig.json",
18
+ "extends": "@infinitetoken/tsconfig/node",
10
19
  "compilerOptions": {
11
- "target": "esnext",
12
- "module": "preserve",
13
- "moduleResolution": "bundler",
14
20
  "rootDir": "./src",
15
- "types": ["jest", "node"]
21
+ "outDir": "./dist"
16
22
  },
17
- "include": ["src/**/*"],
18
- "exclude": ["node_modules", "dist"]
23
+ "include": ["src/**/*"]
19
24
  }
20
25
  ```
21
26
 
27
+ That's the whole file for a typical Node/kit package — every other compiler option now comes from the preset. `rootDir`, `outDir`, `include` (and `exclude`, if you actually need one — see below) are the only things that ever need to be local, because of a real TypeScript limitation: an inherited path-valued `compilerOptions` entry, or an inherited `include`/`exclude`, resolves relative to the file that *declared* it, not the file that extends it. If this package tried to ship `rootDir`/`include`/`exclude` itself, an unoverridden consumer would have TypeScript looking for source files inside `node_modules/@infinitetoken/tsconfig/`. `target`/`module`/`moduleResolution`/`types`/`lib`/etc. don't have this problem — plain `compilerOptions` values merge normally through `extends`, which is exactly why the presets above can carry them for you.
28
+
29
+ **You very likely don't need an `exclude` array at all.** `include: ["src/**/*"]` already scopes the whole program to `src/` — anything living outside it (`node_modules`, `dist`, `.claude/worktrees`, `examples`, etc.) was never going to be included in the first place, so excluding it again is redundant. Only add `exclude` if you have something that genuinely lives *inside* `src/` that you need to keep out of the program.
30
+
31
+ `rootDir` specifically can't be dropped even though `include` looks like it should imply it: without it, `tsc`'s declaration-emit output layout breaks (`TS5011`), so it has to stay explicit whenever you're emitting declarations.
32
+
33
+ ## tsup config
34
+
35
+ Opt-in — only relevant if the package builds with `tsup`. Unlike `tsconfig.json`, a `tsup.config` file is executable code with no path-resolution sharing limitation, so this is a plain factory function — same shape as `@infinitetoken/jest-config`'s presets, a bare function you call, nothing invoked by name off an object. Use a `tsup.config.cjs` (not `.ts`) so it loads directly with `require()` instead of going through tsup's ESM-bundling loader.
36
+
37
+ ```js
38
+ // tsup.config.cjs
39
+ module.exports = require('@infinitetoken/tsconfig/tsup')()
40
+ ```
41
+
42
+ That's the whole file for one library entry point — cjs+esm, with declarations, cleaning `dist/` first. Pass a different entry or override anything tsup accepts: `require('@infinitetoken/tsconfig/tsup')('src/main.ts', { minify: true })`.
43
+
44
+ A package with more than one entry point (a library plus a CLI bin, say) isn't covered by this factory yet — write `tsup.config.cjs` by hand with `tsup`'s own `defineConfig([...])` for that case, same as before this package existed.
45
+
46
+ `createTsupConfig` defaults `dts: true` — a package doing `tsup && tsc --emitDeclarationOnly` as two separate steps (rather than letting tsup's own entry-scoped `dts` option handle it) will end up shipping declarations for every file `tsconfig.json`'s `include` matches, `__tests__` included, not just the real entry point.
47
+
22
48
  ## Release
23
49
 
24
50
  Tag-based, using npm trusted publishing (OIDC, no token required):
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@infinitetoken/tsconfig",
3
- "version": "0.1.3",
4
- "description": "Shared base tsconfig for InfiniteToken TypeScript packages",
3
+ "version": "0.2.0",
4
+ "description": "Shared base tsconfig for InfiniteToken TypeScript packages, with an opt-in tsup build config",
5
5
  "keywords": [
6
6
  "config",
7
7
  "tsconfig",
8
- "typescript"
8
+ "typescript",
9
+ "tsup"
9
10
  ],
10
11
  "homepage": "https://github.com/infinitetoken/tsconfig#readme",
11
12
  "bugs": {
@@ -25,13 +26,15 @@
25
26
  "./package.json": "./package.json",
26
27
  "./react-native": "./react-native.json",
27
28
  "./server": "./server.json",
28
- "./tsconfig.json": "./tsconfig.json"
29
+ "./tsconfig.json": "./tsconfig.json",
30
+ "./tsup": "./tsup.cjs"
29
31
  },
30
32
  "files": [
31
33
  "tsconfig.json",
32
34
  "node.json",
33
35
  "react-native.json",
34
- "server.json"
36
+ "server.json",
37
+ "tsup.cjs"
35
38
  ],
36
39
  "scripts": {
37
40
  "fix": "eslint . --fix",
@@ -40,16 +43,29 @@
40
43
  "release:major": "npm version major && npm run release",
41
44
  "release:minor": "npm version minor && npm run release",
42
45
  "release:patch": "npm version patch && npm run release",
43
- "test": "tsc --noEmit -p test/tsconfig.json",
46
+ "test": "node scripts/verify-presets.cjs && node scripts/verify-tsup.cjs",
44
47
  "verify": "npm run lint && npm test",
45
48
  "preversion": "npm run verify"
46
49
  },
47
50
  "prettier": "@infinitetoken/eslint-config/prettier",
48
51
  "devDependencies": {
49
52
  "@infinitetoken/eslint-config": "^0.1.4",
53
+ "@types/jest": "^30.0.0",
54
+ "@types/node": "^26.4.0",
55
+ "@types/react": "^19.2.18",
50
56
  "eslint": "^9.39.4",
57
+ "react": "^19.2.8",
58
+ "tsup": "^8.5.1",
51
59
  "typescript": "^6.0.3"
52
60
  },
61
+ "peerDependencies": {
62
+ "tsup": "^8.0.0"
63
+ },
64
+ "peerDependenciesMeta": {
65
+ "tsup": {
66
+ "optional": true
67
+ }
68
+ },
53
69
  "publishConfig": {
54
70
  "access": "public"
55
71
  }
package/tsup.cjs ADDED
@@ -0,0 +1,21 @@
1
+ const { defineConfig } = require('tsup')
2
+
3
+ /**
4
+ * One library entry point, cjs+esm, with declarations and a clean build.
5
+ * Covers the common case fleet-wide.
6
+ *
7
+ * @param {string|string[]} [entry]
8
+ * @param {import('tsup').Options} [overrides]
9
+ * @returns {import('tsup').Options}
10
+ */
11
+ function createTsupConfig(entry = 'src/index.ts', overrides = {}) {
12
+ return defineConfig({
13
+ entry: Array.isArray(entry) ? entry : [entry],
14
+ format: ['cjs', 'esm'],
15
+ dts: true,
16
+ clean: true,
17
+ ...overrides
18
+ })
19
+ }
20
+
21
+ module.exports = createTsupConfig