frontend: move shadow-DOM component CSS to real .css files, not JS strings

mara: 'i dont like sharing css via js, thats not how it should be done.'

Replaced the DIALOG_CSS/TOAST_CSS template-string constants in modal.js
and the inline CSS text in component-styles.js with three real .css
files (hive-dialog.css, hive-toast.css, component-common.css),
imported as raw text via esbuild's 'text' loader and turned into
CSSStyleSheet objects at runtime (same replaceSync() call as before --
only where the CSS text comes from changed). Both packages' build.mjs
gained a '.css': 'text' loader entry on their JS-bundling step; this
doesn't collide with the separate page-stylesheet bundling ('css'
loader), which is a different esbuild invocation over different entry
points.

No behavior change -- same adoptedStyleSheets wiring, same rules,
same output. Verified with a full frontend build (grepped the bundled
JS to confirm the CSS text inlines correctly); nix fmt clean.
This commit is contained in:
iris 2026-07-28 00:30:38 +02:00 committed by mara
commit bce666a9b2
7 changed files with 197 additions and 151 deletions

View file

@ -74,6 +74,15 @@ await build({
target: ['es2022'],
sourcemap: true,
logLevel: 'info',
// `@hive/shared/modal.js` imports its shadow-DOM component CSS
// (hive-dialog.css, hive-toast.css, component-common.css) as raw text
// via a plain `import css from './foo.css'` — the `text` loader turns
// that into a string constant at bundle time instead of erroring on an
// unrecognised extension. None of these JS entries import a `.css`
// file any other way, so this doesn't collide with the separate
// page-stylesheet bundling below (`loader: { '.css': 'css' }`), which
// runs as its own esbuild invocation over different entry points.
loader: { '.css': 'text' },
});
// Stream-worker entry (#448). Lives in a separate bundle: SharedWorker