Skip to content

refactor: derive package entrypoints from src/*.ts - #93

Draft
kjanat wants to merge 3 commits into
masterfrom
refactor/flat-public-entrypoints
Draft

refactor: derive package entrypoints from src/*.ts#93
kjanat wants to merge 3 commits into
masterfrom
refactor/flat-public-entrypoints

Conversation

@kjanat

@kjanat kjanat commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Closes #91.

What

The public surface was described in seven synchronized places: nested index.ts barrels, the entries map in tsdown.config.ts, exact #micro509/<domain> aliases, generated package.json#exports, generated jsr.json#exports, the Deno import map, and the docs. Adding an entrypoint meant touching all of them.

The eight src/<domain>/index.ts barrels move to src/<domain>.ts. Git records all eight as 100% renames, so no export list changed. tsdown takes entry: ['src/*.ts'] and the build:done JSR hook globs the same root files, making the filesystem the only manifest. package.json#imports drops the eight exact domain aliases; #micro509/* already resolves both #micro509/x509 and #micro509/x509/parse.

Implementation modules stay where they are. src/x509/parse.ts, src/pkcs/pfx.ts, and the rest are untouched.

Surface parity

Package specifiers are unchanged. The export set of all nine entrypoints was captured before the change and compared after, three ways:

  • source aliases (#micro509, #micro509/der, …)
  • built artifacts (dist/*.js, imported directly)
  • Node's resolution of the package specifiers (micro509, micro509/der, …)

All three match the baseline exactly: 142 root symbols, 48 der, 53 keys, 7 pem, 13 pkcs, 9 result, 28 revocation, 13 verify, 48 x509.

package.json#exports is byte-identical to before, still exactly ., ./der, ./keys, ./pem, ./pkcs, ./result, ./revocation, ./verify, ./x509, ./package.json, each with its types condition. jsr.json#exports now points at the flat source paths. A second build produces no metadata diff.

Guarding the root

Because tsdown globs src/*.ts, a stray root file would silently become a published subpath. test/conventions.test.ts gains a test pinning the root entry set, and its barrel lookup moves from <domain>/index.ts to <domain>.ts.

Deno import map

deno.import_map.json is gitignored and regenerated by deno:importsmap. After regeneration it carries no #micro509/<domain>/index aliases. #micro509/index remains, as it did before: it is the wildcard resolving the root entry, which importmapify emits for every root file.

Verification

typecheck, biome, dprint, deno lint (all 125 files), 1483 tests, 249 PKITS, 76 OpenSSL differential, docs:lint, publint (All good!), attw --profile esm-only (green for every entrypoint), and the smoke suite across Bun, Node, Deno, browser, and workerd.

No version bump; the entry is under [Unreleased].

The public surface was described in seven synchronized places: nested
barrels, the `entries` map in `tsdown.config.ts`, exact `#micro509/<domain>`
aliases, generated npm and JSR exports, the Deno import map, and the docs.
Adding an entrypoint meant touching all of them.

The eight `src/<domain>/index.ts` barrels move to `src/<domain>.ts` with
their contents unchanged. tsdown globs `entry: ['src/*.ts']`, and the JSR
hook globs the same root files, so the filesystem is the only manifest.
`package.json#imports` drops the exact domain aliases; `#micro509/*` now
serves both `#micro509/x509` and `#micro509/x509/parse`.

Package specifiers and every exported symbol are unchanged. Verified by
comparing the export set of all nine entrypoints before and after, through
source aliases, `dist/*.js`, and Node's resolution of `micro509/<domain>`.

Root `src/*.ts` is now reserved for entrypoints, since a stray root file
would publish a subpath, so `test/conventions.test.ts` pins the set.
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • cr:review
🚫 Excluded labels (none allowed) (2)
  • wip
  • cr:skip

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 59b4b217-14bc-4de0-bad8-b5065b0eb156

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 25, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
micro509 7bf2903 Jul 25 2026, 02:40 AM

@pkg-pr-new

pkg-pr-new Bot commented Jul 25, 2026

Copy link
Copy Markdown
  • micro509-vite-demo

    npm i https://pkg.pr.new/micro509@93
    
    pnpm add https://pkg.pr.new/micro509@93
    
    bun add https://pkg.pr.new/micro509@93
    

commit: 7bf2903

@codecov

codecov Bot commented Jul 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

The structure tree named one of the nine root entry files and waved at
the rest; the src/ module map named three of eight. Both now list them.

The jsr hook hand-rolled a glob behind a named constant and a helper so
each could carry a comment. It reads the directory once, inline, on the
same cwd assumption as the writeFile below it and as tsdown's own entry
glob.
@kjanat kjanat self-assigned this Jul 25, 2026
Comment thread src/internal/AGENTS.md

`src/internal/` hosts reusable low-level spines consumed by all domains.
Public barrels should stay in domain folders.
Public barrels are the root `src/*.ts` files and never live here.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NO SHIT, THE DIRECTORY IS CALLED INTERNAL.

Comment thread src/AGENTS.md Outdated
Comment on lines -3 to -10
Public domain entrypoints are one-level buckets, implementation details stay in
`src/internal/`.
Public entrypoints are the root `src/*.ts` files; domain implementation stays in
`src/<domain>/` and internals in `src/internal/`.

## OVERVIEW

`src/` is the library boundary. High-level workflow ownership is in domain
barrels under `x509`, `verify`, `revocation`, `keys`, `pem`, `pkcs`, and
`result`.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you be any more verbose... wtf...

Comment thread src/AGENTS.md
| Area | File/dir | Notes |
| ------------------ | ---------------------------------------------------------------------------------------------- | --------------------------------------------------- |
| Package root | `index.ts` | all stable package exports |
| Domain entrypoints | `der.ts`, `keys.ts`, `pem.ts`, `pkcs.ts`, `result.ts`, `revocation.ts`, `verify.ts`, `x509.ts` | re-export-only |

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to enumerate all in a fucking table cell

Comment thread test/conventions.test.ts

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get rid of this file

`test/conventions.test.ts` regex-matched source text for two rules a
linter can check properly. `style/noDefaultExport` covers one, scoped to
`src/`, since tsdown.config.ts, the VitePress config and theme, and
scripts/smoke-worker.mjs all need a default export. A GritQL plugin
covers the other, and unlike the regex it sees class expressions and
ignores a `class` line inside a template literal.

The entrypoint test hardcoded the nine root stems that
`package.json#exports` and `jsr.json#exports` already carry. It now
asserts the three agree, so adding an entrypoint needs no edit here and
the two maps cannot drift apart.

The linter config moves to `preset: recommended` with the `types`
domain on, which is what the site and pbes2 changes answer.
@kjanat
kjanat marked this pull request as draft July 25, 2026 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flatten public barrels to src/*.ts and derive tsdown entries from the filesystem

1 participant