Skip to content

feat(hosting): source wheel modules' components/ in gen-pages (fixes Windows widget-CSS drop) - #259

Open
antosubash wants to merge 1 commit into
mainfrom
fix/gen-pages-source-components
Open

feat(hosting): source wheel modules' components/ in gen-pages (fixes Windows widget-CSS drop)#259
antosubash wants to merge 1 commit into
mainfrom
fix/gen-pages-source-components

Conversation

@antosubash

Copy link
Copy Markdown
Owner

Summary

gen-pages emits an absolute @source for each wheel-installed module's
pages/, but not for its components/. Wheel modules ship widgets under
components/ (pagebuilder's SiteHeader, MediaObject, Hero, …) whose
Tailwind classes go uncompiled unless the host hand-adds a @source line —
and the only way to point at a wheel dir by hand is a .venv-relative path,
which is not portable across OSes.

Why it bites (Windows)

A host that hand-writes the POSIX layout:

@source "../../.venv/lib/python3.12/site-packages/pagebuilder/components";

matches nothing on Windows, whose venv is .venv/Lib/site-packages/...
(capital Lib, no python3.x/). Tailwind accepts the glob silently and drops
every widget class from the build: the site-header nav is display:none
(lg:flex never emitted), the hero collapses, two-column widgets stack, and
section background colours vanish. The failure is invisible — no error, just a
broken-looking site — and only on Windows.

(Found the hard way bringing up Global Canopy Atlas on Windows.)

Root cause

render_modules_css (framework/hosting/simple_module_hosting/assets.py) emits
@source for pages_dir only:

source_lines = [
    f'@source "{e.pages_dir.as_posix()}/**/*.{{ts,tsx}}";'
    for e in assets
    if e.pages_dir and not in_repo(e.pages_dir)
]

components/ is never discovered, so every app is left to hand-source it — and
hand-sourcing a wheel dir can't be written portably.

Fix

Have gen-pages emit an absolute @source for a wheel module's components/
too, exactly as it already does for pages/. Absolute as_posix() paths work
on POSIX and Windows alike, so no host ever hand-writes a .venv/... line
again. In-repo modules stay covered by the host's static modules/* glob.

PR attached.


Change: compute_module_assets now discovers components/; render_modules_css emits the same absolute as_posix() @source glob for it as for pages/; modules.assets.json gains a components key. Added unit tests for detection + emission (+ the in-repo skip); 16 passed, 1 skipped, ruff clean.

Closes #258

`render_modules_css` emitted an absolute `@source` for each wheel module's
`pages/` but not its `components/`, so widgets shipped in a wheel (pagebuilder's
SiteHeader, MediaObject, Hero, ...) had their Tailwind classes dropped from the
build unless the host hand-added a `@source` line. Hand-sourcing a wheel dir can
only be written as a `.venv`-relative path, which silently matches nothing on
Windows (`.venv/Lib/site-packages`, not `.venv/lib/python3.x/...`) — the site
builds with the widget nav at `display:none` and no error.

Discover `components/` alongside `pages/` and emit the same absolute
`as_posix()` `@source` glob. In-repo modules stay covered by the host's static
`modules/*` glob. No host hand-writes a `.venv/...` line again.

Closes #258

Claude-Session: https://claude.ai/code/session_01852vDTaepS9fbFaMEWrrVX
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying simple-module-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0a0be3a
Status: ✅  Deploy successful!
Preview URL: https://248f9409.simple-module-python.pages.dev
Branch Preview URL: https://fix-gen-pages-source-compone.simple-module-python.pages.dev

View logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant