Files
Tyler Slaton 7df369f955 fix(build): generalize per-mode resolution to all conditions; fail-loud helper
CR-loop confirmation-round #4 findings:

- validator: `resolvesForMode` (renamed from `typesCoversMode`) now applies to
  EVERY condition, not just `types`. A partial object under `node`/`default`
  (active in both modes) no longer silently covers the mode it lacks —
  resolution falls through to the sibling, catching the untyped-JS #3324 shape
  there. This completes the per-mode model.
- helper: `withTypesConditions` throws on a non-object `exports` (bare string /
  array) instead of iterating it into a corrupt map; `typedTarget` now warns
  loudly when a JS target has no adjacent declaration (was silent, contradicting
  the helper's own fail-loud contract); idempotency skips only the helper's own
  `{ types: <string>, ... }` output, so a hand-authored types-first PARTIAL
  object is normalized (its untyped sibling gets a `types`). UMD / `.d.mts` docs
  corrected; `ctx.pkg: unknown` documented as intentional (weak-type constraint).
- tests: node/default partial fall-through regression; types-first-partial
  normalization; a helper->validator round-trip; a console.warn assertion for
  the missing-declaration path; split the untouched-target test into silent
  (non-JS) and warning (JS) cases.
- react-native: dropped a pre-existing duplicate `@ag-ui/client` external.

Call sites: resolvesForMode (internal, walk + recursion; grep-confirmed no
`typesCoversMode` refs); withTypesConditions signature unchanged, and the new
throw/warn never fire on tsdown's real input (object map, packageJsonPath
present, dts:true).

36 tests pass; validator typechecks; validate:exports exits 0; native-loader
builds of react-core + react-native unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 20:40:27 -07:00

41 lines
1.2 KiB
TypeScript

import { defineConfig } from "tsdown";
// NOTE: unlike the other tsdown-built packages, this config sets no `exports`
// option, so tsdown does NOT generate/overwrite package.json `exports` — the
// map (including the per-entry `types` conditions required by issue #3324) is
// hand-maintained in package.json. The `pnpm validate:exports` CI gate guards
// it against a missing `types` condition. If entry points change here, update
// the `exports` map in package.json by hand to match.
export default defineConfig({
entry: [
"src/index.ts",
"src/components/index.ts",
"src/polyfills.ts",
"src/polyfills/streams.ts",
"src/polyfills/encoding.ts",
"src/polyfills/crypto.ts",
"src/polyfills/dom.ts",
"src/polyfills/location.ts",
],
format: ["esm", "cjs"],
dts: true,
sourcemap: true,
target: "es2022",
outDir: "dist",
external: [
"react",
"react-native",
"@ag-ui/client",
"@copilotkit/react-core",
"@copilotkit/core",
"@copilotkit/shared",
"@gorhom/bottom-sheet",
"react-native-streamdown",
"react-native-gesture-handler",
"react-native-reanimated",
"react-native-enriched-markdown",
"react-native-worklets",
"remend",
],
});