Split from #2004, which was closed once the dangerous half of this was fixed. That issue's first and preferred expectation was to make the names resolve, and that part is untouched.
What happens
@stacksjs/defaults' components answer to a bare tag. @stacksjs/components' do not, and need an explicit import in a <script client> block.
bare <Name> | resolves? |
|---|---|
Badge, Card, Avatar, Image, Video | yes, because they are also in @stacksjs/defaults |
Skeleton, Spinner, Switch, Progress, Dialog | no |
Since 988a0e627f the failure is quiet rather than hazardous: an HTML comment in the page and a console.error carrying the searched paths, instead of a block of absolute filesystem paths in the body. So this is no longer a production incident, just an invisible one.
Dialog is still the one that hurts. It is the documented way to build a modal, it is in the non-resolving group, and an app can ship <Dialog :open="…"> with nothing where the modal should be.
Why
Resolution searches project directories only:
// packages/stx/src/utils.ts:748
push(path.resolve(configuredRoot, 'resources/views/components'))
push(path.resolve(configuredRoot, 'resources/components'))Nothing consults an installed package, so no amount of having @stacksjs/components in package.json makes a bare <Dialog /> resolve.
Options
- Let an installed component package register its own names, so
@stacksjs/componentsanswers to a bare tag the way the defaults do. This is what the docs already imply, since they show the components without an import. - Document the import requirement where the components are documented. Cheaper, and it leaves the two packages behaving differently for no reason a reader can see.
(1) is the one worth doing. The current split is not a design, it is an accident of which package the defaults happen to live in.
Reproducing
<!-- resources/views/anything.stx -->
<Dialog :open="true" />curl the page: an HTML comment where the dialog should be, and the paths on the dev server's console. Add import { Dialog } from '@stacksjs/components' in a <script client> block and it renders.
Measured on main at 0.2.345.