ReviewOS

stacks/stx

Pantry-managed projects: `[Crosswind] CSS engine not available` even when `@cwcss/crosswind` is in `pantry/`

#1693
Closed glennmichael123 opened this 23 days ago · 0 comments
23 days ago

Summary

In a project that uses pantry (no node_modules, no bun.lock) as the package manager, stx's crosswind loader can't find @cwcss/crosswind even when it lives at pantry/@cwcss/crosswind/. Page renders show [Crosswind] CSS engine not available, Tailwind styles will not be generated and ship unstyled.

Repro

  1. Pantry-managed project. ./buddy dev is invoked; the buddy shell wrapper exports NODE_PATH=$PWD/pantry.
  2. pantry/@stacksjs/stx is a symlink to a local stx source checkout (or it's the vendored copy — same behavior).
  3. pantry/@cwcss/crosswind/dist/index.js exists and exports CSSGenerator.
  4. Boot the dev server. Output:
    [stx] Plugin loaded: stacksjs-components
    [Crosswind] CSS engine not available, Tailwind styles will not be generated
    Run 'bun add @stacksjs/crosswind' to enable CSS generation

Root cause

packages/stx/src/dev-server/crosswind.ts → findCrosswindPaths() only walks node_modules/ directories from process.cwd() upward, plus a fixed list of ~/Code/Tools/... and ~/repos/stacks-org/... dev paths. Pantry is not in any of those lists, so a pantry-only project finds zero candidate paths.

The loadCrosswind bare-specifier fallback (Strategy 1, await import('@cwcss/crosswind')) doesn't save us either, because Bun's dynamic-import resolver fails to walk node_modules upward across a package boundary. From inside stx/packages/stx/dist/dev-server/crosswind.js:

Cannot find module '@cwcss/crosswind' from '.../stx/packages/stx/dist/dev-server/_test.js'

…even though @cwcss/crosswind lives at stx/node_modules/@cwcss/crosswind AND is declared in stx/packages/stx/package.json. (Worth a separate Bun reproducer — but for stx this means we cannot rely on the bare-specifier path.)

Suggested fix

Add pantry to the cwd walk in findCrosswindPaths:

   let currentDir = process.cwd()
   while (currentDir !== path.dirname(currentDir)) {
     // Try @cwcss/crosswind first (new package name)
     paths.push(path.join(currentDir, 'node_modules', '@cwcss', 'crosswind', 'dist', 'index.js'))
     paths.push(path.join(currentDir, 'node_modules', '@cwcss', 'crosswind', 'src', 'index.ts'))
+    paths.push(path.join(currentDir, 'pantry', '@cwcss', 'crosswind', 'dist', 'index.js'))
+    paths.push(path.join(currentDir, 'pantry', '@cwcss', 'crosswind', 'src', 'index.ts'))
     // Also try @stacksjs/crosswind (legacy package name)
     paths.push(path.join(currentDir, 'node_modules', '@stacksjs', 'crosswind', 'dist', 'index.js'))
+    paths.push(path.join(currentDir, 'pantry', '@stacksjs', 'crosswind', 'dist', 'index.js'))
     currentDir = path.dirname(currentDir)
   }

Verified locally: with this patch, loadCrosswind() from inside the running dev server returns:

[Crosswind] CSS engine loaded from .../bench-review/pantry/@cwcss/crosswind

Broader pattern

This is one instance of a wider blind spot — multiple stx subsystems assume node_modules/ as the only package store:

  • findCrosswindPaths (this issue).
  • client-script-bundler.ts had to be patched to add a ~/ alias for projects that don't have a tsconfig path mapping; same shape of problem.
  • bun-plugin-stx's nested @stacksjs/stx inside its own node_modules/ shadows linked or pantry copies unless you symlink it manually.
  • storage/framework/core/actions/src/dev/views.ts already special-cases pantry/bun-plugin-stx/dist/serve.js — so the framework is aware of pantry in places, but not consistently.

Worth a follow-up pass: a small helper like resolvePackagePath(name, { searchPantry: true }) used everywhere the framework looks for sibling packages, instead of each subsystem rolling its own walk.

Environment

  • stx: 0.2.54 (from Projects/stx workspace)
  • Bun: 1.3.13
  • macOS arm64
  • Project layout: pantry/ (no node_modules/, no bun.lock), pantry/@stacksjs/stx → ../../../Projects/stx/packages/stx (symlink to live source).

Sign in to comment on this issue.