Skip to content

Modularize Ratatui crate #1388

@joshka

Description

@joshka

Problem

It would be nice to be able for widget crates to rely just on the widget / buffer / etc. types instead of the whole library.
Additionally by extracting a widget crate out of the library we might be able to have quicker incremental build times.
It would also be nice to be able to release non-breaking widget updates in point releases immediately rather than waiting for a library release.

Solution

Decompose Ratatui into several crates:

  • ratatui: the main core library, feature flags to include the parts
  • ratatui-core: Widget, WidgetRef, StatefulWidget, StatefulWidgetRef, Terminal, Frame, Backend etc.
  • ratatui-{crossterm,termion,termwiz}: backends
  • ratatui-widgets: all the existing built-in widgets (currently this is something else, but I'd move the current library to a new name)

It's possible that we could also go more granular than this and have a crate per widget, but I think it's worth doing the first part and evaluating whether doing more is worthwhile.

This will be implemented by making the repo into a cargo workspace, moving the current source under /ratatui/src, and creating several more crates at the root. I know it may be tempting to not do a monorepo for this, but the administrative overhead of having a repo per crate seem prohibitive, while I've had reasonable success using mono-repos (e.g. tui-widgets crate).

The work to do this will be:

  • make the actual refactoring changes
  • make the CI / CD changes
  • make the doc changes (fixup website links etc. to examples)
  • test changes in various widget libraries

@ratatui/maintainers what do you think?

Plan

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: AcceptedPR review approved / issue should be worked onType: EnhancementNew feature or requestType: RFCRequest for Comment. A design doc used to gather opinions on future features

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions