perf(types): import cross-component types from source, not the barrel#227
Merged
Conversation
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
04912d9 to
2151137
Compare
This was referenced Jun 29, 2026
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Upstream
7eab4bc—perf(types): import cross-component types from source, not the barrel (#6646)Change
The
../typesbarrel (src/runtime/types/index.ts)export *s every component + everytypes/*submodule, so a singleimport type { … } from '../types'eagerly pulls the whole library into a consumer's type graph. This replaces those barrel imports with per-source imports:.vue(e.g.ButtonPropsfrom./Button.vue)../types/*module (e.g.Messagesfrom../types/locale)…across 119 consumer files under
src/runtime/{components,composables,utils,dictionary,locale,vue/…}, plus an eslintno-restricted-importsguard so the barrel can't creep back in (useComponentProps.tsexempted — it legitimately needs the whole barrel viaimport 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:
Icon.vue→ upstream'sIconProps(./Icon.vue) becomesIconComponent(../types/icons).AuthForm/BlogPost/…, plusAdvice/Countdown/Sidebar*/Navbar*).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 undersrc/runtime/vue/…(outside the guarded globs) — rewritten but not eslint-guarded, exactly as upstream.Scope
120files, +284/−120. Only remaining barrel import is the intentional, rule-exempted one inuseComponentProps.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
.sync/log/7eab4bc….md— port rationale.sync/nuxt-ui.json— add7eab4bcasport, advance cursor; reconcile prior88baabcf→ PR fix(Separator): forward fall-through attributes to root #225 /007602bf. (7eab4bcitself stayspending-merge, reconciled next port.)🤖 Generated with Claude Code
Generated by Claude Code