Skip to content

feat(react-headless-components-preview): switch to subpaths exports#36036

Open
dmytrokirpa wants to merge 1 commit intomicrosoft:masterfrom
dmytrokirpa:feat/headless-subpath-imports
Open

feat(react-headless-components-preview): switch to subpaths exports#36036
dmytrokirpa wants to merge 1 commit intomicrosoft:masterfrom
dmytrokirpa:feat/headless-subpath-imports

Conversation

@dmytrokirpa
Copy link
Copy Markdown
Contributor

@dmytrokirpa dmytrokirpa commented Apr 23, 2026

Summary

  • Replaces the previous wildcard "./*" entry with an explicit export map — every subpath is individually enumerated in package.json to prevent accidental exposure of internal modules
  • Adopts kebab-case subpath keys ("./radio-group", "./message-bar", "./tab-list") following the same convention used across the rest of the Fluent UI v9 package namespace
  • Removes the root "." barrel export — consumers must import from the specific component subpath
  • Adds a conformance test that asserts every headless component has a named entry in the exports map, catching gaps at CI time
  • Switches all Storybook stories and the bundle-size fixture to import from subpath exports (@fluentui/react-headless-components-preview/radio-group, etc.)

Why explicit over wildcard

A wildcard "./*" passes through any path under the package root — including build artifacts, internal utilities, and anything else that happens to exist in lib/. Explicit entries make the public surface intentional and auditable.

Why kebab-case subpath keys

Kebab-case is consistent with how the rest of the Fluent UI v9 ecosystem names things in package paths and aligns with common Node.js ecosystem conventions for subpath exports . Removing the barrel export encourages consumers to import only what they need, enabling better tree-shaking.

Export map

".":               removed — import from subpath directly
"./accordion":     { "types": "./dist/accordion.d.ts",   "import": "./lib/accordion.js",   ... },
"./message-bar":   { "types": "./dist/message-bar.d.ts",  "import": "./lib/message-bar.js",  ... },
"./radio-group":   { "types": "./dist/radio-group.d.ts",  "import": "./lib/radio-group.js",  ... },
"./tab-list":      { "types": "./dist/tab-list.d.ts",     "import": "./lib/tab-list.js",     ... },
...

