Skip to content

feat(zephyr-astro-integration): add ZE_PUBLIC dynamic env rewrite support#444

Draft
ryok90 wants to merge 2 commits into
mainfrom
feat/astro-ze-public-env-rewrite
Draft

feat(zephyr-astro-integration): add ZE_PUBLIC dynamic env rewrite support#444
ryok90 wants to merge 2 commits into
mainfrom
feat/astro-ze-public-env-rewrite

Conversation

@ryok90
Copy link
Copy Markdown
Collaborator

@ryok90 ryok90 commented Apr 30, 2026

What's added in this PR?

  • Adds an Astro-side Vite sub-plugin (with-zephyr-astro-env) through astro:config:setup so Astro follows the same ZE_PUBLIC_* runtime behavior as the existing Vite flow.
  • Mirrors ZE_PUBLIC_* variables from loaded env files into process.env (without overwriting pre-set values) for manifest/runtime consistency.
  • Rewrites process.env.ZE_PUBLIC_* and import.meta.env.ZE_PUBLIC_* reads to the virtual manifest module and resolves the generated env:vars:<app_uid> specifier to /zephyr-manifest.json in development and an external import in build.
  • Extends Astro integration tests to cover hook registration and plugin injection.

Screenshots

  • N/A (behavioral/runtime integration change)

What's the issues or discussion related to this PR ?

  • Astro integration previously did not replicate ZE_PUBLIC_* dynamic env rewriting behavior already implemented in the Vite plugin path.
  • This created inconsistent runtime env handling across bundlers; this PR aligns Astro behavior with the established Zephyr Vite implementation.

What are the steps to test this PR?

  1. Run pnpm nx test zephyr-astro-integration.
  2. In an Astro app using withZephyr, define one or more ZE_PUBLIC_* vars in .env.
  3. Reference these vars via either process.env.ZE_PUBLIC_* or import.meta.env.ZE_PUBLIC_* in app code.
  4. Build/serve and verify values resolve through Zephyr manifest runtime flow.

Documentation update for this PR (if applicable)?

  • Not yet. If required, I can open a docs PR in zephyr-documentation to describe Astro parity for ZE_PUBLIC_* behavior.

(Optional) What's left to be done for this PR?

  • Add an end-to-end Astro fixture test that asserts transformed output contains the virtual manifest import and ZE_PUBLIC_* rewrites.

(Optional) What's the potential risk and how to mitigate it?

  • Risk: introducing Vite plugin behavior into Astro could affect transform ordering in uncommon project setups.
  • Mitigation: plugin is scoped to ZE_PUBLIC_* references only, skips node_modules, and is covered by unit tests; further mitigate with fixture/e2e coverage.

(Required) Pre-PR/Merge checklist

  • I have added/updated/opened a PR to documentation to cover this new behavior
  • I have added an explanation of my changes
  • I have written new tests (if applicable)
  • I have tested this locally (standing from a first time user point of view, never touch this app before)
  • I have/will run tests, or ask for help to add test

@github-actions
Copy link
Copy Markdown

🚀 Preview Environment Ready!

Name Status URL
astro-blog ✅ Active https://testuser-45754-astro-blog-zephyr-packages-zephyrc-d347001... ↗

Details:

  • Latest Commit: 398006d
  • Created at: 4/30/2026, 5:42:02 PM

@ryok90 ryok90 self-assigned this Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant