Skip to content

Conversation

@Gaic4o
Copy link
Collaborator

@Gaic4o Gaic4o commented Dec 13, 2025

Background

This PR adds a new documentation page that explains common code smells related to cross-imports in Feature-Sliced Design (FSD).

The page was created after reviewing real-world discussions and recurring pain points shared by developers in the official FSD Telegram community.
By researching how teams have struggled with cross-import issues, the document aims to provide a clear conceptual understanding and a set of practical strategies to avoid or refactor problematic dependency patterns.

  • Added a new page: "Code smells / Cross-imports"
  • Defined the scope of cross-imports as imports between different slices within the same layer
  • Explained why cross-imports are considered a code smell, including examples of:
    • deep imports into another slice’s internals
    • blurred responsibility boundaries
  • Clarified cross-import handling across layers:
    • shared layer: no slice boundaries, therefore cross-imports are not considered an issue
    • entities layer: domain/type-centric; UI is discouraged and treated as a code smell
    • introduced @x as a dedicated, domain-only public API surface for cross-entity imports
  • Documented four strategies for addressing cross-imports in features / widgets:
    • Strategy A: Slice merge
    • Strategy B: Move shared domain flows into entities
    • Strategy C: Orchestrate from upper layers (pages / app)
    • Strategy D: Reuse only via Public API

@github-actions
Copy link

github-actions bot commented Dec 13, 2025

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
pr-fsd ✅ Ready (View Log) Visit Preview 1467a84

Copy link
Member

@illright illright left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'm not so enthusiastic about the current length and focus of this page. I found it a bit difficult to read because it seemed like there were many different topics covered. Let me try to give examples:

  1. The first two sections describe what the article will be about, but they already go into a little bit of depth, so to me it feels like this short introduction ends up distracting from the main content. I would personally start this page from the third section, "Why is it a code smell" (with a short definition of what a cross-import is), I don't think the page would've become harder to read.
  2. There's a part about deep imports, which is its own problem, even outside of cross-imports. It's currently covered in the Public API reference page.
  3. There's an entire section about the shared layer, with examples, even though cross-imports aren't really relevant for Shared. I think this section should just be a simple clarification in the beginning.
  4. In the Entities section, there's a discussion about not putting UI in Entities. While it's good advice, I don't think it's relevant to the issue of cross-imports either.
  5. The Defining domain types in entities section gives examples of content that belongs to the Entities layer, which mostly duplicates responsibility with the Types example guide and the Layers reference

I would suggest to liberally cut this page to only leave the essentials — what we're talking about, why it's a problem, what can be done. For example, the strategies from the Features/Widgets section are nice, but they are also quite long in my opinion

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