FragiolaDnD
Documentation
Concepts

Capability entries

Each capability is its own import, so an app's bundle carries only what it uses. What each entry holds, and what it costs on a production build.

dnd is split by capability, not by layer. Each capability is its own entry, in the React package and in the core, and a capability never imports another one: it imports only the shared core.

entries
@fragiola/dnd-react               shared: drag space, collision strategies, events, types,
                                  DragOverlay, useDragMonitor, useDragSpace, autoScroll
    ├── /draggable                Draggable, DragHandle, useDraggable
    ├── /droppable                Droppable, useDroppable
    ├── /sortable                 Sortable, SortableGroup, DragHandle, useSortable,
    │                             useSortableGroup, verticalList, horizontalList, grid,
    │                             arrayMove, moveBetween
    └── /swappable                Swappable, DragHandle, useSwappable, swapItems, swapBetween

Each React entry re-exports the core entry of the same name (export *), so the core's registerDraggable is importable from @fragiola/dnd-react/draggable too. DragHandle is a shared part, re-exported by each drag source's entry (/draggable, /sortable, /swappable). What a drag source needs (the pointer and keyboard sensors, the operation, the writer) lives in the shared core, so sortable and swappable never import draggable. Collision strategies and autoScroll are separate exports of the shared entry, so an app that does not import one does not ship it.

What an app ships

pnpm size builds what an app's production build ships for the entries it imports, with the core they pull, minified and gzipped, with React left out and the development checks dropped:

importedmin + gzipover the shared entrytarget
@fragiola/dnd-react3.6 KB≤ 4 KB
@fragiola/dnd-react + /draggable8.6 KB5.0 KB≤ 2 KB extra
@fragiola/dnd-react + /droppable4.8 KB1.1 KB≤ 1.5 KB extra
@fragiola/dnd-react + /sortable11.5 KB7.9 KB≤ 2.5 KB extra
@fragiola/dnd-react + /swappable9.5 KB5.8 KB≤ 1.5 KB extra
the shared entry, /draggable, /droppable9.2 KB5.5 KB
those three + /sortable12.2 KB3.0 KB over those three
those three + /swappable10.2 KB1.0 KB over those three
all five13.0 KB9.3 KB
only Draggable7.0 KB
only Droppable3.1 KB
only Sortable9.2 KB
only Swappable7.6 KB

The drag sources miss their targets: each carries the pointer and keyboard sensors, the drag operation and the translate writer, shared between them, so an app that both drags and sorts pays for that machinery once. See bundle size for what is in each number and how it is measured.

Proved by a test

A bundle test builds a fixture that imports only Draggable and fails when droppable, sortable or swappable code is in the output, and the same for each capability. A guard test fails when a capability imports another.

No namespace object

There is no Dnd.* namespace on purpose: one object holding every part would put every capability in every bundle. This deviates from the Fragiola "one namespace" rule; see wrappers without HTML.