Skip to content

refactor(chat): point exports at dist and delete the prepack export swap - #68

Open
rpvilo wants to merge 1 commit into
mainfrom
feature/exports-point-at-dist
Open

refactor(chat): point exports at dist and delete the prepack export swap#68
rpvilo wants to merge 1 commit into
mainfrom
feature/exports-point-at-dist

Conversation

@rpvilo

@rpvilo rpvilo commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Closes CHAT-9. Points exports permanently at ./dist and deletes the prepack export swap.

Why

exports pointed at ./src/*.ts in the repo, so the docs app could consume package source with no build step, and a prepack/postpack pair swapped it to ./dist for packing. npm builds the packument from package.json as it stands after postpack — which restored the source paths — so every published version advertises ./src/*.ts for all 11 subpaths, files the tarball does not ship. Still true on 0.1.2:

$ npm view @intentface/chat exports
{
  './types': './src/types.ts',
  './composer': './src/composer/index.ts',
  ...
}

Consumers were never affected — Node resolves against the package.json inside the tarball, which always carried correct ./dist paths. But the metadata reads exactly like a broken publish, and it already misled one debugging session into concluding the package was uninstallable.

The deciding factor is that the mechanism has an expiry date regardless. npm warns:

npm warn Unknown publishConfig config "exports". This will stop working
in the next major version of npm.

What changed

  • exports now carries the ./dist map with types/default conditions, permanently.
  • publishConfig reduced to {"access":"public"}; publishConfig.exports deleted.
  • scripts/swap-exports.mjs deleted, postpack removed, prepack reduced to bun run build — the build must still run before packing.
  • The app gets source resolution from the repo instead of from the exports map: a paths entry in tsconfig.json and a matching turbopack.resolveAlias in next.config.ts, each mapping the 11 subpaths to packages/chat/src. The alias entries are explicit rather than a wildcard, because Turbopack's resolveAlias matches request strings, not globs.
  • scripts/smoke-dist.mjs now reads exports instead of publishConfig.exports. This coupling was the one surprise: the smoke test added in fix(chat): add .js extensions to single-quoted dist specifiers #65 iterated the publish-only map, so deleting that key broke the build until it was repointed.

tsconfig.demos.json needed no change — it declares its own paths to packages/chat/dist and does not extend the root config, so the portability gate still tests the built package rather than source.

Relationship to #64

This supersedes #64, which repairs the swap by deferring the restore to postpublish. That fix is correct, but it invests in the mechanism this PR deletes. If this lands, #64 should be closed unmerged — the packument comes out right because there is no swap left to leak.

Verification

  • bun run build — 252 specifiers rewritten, smoke-dist reports all 11 entries load under Node
  • publint — clean, and no longer warns about publishConfig.exports
  • 191 package tests pass
  • app tsc --noEmit clean; tsc -p tsconfig.demos.json (portability gate) clean; scripts/audit-docs.mjs clean; biome check clean
  • next build green with packages/chat/dist deleted entirely — the actual proof that the app still compiles package source with no build step, rather than silently resolving through a stale dist
  • CodeRabbit review: 0 findings

Takes effect on the next publish. Packument entries are immutable, so 0.1.0–0.1.2 keep their stale metadata permanently; harmless, and not worth a release on its own.

@vercel

vercel Bot commented Aug 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
intentface-chat Ready Ready Preview Aug 20, 2026 5:26am

Request Review

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.

1 participant