Skip to content

perf(types): import cross-component types from source, not the barrel#227

Merged
IgorShevchik merged 1 commit into
mainfrom
sync/nuxt-7eab4bc
Jun 29, 2026
Merged

perf(types): import cross-component types from source, not the barrel#227
IgorShevchik merged 1 commit into
mainfrom
sync/nuxt-7eab4bc

Conversation

@IgorShevchik

Copy link
Copy Markdown
Collaborator

Upstream

7eab4bcperf(types): import cross-component types from source, not the barrel (#6646)

Change

The ../types barrel (src/runtime/types/index.ts) export *s every component + every types/* submodule, so a single import type { … } from '../types' eagerly pulls the whole library into a consumer's type graph. This replaces those barrel imports with per-source imports:

  • component prop/slot/emit types ← the owning .vue (e.g. ButtonProps from ./Button.vue)
  • module types ← the specific ../types/* module (e.g. Messages from ../types/locale)

…across 119 consumer files under src/runtime/{components,composables,utils,dictionary,locale,vue/…}, plus an eslint no-restricted-imports guard so the barrel can't creep back in (useComponentProps.ts exempted — it legitimately needs the whole barrel via import type * as ComponentTypes).

Adapted, not 1:1

The type→source mapping was resolved against b24ui's own exports, not copied from upstream, because the component/type set diverges:

  • b24ui has no Icon.vue → upstream's IconProps (./Icon.vue) becomes IconComponent (../types/icons).
  • b24ui's own component set (no AuthForm/BlogPost/…, plus Advice/Countdown/Sidebar*/Navbar*).
  • Curated locale set (§2): 20 locale files retargeted (Messages../types/locale) vs upstream's 62; no new locales.

I built a name→source index from b24ui's barrel sources and rewrote each consumer with the correct relative specifier for its depth. 0 unresolved type names, 0 ambiguous names (no type exported by >1 source). The eslint rule mirrors upstream (restricted paths ../types/../../types, files = components/**/*.vue + composables/**/*.ts), appended through b24ui's existing .append(...) chain (bitrix24-ui/ plugin namespace). b24ui's only depth-3 barrel importers live under src/runtime/vue/… (outside the guarded globs) — rewritten but not eslint-guarded, exactly as upstream.

Scope

120 files, +284/−120. Only remaining barrel import is the intentional, rule-exempted one in useComponentProps.ts.

Tests

Types-only — no runtime/markup change, no snapshot churn.

Verify (CI=true)

dev:prepare · lint (new rule active, green) · typecheck (all 119 rewrites resolve) · test (5143 passed / 6 skipped, 225 files) · build — all green.

Ledger

🤖 Generated with Claude Code


Generated by Claude Code

Port of upstream nuxt/ui 7eab4bc (#6646).

Replace `import type { … } from '../types'` barrel imports with per-source
imports (the owning component `.vue`, e.g. `ButtonProps` from `./Button.vue`,
or a specific `../types/*` module, e.g. `Messages` from `../types/locale`)
across 119 consumer files under `src/runtime/`. The barrel re-exports every
component, so a single barrel import eagerly loads the whole library into a
consumer's type graph.

Adds an eslint `no-restricted-imports` guard on `../types` / `../../types` for
`components/**/*.vue` and `composables/**/*.ts`, with `useComponentProps.ts`
exempted (it legitimately needs the whole barrel via
`import type * as ComponentTypes`).

Type→source mapping resolved against b24ui's own exports (e.g. `IconComponent`
→ `../types/icons`, since b24ui has no `Icon.vue`). Types-only change; no
runtime or snapshot changes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JS8ypVfQSFzYVZzkTHhURb
@IgorShevchik IgorShevchik merged commit 575c8de into main Jun 29, 2026
1 check passed
@IgorShevchik IgorShevchik deleted the sync/nuxt-7eab4bc branch June 29, 2026 14:23
IgorShevchik added a commit that referenced this pull request Jun 29, 2026
…el (#230)

Port of upstream nuxt/ui 6576fb8 (#6648).

Move the ThemeUI / ThemeDefaults / ThemeContextDefaults / ThemeSlotOverrides
type definitions out of `composables/useComponentProps.ts` into a new
`types/theme.ts`. The composable was the last file importing the `../types`
barrel — only because those theme types reference every component's `*Props`.
Relocating them lets the composable drop the barrel import, and its eslint
`no-restricted-imports` exemption (added in #227) is removed.

`ThemeContext.defaults` is re-typed to the loose
`ComputedRef<Record<string, Record<string, any> | undefined>>`; the strict
shape now lives in `types/theme.ts`. b24ui's own 114-key `ThemeDefaults`
registry was moved verbatim. Types-only; no snapshot changes.


Claude-Session: https://claude.ai/code/session_01JS8ypVfQSFzYVZzkTHhURb

Co-authored-by: Shevchik Igor <noreply@anthropic.com>
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.

2 participants