Skip to content

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

Merged
rpvilo merged 1 commit into
mainfrom
feature/exports-point-at-dist
Aug 21, 2026
Merged

refactor(chat): point exports at dist and delete the prepack export swap#68
rpvilo merged 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.

Summary by CodeRabbit

  • Improvements
    • Package entry points now consistently resolve to production-ready builds and type declarations.
    • Installation and consumption of the chat package are more reliable across supported environments.
    • Published package metadata is streamlined for clearer, more predictable access to public exports.
  • Compatibility
    • The existing public API remains unchanged.
  • Documentation
    • Added release notes documenting the updated package export behavior.

@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

@rpvilo

rpvilo commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai full review

This PR predates the CodeRabbit app being active here, so it has never been reviewed. It is also the one we intend to merge first and release on its own, because it changes how the package is published — so a review before merge is worth having.

Worth particular attention:

  • packages/chat/package.jsonexports now points permanently at ./dist with types/default conditions, publishConfig.exports is deleted, postpack is gone, and prepack is reduced to bun run build. The build must still run before packing; if that guarantee is broken the tarball ships stale or missing dist.
  • scripts/swap-exports.mjs deleted — anything still depending on the swap would now silently publish the wrong paths.
  • tsconfig.json + next.config.ts — the app previously resolved package source through the dev exports map. It now does so via a paths entry and a Turbopack resolveAlias listing all 11 subpaths explicitly. A missing subpath would fail only for that entry point.
  • scripts/smoke-dist.mjs — repointed from publishConfig.exports to exports, since the former no longer exists.

Verified locally: next build succeeds with packages/chat/dist deleted entirely, which is what proves the no-build-step dev loop still holds.

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown

@rpvilo, I will perform a complete review of #68. I will check the package publishing flow and the source-resolution changes.

✅ Action performed

Full review finished.

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c4664760-cafa-405f-b35e-2a4ae0a65ab1

📥 Commits

Reviewing files that changed from the base of the PR and between d73bb3f and 1042fb6.

📒 Files selected for processing (6)
  • .changeset/exports-point-at-dist.md
  • next.config.ts
  • packages/chat/package.json
  • packages/chat/scripts/smoke-dist.mjs
  • packages/chat/scripts/swap-exports.mjs
  • tsconfig.json
💤 Files with no reviewable changes (1)
  • packages/chat/scripts/swap-exports.mjs

Included review availability: 1 review is currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.

📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: React 19 passes ref as a regular prop — do not use forwardRef. Accept ref directly in the props type instead.
Prefer type over interface for type definitions. Prefer arrow functions over function keyword for components, handlers, and utilities.
Avoid useEffect for syncing/deriving state. Use it only for true side effects (subscriptions, DOM integrations).
Use cn() from lib/utils.ts for className merging.
Follow Biome rules and formatting.
Follow AI SDK patterns (useChat(), streamText(), toUIMessageStreamResponse()).
Do not use index/barrel files (index.ts that re-exports from other files). Import directly from the specific module instead. Exception: each packages/chat/src/<primitive>/ has exactly two barrels — index.parts.ts and index.ts — which are required for server-component reach and must stay directive-free.

Files:

  • next.config.ts
🔇 Additional comments (6)
packages/chat/package.json (2)

103-103: LGTM!


34-77: 🗄️ Data Integrity & Integration

No package inclusion change is required.

files includes dist, and prepack generates it before packing. The disabled-script pack excludes dist only because the checkout has no generated output.

			> Likely an incorrect or invalid review comment.
packages/chat/scripts/smoke-dist.mjs (1)

7-14: LGTM!

.changeset/exports-point-at-dist.md (1)

1-12: LGTM!

tsconfig.json (1)

23-24: LGTM!

next.config.ts (1)

4-24: LGTM!


📝 Walkthrough

Walkthrough

The package now exports built dist JavaScript and declaration files directly. Export-swapping hooks and nested publish exports were removed. The smoke test reads the top-level exports map, while TypeScript and Turbopack use repository source aliases.

Changes

Package export and resolution changes

Layer / File(s) Summary
Dist exports and packaging validation
packages/chat/package.json, packages/chat/scripts/smoke-dist.mjs, .changeset/exports-point-at-dist.md
Public subpaths now target built dist files. prepack only runs the build. The smoke test validates the top-level exports map. The changeset documents the packaging changes.
Repository source aliases
tsconfig.json, next.config.ts
TypeScript and Turbopack resolve @intentface/chat subpaths to source files during repository development.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 1042f

The package export and build changes are merge-ready after normal checks and review; no actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the primary changes: pointing chat exports to dist and removing the prepack export swap.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files. (3 skipped: 3 unsupported.)
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/exports-point-at-dist

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

@rpvilo
rpvilo merged commit 7be61d3 into main Aug 21, 2026
7 checks passed
@rpvilo
rpvilo deleted the feature/exports-point-at-dist branch August 21, 2026 12:46
@github-actions github-actions Bot mentioned this pull request Aug 21, 2026
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