@dmytrokirpa dmytrokirpa self-assigned this Apr 23, 2026
@dmytrokirpa dmytrokirpa marked this pull request as ready for review April 23, 2026 12:24
@dmytrokirpa dmytrokirpa requested review from a team as code owners April 23, 2026 12:24
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 23, 2026

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-headless-components-preview
react-headless-components-preview: entire library
84.122 kB
24.635 kB
85.341 kB
25.007 kB
1.219 kB
372 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
global-context
createContext
510 B
328 B
global-context
createContextSelector
531 B
335 B
keyboard-key
keyboard-key package
3.746 kB
1.928 kB
keyboard-keys
Multiple keyCodes
50 B
70 B
keyboard-keys
Multiple keys
87 B
94 B
keyboard-keys
Single key
44 B
64 B
keyboard-keys
Single keyCode
39 B
59 B
priority-overflow
createOverflowManager
4.584 kB
1.873 kB
react
ActivityItem
71.22 kB
23.347 kB
react
Announced
38.472 kB
13.275 kB
react
Autofill
15.42 kB
4.766 kB
react
Breadcrumb
200.805 kB
59.601 kB
react
Button
194.354 kB
55.886 kB
react
ButtonGrid
179.242 kB
53.891 kB
react
Calendar
121.162 kB
36.83 kB
react
Callout
84.299 kB
27.593 kB
react
Check
53.206 kB
17.835 kB
react
Checkbox
59.978 kB
19.874 kB
react
ChoiceGroup
65.488 kB
21.465 kB
react
ChoiceGroupOption
58.769 kB
19.353 kB
react
Coachmark
92.7 kB
29.305 kB
react
Color
7.789 kB
3.127 kB
react
ColorPicker
134.97 kB
42.125 kB
react
ComboBox
250.687 kB
71.515 kB
react
CommandBar
201.861 kB
59.387 kB
react
ContextualMenu
154.229 kB
47.566 kB
react
DatePicker
183.251 kB
55.892 kB
react
DateTimeUtilities
5.244 kB
1.849 kB
react
DetailsList
229.929 kB
65.81 kB
react
Dialog
210.16 kB
62.358 kB
react
Divider
19.588 kB
6.84 kB
react
DocumentCard
215.843 kB
63.666 kB
react
DragDrop
8.343 kB
2.724 kB
react
DraggableZone
34.28 kB
11.488 kB
react
Dropdown
233.151 kB
67.962 kB
react
ExtendedPicker
96.823 kB
27.866 kB
react
Fabric
41.728 kB
14.343 kB
react
Facepile
209.377 kB
62.375 kB
react
FloatingPicker
240.865 kB
68.222 kB
react
FocusTrapZone
16.99 kB
5.891 kB
react
FocusZone
55.1 kB
17.451 kB
react
Grid
179.242 kB
53.891 kB
react
GroupedList
135.035 kB
40.67 kB
react
GroupedListV2
122.659 kB
37.758 kB
react
HoverCard
96.784 kB
30.688 kB
react
Icon
51.887 kB
17.263 kB
react
Icons
66.339 kB
24.385 kB
react
Image
46.901 kB
15.695 kB
react
Keytip
81.301 kB
26.677 kB
react
KeytipData
14.05 kB
4.583 kB
react
KeytipLayer
103.089 kB
31.9 kB
react
Keytips
105.873 kB
32.904 kB
react
Label
38.324 kB
13.241 kB
react
Layer
48.089 kB
16.348 kB
react
Link
39.665 kB
13.653 kB
react
List
39.346 kB
12.454 kB
react
MarqueeSelection
74.49 kB
22.402 kB
react
MessageBar
189.388 kB
56.33 kB
react
Modal
93.738 kB
30.223 kB
react
Nav
186.825 kB
55.723 kB
react
OverflowSet
33.354 kB
11.282 kB
react
Overlay
40.885 kB
14.077 kB
react
Panel
200.327 kB
59.336 kB
react
Persona
114.591 kB
36.435 kB
react
PersonaCoin
114.591 kB
36.435 kB
react
PersonaPresence
58.076 kB
19.372 kB
react
Pickers
297.91 kB
82.996 kB
react
Pivot
187.734 kB
56.5 kB
react
Popup
12.312 kB
4.197 kB
react
Positioning
22.764 kB
7.683 kB
react
PositioningContainer
73.445 kB
23.685 kB
react
ProgressIndicator
39.477 kB
13.528 kB
react
Rating
82.086 kB
26.09 kB
react
Fluent UI React (entire library)
1.019 MB
283.183 kB
react
ResizeGroup
13.35 kB
4.379 kB
react
ResponsiveMode
8.13 kB
2.966 kB
react
ScrollablePane
55.541 kB
17.718 kB
react
SearchBox
187.63 kB
55.936 kB
react
SelectableOption
724 B
413 B
react
SelectedItemsList
231.35 kB
67.176 kB
react
Selection
42.418 kB
12.26 kB
react
Separator
35.365 kB
12.132 kB
react
Shimmer
49.249 kB
16.258 kB
react
ShimmeredDetailsList
240.71 kB
68.549 kB
react
Slider
57.627 kB
19.198 kB
react
SpinButton
191.297 kB
57.006 kB
react
Spinner
41.759 kB
14.468 kB
react
Stack
42.039 kB
14.389 kB
react
Sticky
32.577 kB
10.488 kB
react
Styling
46.033 kB
15.135 kB
react
SwatchColorPicker
189.637 kB
57.417 kB
react
TeachingBubble
204.648 kB
60.317 kB
react
Text
36.886 kB
12.806 kB
react
TextField
80.798 kB
25.308 kB
react
Theme
43.486 kB
14.168 kB
react
ThemeGenerator
12.384 kB
4.116 kB
react
TimePicker
240.515 kB
69.311 kB
react
Toggle
46.201 kB
15.957 kB
react
Tooltip
87.073 kB
28.151 kB
react
Utilities
82.938 kB
25.15 kB
react
Viewport
23.872 kB
7.642 kB
react
WeeklyDayPicker
101.348 kB
31.644 kB
react
WindowProvider
1.059 kB
541 B
react-accordion
Accordion (including children components)
103.397 kB
31.296 kB
react-aria
ARIA - useARIAButtonProps
1.354 kB
648 B
react-aria
ARIA - AriaLiveAnnouncer
3.293 kB
1.507 kB
react-avatar
Avatar
48.492 kB
15.379 kB
react-avatar
AvatarGroup
17.468 kB
6.999 kB
react-avatar
AvatarGroupItem
61.513 kB
19.251 kB
react-badge
Badge
24.258 kB
7.881 kB
react-badge
CounterBadge
24.981 kB
8.137 kB
react-badge
PresenceBadge
24.216 kB
8.813 kB
react-breadcrumb
@fluentui/react-breadcrumb - package
115.18 kB
31.479 kB
react-button
Button
33.962 kB
9.022 kB
react-button
CompoundButton
40.843 kB
10.379 kB
react-button
MenuButton
38.866 kB
10.414 kB
react-button
SplitButton
47.663 kB
12.057 kB
react-button
ToggleButton
53.634 kB
11.155 kB
react-calendar-compat
Calendar Compat
149.292 kB
39.866 kB
react-card
Card - All
105.24 kB
29.479 kB
react-card
Card
97.858 kB
27.587 kB
react-card
CardFooter
12.792 kB
5.12 kB
react-card
CardHeader
15.321 kB
5.98 kB
react-card
CardPreview
12.872 kB
5.255 kB
react-charting
AreaChart
302.827 kB
94.751 kB
react-charting
ChartHoverCard
37.196 kB
12.7 kB
react-charting
DeclarativeChart
677.056 kB
191.292 kB
react-charting
DonutChart
203.52 kB
63.663 kB
react-charting
GanttChart
282.797 kB
88.761 kB
react-charting
GaugeChart
197.055 kB
61.221 kB
react-charting
GroupedVerticalBarChart
294.564 kB
91.795 kB
react-charting
HeatMapChart
285.643 kB
89.439 kB
react-charting
HorizontalBarChart
127.266 kB
39.944 kB
react-charting
HorizontalBarChartWithAxis
293.937 kB
91.167 kB
react-charting
Legends
151.485 kB
46.4 kB
react-charting
LineChart
332.438 kB
101.79 kB
react-charting
MultiStackedBarChart
181.754 kB
55.275 kB
react-charting
PieChart
134.305 kB
42.299 kB
react-charting
PolarChart
235.153 kB
74.294 kB
react-charting
SankeyChart
158.002 kB
49.166 kB
react-charting
ScatterChart
289.004 kB
91.071 kB
react-charting
Sparkline
87.616 kB
29.671 kB
react-charting
StackedBarChart
175.435 kB
52.872 kB
react-charting
TreeChart
84.809 kB
26.636 kB
react-charting
VerticalBarChart
303.589 kB
93.173 kB
react-charting
VerticalStackedBarChart
300.594 kB
92.797 kB
react-charts
AreaChart
412.997 kB
126.642 kB
react-charts
DeclarativeChart
763.759 kB
220.641 kB
react-charts
DonutChart
323.416 kB
97.131 kB
react-charts
FunnelChart
314.963 kB
94.145 kB
react-charts
GanttChart
396.105 kB
120.154 kB
react-charts
GaugeChart
322.849 kB
96.554 kB
react-charts
GroupedVerticalBarChart
403.98 kB
122.722 kB
react-charts
HeatMapChart
398.177 kB
122.047 kB
react-charts
HorizontalBarChart
303.146 kB
89.291 kB
react-charts
HorizontalBarChartWithAxis
63 B
83 B
react-charts
Legends
242.887 kB
71.756 kB
react-charts
LineChart
424.337 kB
128.724 kB
react-charts
PolarChart
351.985 kB
107.563 kB
react-charts
SankeyChart
220.864 kB
67.971 kB
react-charts
ScatterChart
403.719 kB
122.848 kB
react-charts
Sparkline
91.4 kB
28.708 kB
react-charts
VerticalBarChart
440.449 kB
128.312 kB
react-charts
VerticalStackedBarChart
409.991 kB
124.241 kB
react-checkbox
Checkbox
33.718 kB
11.424 kB
react-color-picker
ColorArea
47.407 kB
16.636 kB
react-color-picker
ColorPicker
16.157 kB
6.526 kB
react-color-picker
ColorSlider
39.577 kB
14.684 kB
react-combobox
Combobox (including child components)
106.709 kB
34.573 kB
react-combobox
Dropdown (including child components)
106.479 kB
34.32 kB
react-components
react-components: Button, FluentProvider & webLightTheme
70.415 kB
19.963 kB
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
237.29 kB
68.851 kB
react-components
react-components: FluentProvider & webLightTheme
43.63 kB
14.026 kB
react-components
react-components: entire library
1.302 MB
325.338 kB
react-datepicker-compat
DatePicker Compat
225.645 kB
63.659 kB
react-dialog
Dialog (including children components)
101.984 kB
30.317 kB
react-divider
Divider
16.354 kB
5.928 kB
react-field
Field
22.411 kB
8.393 kB
react-image
Image
13.626 kB
5.536 kB
react-input
Input
26.298 kB
8.705 kB
react-jsx-runtime
Classic Pragma
1.101 kB
550 B
react-jsx-runtime
JSX Dev Runtime
1.914 kB
908 B
react-jsx-runtime
JSX Runtime
2.268 kB
1.018 kB
react-label
Label
12.972 kB
5.261 kB
react-link
Link
16.191 kB
6.459 kB
react-list
List
87.098 kB
25.756 kB
react-list
ListItem
110.887 kB
32.626 kB
react-menu
Menu (including children components)
170.728 kB
51.986 kB
react-menu
Menu (including selectable components)
173.906 kB
52.574 kB
react-message-bar
MessageBar (all components)
23.418 kB
8.651 kB
react-motion
@fluentui/react-motion - createMotionComponent()
4.156 kB
1.818 kB
react-motion
@fluentui/react-motion - createPresenceComponent()
5.908 kB
2.442 kB
react-motion
@fluentui/react-motion - PresenceGroup
1.727 kB
823 B
react-overflow
hooks only
11.966 kB
4.565 kB
react-persona
Persona
55.447 kB
17.311 kB
react-popover
Popover
134.15 kB
41.538 kB
react-portal
Portal
11.219 kB
3.602 kB
react-portal-compat
PortalCompatProvider
8.386 kB
2.624 kB
react-positioning
usePositioning
28.889 kB
10.158 kB
react-positioning
useSafeZoneArea
12.445 kB
5 kB
react-progress
ProgressBar
20.23 kB
7.866 kB
react-provider
FluentProvider
23.018 kB
8.198 kB
react-radio
Radio
31.105 kB
9.66 kB
react-radio
RadioGroup
14.053 kB
5.703 kB
react-select
Select
26.183 kB
9.474 kB
react-slider
Slider
36.377 kB
12.034 kB
react-spinbutton
SpinButton
33.822 kB
11.128 kB
react-spinner
Spinner
23.721 kB
7.861 kB
react-swatch-picker
@fluentui/react-swatch-picker - package
104.207 kB
29.897 kB
react-switch
Switch
36.351 kB
11.07 kB
react-table
DataGrid
159.681 kB
44.965 kB
react-table
Table (Primitives only)
41.015 kB
13.174 kB
react-table
Table as DataGrid
131.023 kB
36.014 kB
react-table
Table (Selection only)
69.409 kB
19.408 kB
react-table
Table (Sort only)
68.052 kB
19.026 kB
react-tag-picker
@fluentui/react-tag-picker - package
187.014 kB
55.911 kB
react-tags
InteractionTag
13.742 kB
5.473 kB
react-tags
Tag
29.666 kB
9.433 kB
react-tags
TagGroup
82.265 kB
24.156 kB
react-teaching-popover
TeachingPopover
112.714 kB
34.302 kB
react-text
Text - Default
15.313 kB
5.968 kB
react-text
Text - Wrappers
18.473 kB
6.295 kB
react-textarea
Textarea
24.686 kB
8.972 kB
react-theme
Single theme token import
69 B
89 B
react-theme
Teams: all themes
37.985 kB
7.895 kB
react-theme
Teams: Light theme
20.803 kB
5.851 kB
react-timepicker-compat
TimePicker
109.674 kB
36.193 kB
react-toast
Toast (including Toaster)
102.992 kB
30.721 kB
react-tooltip
Tooltip
57.52 kB
19.808 kB
react-tree
FlatTree
148.056 kB
42.19 kB
react-tree
PersonaFlatTree
149.884 kB
42.567 kB
react-tree
PersonaTree
145.944 kB
41.374 kB
react-tree
Tree
144.122 kB
41.003 kB
react-utilities
SSRProvider
180 B
160 B
🤖 This report was generated against 0392152eacf970d6d7063c12af84b20b7d45c8e1

