Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/quiet-pandas-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"joyful": patch
---

Generate type declarations with `tsc` instead of tsup's bundled `rollup-plugin-dts`, which is incompatible with TypeScript 7. The exported type surface is unchanged; the package no longer ships the unreferenced `dist/*.d.mts` duplicates, since `exports` resolves types to `dist/index.d.ts` for both the import and require conditions.
36 changes: 9 additions & 27 deletions BENCHMARKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,15 @@ Run the full performance report with:
bun run perf
```

The command builds the published package output once, then reports runtime
benchmarks, cold startup timings, package artifact sizes, and a consumer bundle
size estimate. CI runs this in report-only mode so performance changes are
visible on pull requests without blocking merges yet.
The command builds the published package output once, then reports runtime benchmarks, cold startup timings, package artifact sizes, and a consumer bundle size estimate. CI runs this in report-only mode so performance changes are visible on pull requests without blocking merges yet.

Each run also writes `BENCHMARK_REPORT.md` with the latest local results and
interpretation notes. The report is overwritten on every run and is
machine-dependent.
Each run also writes `BENCHMARK_REPORT.md` with the latest local results and interpretation notes. The report is overwritten on every run and is machine-dependent.

## What We Measure

### Runtime

`benchmarks/joyful.bench.ts` benchmarks the published ESM and CJS outputs from
`dist`, not the TypeScript source. This catches regressions in the code users
actually install.
`benchmarks/joyful.bench.ts` benchmarks the published ESM and CJS outputs from `dist`, not the TypeScript source. This catches regressions in the code users actually install.

The covered cases are:

Expand All @@ -47,34 +40,26 @@ This matters because the package eagerly loads the word lists when imported.
`scripts/size.ts` reports:

- raw and gzip sizes for each `dist` file
- raw and gzip size for a temporary browser consumer bundle that imports
`joyful` and calls it once
- raw and gzip size for a temporary browser consumer bundle that imports `joyful` and calls it once
- `npm pack --dry-run --json` packed and unpacked package size

The consumer bundle is created in the OS temp directory and removed after the
report.
The consumer bundle is created in the OS temp directory and removed after the report.

## How To Read Results

Compare pull request output against recent `main` output from the same CI
environment. Local numbers are useful for investigation, but they are expected
to vary by CPU, thermal state, Bun version, and background load.
Compare pull request output against recent `main` output from the same CI environment. Local numbers are useful for investigation, but they are expected to vary by CPU, thermal state, Bun version, and background load.

Important signals:

- Default unbounded generation should stay in the nanosecond range.
- High `segments` cases show scaling cost from repeated uniqueness checks.
- Bounded `maxLength` cases are the current hot path and are much slower than
unbounded generation.
- Bounded `maxLength` cases are the current hot path and are much slower than unbounded generation.
- Startup/import timing reflects eager loading of all word-list data.
- Consumer bundle gzip size should track the real cost paid by browser users.

## Current Baseline Shape

On the initial local baseline, default generation was fast, high segment counts
scaled predictably, and bounded generation was the clear optimization target.
The consumer bundle was roughly the same size as the bundled word-list chunk
because a normal consumer import needs the full word data.
On the initial local baseline, default generation was fast, high segment counts scaled predictably, and bounded generation was the clear optimization target. The consumer bundle was roughly the same size as the bundled word-list chunk because a normal consumer import needs the full word data.

Good next optimization targets:

Expand All @@ -85,7 +70,4 @@ Good next optimization targets:

## When To Add Gates

Keep the report-only workflow until there are several stable CI runs on `main`.
After that, add conservative thresholds first for package size and consumer
bundle gzip size. Runtime thresholds should come later because microbenchmark
timings are noisier.
Keep the report-only workflow until there are several stable CI runs on `main`. After that, add conservative thresholds first for package size and consumer bundle gzip size. Runtime thresholds should come later because microbenchmark timings are noisier.
38 changes: 17 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ Pattern rules:

## Custom Word Lists

Use `wordLists` to add named word pools that can be selected by `pattern`.
Use `omit` to exclude exact words from both built-in and custom lists.
Use `wordLists` to add named word pools that can be selected by `pattern`. Use `omit` to exclude exact words from both built-in and custom lists.

```ts
joyful({
Expand All @@ -89,8 +88,7 @@ joyful({
}); // "apple-linen"
```

Custom category names are additive. If a custom list uses a built-in category
name, such as `animal`, it replaces that built-in category for the current call.
Custom category names are additive. If a custom list uses a built-in category name, such as `animal`, it replaces that built-in category for the current call.

## CLI

Expand Down Expand Up @@ -167,25 +165,25 @@ Permutation counts include only unique names that can be generated without repea

Returns a generated name as a `string`.

| Option | Type | Default | Description |
| ----------- | --------------------------------------- | ------- | ------------------------------------- |
| `segments` | `number` | `2` | Number of words to generate |
| `pattern` | `JoyfulCategory[]` or custom `string[]` | none | Category pattern for each word |
| `wordLists` | `Record<string, readonly string[]>` | none | Custom named word lists |
| `omit` | `readonly string[]` | none | Exact words to exclude |
| `separator` | `string` | `"-"` | Character(s) between words |
| `maxLength` | `number` | none | Maximum length of the returned string |
| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `segments` | `number` | `2` | Number of words to generate |
| `pattern` | `JoyfulCategory[]` or custom `string[]` | none | Category pattern for each word |
| `wordLists` | `Record<string, readonly string[]>` | none | Custom named word lists |
| `omit` | `readonly string[]` | none | Exact words to exclude |
| `separator` | `string` | `"-"` | Character(s) between words |
| `maxLength` | `number` | none | Maximum length of the returned string |

### `permutations(options?)`

Returns the number of possible unbounded combinations as a `number`.

| Option | Type | Default | Description |
| ----------- | --------------------------------------- | ------- | ------------------------------ |
| `segments` | `number` | `2` | Number of words to count |
| `pattern` | `JoyfulCategory[]` or custom `string[]` | none | Category pattern for each word |
| `wordLists` | `Record<string, readonly string[]>` | none | Custom named word lists |
| `omit` | `readonly string[]` | none | Exact words to exclude |
| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `segments` | `number` | `2` | Number of words to count |
| `pattern` | `JoyfulCategory[]` or custom `string[]` | none | Category pattern for each word |
| `wordLists` | `Record<string, readonly string[]>` | none | Custom named word lists |
| `omit` | `readonly string[]` | none | Exact words to exclude |

### `JoyfulCategory`

Expand Down Expand Up @@ -267,9 +265,7 @@ All word lists are manually curated to be safe for work and family-friendly. Eve

## Benchmarks

Run `bun run perf` to generate the runtime, startup, package size, and consumer
bundle size report. See [BENCHMARKS.md](./BENCHMARKS.md) for what the report
measures and how to interpret it.
Run `bun run perf` to generate the runtime, startup, package size, and consumer bundle size report. See [BENCHMARKS.md](./BENCHMARKS.md) for what the report measures and how to interpret it.

## Credits

Expand Down
Loading
Loading