Skip to content

Commit 2debc7f

Browse files
committed
refactor(build): keep runtime entrypoints composable
1 parent fba3f5d commit 2debc7f

File tree

9 files changed

+9
-53
lines changed

9 files changed

+9
-53
lines changed

README.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# @crup/react-timer-hook
22

3-
> Tiny React timer primitives for countdowns, stopwatches, clocks, polling schedules, and many independent timer lifecycles.
3+
> ~1.2 kB timer core for React, with opt-in batteries for schedules, diagnostics, duration math, and many independent timers.
44
55
[![npm alpha](https://img.shields.io/npm/v/%40crup%2Freact-timer-hook/alpha?label=npm%20alpha&color=00b894)](https://www.npmjs.com/package/@crup/react-timer-hook?activeTab=versions)
66
[![npm downloads](https://img.shields.io/npm/dm/%40crup%2Freact-timer-hook?color=0f766e)](https://www.npmjs.com/package/@crup/react-timer-hook)
@@ -17,9 +17,10 @@
1717

1818
Timer hooks look simple until real apps need pause/resume semantics, Strict Mode cleanup, async callbacks, polling that does not overlap, and lists with dozens of independent timers.
1919

20-
`@crup/react-timer-hook` keeps the root import small and lets your app opt into heavier features only when needed:
20+
`@crup/react-timer-hook` starts with a tiny core and lets your app compose the heavier pieces only when it needs them:
2121

2222
- ⏱️ `useTimer()` from the root package for one lifecycle: stopwatch, countdown, clock, or custom flow.
23+
- 🔋 Batteries are optional: schedules, timer groups, duration helpers, and diagnostics live in subpath imports.
2324
- 🧭 `useTimerGroup()` from `/group` for many keyed lifecycles with one shared scheduler.
2425
- 📡 `useScheduledTimer()` from `/schedules` for polling, overdue timing context, and opt-in diagnostics.
2526
- 🧩 `durationParts()` from `/duration` for display math without locale or timezone opinions.
@@ -41,9 +42,6 @@ import { useTimer } from '@crup/react-timer-hook';
4142
import { durationParts } from '@crup/react-timer-hook/duration';
4243
import { useTimerGroup } from '@crup/react-timer-hook/group';
4344
import { useScheduledTimer } from '@crup/react-timer-hook/schedules';
44-
45-
// Or choose convenience over minimum entry size:
46-
import { durationParts, useScheduledTimer, useTimer, useTimerGroup } from '@crup/react-timer-hook/full';
4745
```
4846

4947
## Live recipes
@@ -147,16 +145,15 @@ const timers = useTimerGroup({
147145

148146
## Bundle size
149147

150-
Current build:
148+
The core import stays small. Extra capabilities are opt-in batteries.
151149

152150
| Entry | Raw | Gzip | Brotli |
153151
| --- | ---: | ---: | ---: |
154-
| core | 3.91 kB | 1.34 kB | 1.23 kB |
155-
| full | 15.03 kB | 4.69 kB | 4.18 kB |
156-
| timer group add-on | 9.05 kB | 3.01 kB | 2.74 kB |
157-
| schedules add-on | 6.99 kB | 2.35 kB | 2.16 kB |
158-
| duration helper | 374 B | 262 B | 229 B |
159-
| diagnostics helper | 156 B | 155 B | 139 B |
152+
| core | 3.82 kB | 1.31 kB | 1.21 kB |
153+
| timer group add-on | 8.94 kB | 2.97 kB | 2.70 kB |
154+
| schedules add-on | 6.88 kB | 2.32 kB | 2.13 kB |
155+
| duration helper | 318 B | 224 B | 192 B |
156+
| diagnostics helper | 105 B | 115 B | 99 B |
160157

161158
CI writes a size summary to the GitHub Actions UI and posts bundle-size reports on pull requests.
162159

docs-site/docs/getting-started.mdx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ import { useScheduledTimer } from '@crup/react-timer-hook/schedules';
2020
import type { TimerSnapshot } from '@crup/react-timer-hook';
2121
```
2222

23-
Prefer one convenience import over the smallest entrypoints?
24-
25-
```tsx
26-
import { durationParts, useScheduledTimer, useTimer, useTimerGroup } from '@crup/react-timer-hook/full';
27-
```
28-
2923
## First timer
3024

3125
```tsx

docs-site/static/llms-full.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { consoleTimerDiagnostics } from '@crup/react-timer-hook/diagnostics';
1515
import { durationParts } from '@crup/react-timer-hook/duration';
1616
import { useTimerGroup } from '@crup/react-timer-hook/group';
1717
import { useScheduledTimer } from '@crup/react-timer-hook/schedules';
18-
import { durationParts, useScheduledTimer, useTimer, useTimerGroup } from '@crup/react-timer-hook/full';
1918
```
2019

2120
## useTimer

docs-site/static/llms.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Public exports:
1313
- @crup/react-timer-hook/schedules useScheduledTimer(options): schedule-enabled timer with context.
1414
- @crup/react-timer-hook/duration durationParts(milliseconds): duration display helper.
1515
- @crup/react-timer-hook/diagnostics consoleTimerDiagnostics(options): console debug helper.
16-
- @crup/react-timer-hook/full: convenience import for all public runtime helpers.
1716

1817
Core rules:
1918
- Use timer.now for wall-clock deadlines and clocks.

package.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@
3030
"types": "./dist/diagnostics.d.ts",
3131
"import": "./dist/diagnostics.js",
3232
"require": "./dist/diagnostics.cjs"
33-
},
34-
"./full": {
35-
"types": "./dist/full.d.ts",
36-
"import": "./dist/full.js",
37-
"require": "./dist/full.cjs"
3833
}
3934
},
4035
"files": [

scripts/ai-context.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const context = {
1616
'@crup/react-timer-hook/schedules: useScheduledTimer',
1717
'@crup/react-timer-hook/duration: durationParts',
1818
'@crup/react-timer-hook/diagnostics: consoleTimerDiagnostics',
19-
'@crup/react-timer-hook/full: convenience runtime exports',
2019
],
2120
principles: [
2221
'Use now for wall-clock deadlines and clocks.',

scripts/size-report.mjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ import { brotliCompressSync, gzipSync } from 'node:zlib';
55
const json = process.argv.includes('--json');
66
const entries = [
77
['core', 'dist/index.js'],
8-
['full', 'dist/full.js'],
98
['timer group add-on', 'dist/group.js'],
109
['schedules add-on', 'dist/schedules.js'],
1110
['duration helper', 'dist/duration.js'],
1211
['diagnostics helper', 'dist/diagnostics.js'],
1312
['core CJS', 'dist/index.cjs'],
14-
['full CJS', 'dist/full.cjs'],
1513
['timer group CJS', 'dist/group.cjs'],
1614
['schedules CJS', 'dist/schedules.cjs'],
1715
['duration CJS', 'dist/duration.cjs'],

src/full.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

tsup.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export default defineConfig({
77
duration: 'src/duration.ts',
88
schedules: 'src/schedules.ts',
99
diagnostics: 'src/diagnostics.ts',
10-
full: 'src/full.ts',
1110
},
1211
format: ['esm', 'cjs'],
1312
dts: true,

0 commit comments

Comments
 (0)