@github-actions
Copy link
Copy Markdown

Pull request demo site: URL

Copy link
Copy Markdown
Contributor

@Hotell Hotell left a comment

Choose a reason for hiding this comment

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

left some comments / questions. otherwise looks good ty

"node": "./lib-commonjs/index.js",
"import": "./lib/index.js",
"require": "./lib-commonjs/index.js"
"./*": {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is what I was pointing out with the suggestion to have src/public/*, if anyone adds something by "mistake" to src/* it's gonna be exposed as public api + accessible within monorepo for usage.

also it probably doesn't make sense to expose the index.ts for public as it doesn't exposes anything

Copy link
Copy Markdown
Contributor Author

@dmytrokirpa dmytrokirpa Apr 23, 2026

Choose a reason for hiding this comment

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

that's a valid point, but honestly, src/public/* isn't any better, it has the same problem. Lets go with explicit exports map defined in package.json, as it will allow us to keep the package structure as it is now, wdyt?

I've already updated the PR 😄

Comment thread tools/workspace-plugin/src/executors/generate-api/lib/utils.ts Outdated
Comment thread tools/workspace-plugin/src/executors/generate-api/lib/utils.ts Outdated
Comment thread tools/workspace-plugin/src/executors/generate-api/lib/utils.ts Outdated
@dmytrokirpa dmytrokirpa force-pushed the feat/headless-subpath-imports branch 4 times, most recently from fe2d854 to 4460694 Compare April 24, 2026 06:43
@dmytrokirpa dmytrokirpa changed the title feat(react-headless-components-preview): switch to subpaths exports feat(react-headless-components-preview): add subpaths exports for components Apr 24, 2026
@dmytrokirpa dmytrokirpa force-pushed the feat/headless-subpath-imports branch 4 times, most recently from 8c093ba to 5b472a7 Compare April 24, 2026 15:24
@dmytrokirpa dmytrokirpa changed the title feat(react-headless-components-preview): add subpaths exports for components feat(react-headless-components-preview): switch to subpaths exports Apr 24, 2026
@dmytrokirpa dmytrokirpa requested a review from Hotell April 24, 2026 15:56
@dmytrokirpa dmytrokirpa force-pushed the feat/headless-subpath-imports branch from 5b472a7 to 06b9431 Compare April 24, 2026 15:56
const config = {
react: {
17: {
runConfig: { 'type-check': { configPath: 'tsconfig.lib.json' } },
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

needed for passing the "moduleResolution" : "bundler"

@dmytrokirpa dmytrokirpa force-pushed the feat/headless-subpath-imports branch from 06b9431 to 1923afa Compare April 24, 2026 16:01
@dmytrokirpa dmytrokirpa force-pushed the feat/headless-subpath-imports branch from 1923afa to a3396e7 Compare April 24, 2026 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants