Document Astro config loading and refactor to use Vite fallback - #53
Merged
Merged
Conversation
Add documentation explaining how the CLI loads Astro configs with the same Node-then-Vite strategy Astro uses, enabling TypeScript-only package imports. Extract `loadAstroConfig` helper to core that tries plain Node import first, then falls back to Astro's Vite runner when that fails. Support all standard Astro config file extensions (mjs, js, ts, mts). Update CLI usage text to reflect supported config file patterns.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
polystella-docs | fbbf92b | Commit Preview URL Branch Preview URL |
Sep 24 2026, 10:07 AM |
🚀 Deploying Preview to Cloudflare 🚀Preview Deployments by commit
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Makes every PolyStella CLI command load the Astro config the way Astro does, so configs that import TypeScript-only packages (e.g.
@cloudflare/substrate/static) no longer breakcheck-ui,sync-ui,translate-ui,translate, oraudit-mdx.Previously the CLI imported
astro.config.mjswith plain Node. Node refuses to strip types undernode_modules, so any config that builds only via Astro's Vite path failed withERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING, which broke pre-commit hooks runningcheck-ui.loadAstroConfig(cwd)to@cloudflare/polystella-core/cli/config, mirroring Astro'sloadConfigWithVite:astro.config.{mjs,js,ts,mts}(previously.mjsonly).runnerImport, using the Vite that ships with the project's ownastroinstall. No new dependency, and it's the same Vite Astro uses.loadAstroI18n(used bytranslateandaudit-mdx) now calls core's loader instead of keeping its own copy.Type of change
PolyStella invariants touched
Core still never imports Astro or Vite: it looks up the consumer's Astro install at runtime, only in the Node-only
clisubpath and only when the plain import fails.Checklist
CONTRIBUTING.mdpnpm testpasses, or I have explained why it was not runpnpm typecheckpasses, or I have explained why it was not runpnpm typecheckandpnpm check:packagesfail on 12TS7006errors inpackages/emdash/src/admin/**/*.tsx. These are pre-existing: the same 12 errors appear on a clean tree with this change stashed. Core and Astro typecheck cleanly on their own.AI-generated code disclosure
anthropic/claude-opus-5-5)Screenshots / logs / test output
New test
packages/astro/tests/cli/astro-config-loader.test.tsruns core's built loader in a plain Node subprocess (under Vitest the config import would go through Vite and hide the failure). With the fallback removed, it fails with the reported error:With the fallback: