Give __unstable__loadDesignSystem a stable name for downstream tooling
#20500
johncarmack1984
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
prettier-plugin-tailwindcssis built on a name that says don't build on this.src/versions/v4.tscalls__unstable__loadDesignSystemon whichevertailwindcssthe user has installed, thendesign.getClassOrder(classList). That's the whole dependency. The plugin even declares its own one-methodDesignSysteminterface for it.Same name, same two calls, elsewhere:
tailwindcss canonicalizein@tailwindcss/cli, through@tailwindcss/node(whose wrapper already adds the defaultloadModule/loadStylesheetthat Expose minimal `getClassOrder` API without requiring `__unstable__loadDesignSystem` #17804 asked for, under the same unstable name)/sorterentry pointSo in practice the surface is public, but two of tailwindlabs' own tools already disagree on top of it.
tailwindcss@4.3.3, plugin 0.8.1, fresh project, no stylesheet:Known classes agree. Unknown ones: the CLI alphabetizes, the plugin keeps source order. That's fine, sorting policy can stay with consumers (the comment in
sort.test.tssays exactly that). The point is what everyone shares underneath: the loader andgetClassOrder.So, my proposal, kept small on purpose:
loadDesignSystemfromtailwindcss, and keep__unstable__loadDesignSystemas an alias so nothing breaksDesignSystemtype (today everyone writesAwaited<ReturnType<typeof __unstable__loadDesignSystem>>, the CLI included)@tailwindcss/nodegetClassOrder's signature:(classes: string[]) => [string, bigint | null][]. The rest ofDesignSystemstays as unstable as you want it.I know the prefix is deliberate. The object changes (eight members added to
DesignSystemsince 4.0) and core does no I/O on its own. Neither has to change. The two things I'm proposing to hold still haven't moved since before 4.0: the loader's signature last changed in #14150 (August 2024), andgetClassOrder's hasn't since the v4 codebase landed.#17804 asked for roughly this in April 2025. In #19092, @philipp-spiess said the core API "is not considered stable for now" and invited people to "help us shape it". If that's still open, I'd love to take you up on it. :)
How I got here: I've recently worked on the Tailwind presets in Biome's
useSortedClasses. The generator already calls__unstable__loadDesignSystemto enumerate utilities. The one thing it still scrapes out of tailwind's dist isproperty-order, and that's a different ask I'm tracking in biomejs/biome#11849. This one is just the name.I have the diff on this branch. It's two commits, two source files, tests, and a changelog line. The type export is its own commit, so it can be dropped on its own.
Happy to open it as a PR, or reshape it as needed. :)
All reactions