@infinitetoken/tsconfig 0.1.4 → 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 +5 -16
  2. package/package.json +1 -1
  3. package/tsup.cjs +10 -50
package/README.md CHANGED
@@ -32,29 +32,18 @@ That's the whole file for a typical Node/kit package — every other compiler op
32
32
 
33
33
  ## tsup config
34
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, not a JSON preset. Use a `tsup.config.cjs` (not `.ts`) so it loads directly with `require()` instead of going through tsup's ESM-bundling loader.
36
-
37
- The common case — one library entry, cjs+esm, with declarations, cleaning `dist/` first:
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.
38
36
 
39
37
  ```js
40
38
  // tsup.config.cjs
41
- module.exports = require('@infinitetoken/tsconfig/tsup').createTsupConfig()
39
+ module.exports = require('@infinitetoken/tsconfig/tsup')()
42
40
  ```
43
41
 
44
- For a package with more than one entry point (e.g. a library plus a CLI bin), compose `entryConfig`/`cliConfig` yourself. Only the first entry should set `clean: true` later entries with `clean: true` would wipe out what the earlier ones just wrote:
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 })`.
45
43
 
46
- ```js
47
- // tsup.config.cjs
48
- const { defineConfig, entryConfig, cliConfig } = require('@infinitetoken/tsconfig/tsup')
49
-
50
- module.exports = defineConfig([
51
- entryConfig('src/index.ts', { clean: true }),
52
- entryConfig('src/shapes.ts'),
53
- cliConfig('src/cli.ts')
54
- ])
55
- ```
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.
56
45
 
57
- `createTsupConfig(entry?, overrides?)` and `entryConfig` both default `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.
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.
58
47
 
59
48
  ## Release
60
49
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infinitetoken/tsconfig",
3
- "version": "0.1.4",
3
+ "version": "0.2.0",
4
4
  "description": "Shared base tsconfig for InfiniteToken TypeScript packages, with an opt-in tsup build config",
5
5
  "keywords": [
6
6
  "config",
package/tsup.cjs CHANGED
@@ -1,61 +1,21 @@
1
1
  const { defineConfig } = require('tsup')
2
2
 
3
- const BASE_DEFAULTS = {
4
- format: ['cjs', 'esm'],
5
- dts: true
6
- }
7
-
8
- const CLI_DEFAULTS = {
9
- format: ['esm'],
10
- banner: { js: '#!/usr/bin/env node' }
11
- }
12
-
13
- /**
14
- * A single tsup build-entry object, for composing a multi-entry array yourself
15
- * (e.g. a library entry plus a separate subpath entry). `clean` is deliberately
16
- * NOT defaulted here — with multiple entries in one array, only the first should
17
- * clean `dist/`, or later entries wipe out earlier ones' output.
18
- *
19
- * @param {string|string[]} entry
20
- * @param {import('tsup').Options} [overrides]
21
- * @returns {import('tsup').Options}
22
- */
23
- function entryConfig(entry, overrides = {}) {
24
- return {
25
- entry: Array.isArray(entry) ? entry : [entry],
26
- ...BASE_DEFAULTS,
27
- ...overrides
28
- }
29
- }
30
-
31
3
  /**
32
- * A CLI bin entry: ESM-only with a Node shebang banner, no declarations.
33
- *
34
- * @param {string|string[]} entry
35
- * @param {import('tsup').Options} [overrides]
36
- * @returns {import('tsup').Options}
37
- */
38
- function cliConfig(entry, overrides = {}) {
39
- return {
40
- entry: Array.isArray(entry) ? entry : [entry],
41
- ...CLI_DEFAULTS,
42
- ...overrides
43
- }
44
- }
45
-
46
- /**
47
- * The common case: one library entry point, cjs+esm, with declarations and a
48
- * clean build. Covers most packages in the fleet outright.
49
- *
50
- * For a package with multiple entries (e.g. a CLI bin alongside the library),
51
- * skip this and compose `entryConfig`/`cliConfig` yourself under `defineConfig([...])`.
4
+ * One library entry point, cjs+esm, with declarations and a clean build.
5
+ * Covers the common case fleet-wide.
52
6
  *
53
7
  * @param {string|string[]} [entry]
54
8
  * @param {import('tsup').Options} [overrides]
55
9
  * @returns {import('tsup').Options}
56
10
  */
57
11
  function createTsupConfig(entry = 'src/index.ts', overrides = {}) {
58
- return defineConfig(entryConfig(entry, { clean: true, ...overrides }))
12
+ return defineConfig({
13
+ entry: Array.isArray(entry) ? entry : [entry],
14
+ format: ['cjs', 'esm'],
15
+ dts: true,
16
+ clean: true,
17
+ ...overrides
18
+ })
59
19
  }
60
20
 
61
- module.exports = { createTsupConfig, entryConfig, cliConfig, defineConfig }
21
+ module.exports = createTsupConfig