What happens
@stacksjs/defaults' components resolve by bare name. @stacksjs/components' do not — they need an explicit import in a <script client> block. That is reasonable on its own. What is not reasonable is how the difference announces itself.
Writing <Skeleton /> with no import produces this in the rendered page, as visible text:
[Error loading component: ENOENT: no such file or directory, open 'skeleton']
Searched paths:
- /…/resources/views/components/skeleton.stx
- /…/resources/components/skeleton.stx
… 24 more absolute paths …- HTTP 200
- nothing in the browser console
- nothing in the dev server output
- the build succeeds
- every searched absolute filesystem path is printed into the document
In an app of any size this is a page that looks broken to a user, leaks the developer's directory layout, and gives the developer no signal at all except by reading the rendered HTML.
Which names are affected
In a stock Stacks app, of the components documented in @stacksjs/components:
bare <Name> | resolves? |
|---|---|
Badge, Card, Avatar, Image, Video | yes — also present in @stacksjs/defaults |
Skeleton, Spinner, Switch, Progress, Dialog | no — error text into the page |
Dialog is the one that hurts. It is the documented way to build a modal, and it is in the group that silently fails. An app can have <Dialog :open="…"> on a page, ship it, and the only symptom is a block of text where the modal was — or nothing at all, if the surrounding markup swallows it.
Expectation
Any of these would fix it, roughly in order of preference:
- Make the names resolve. If
@stacksjs/componentsis installed, its components should answer to a bare name the way the defaults' do. The import requirement is invisible in the docs and the failure is silent. - Fail the build, or at minimum log an error to the dev server console and the browser console.
- Render nothing (an HTML comment) rather than visible text, and never print absolute filesystem paths into the document.
(3) alone would be a big improvement — the current behaviour is a production hazard independent of the resolution question.
Reproducing
<!-- resources/views/anything.stx -->
<Skeleton />curl the page. The error is in the body. Add import { Skeleton } from '@stacksjs/components' in a <script client> block and it renders correctly.
@stacksjs/components 0.2.339, stacks 0.75.35.
Related
- stacksjs/stx#2000 — shortcut rules emitted twice, so a shortcut silently overrides utilities written to modify it. Same shape of problem: correct-looking output, no diagnostic.