feat: inject the active environment via prismic/env/register#220
Draft
angeloashmore wants to merge 3 commits into
Draft
feat: inject the active environment via prismic/env/register#220angeloashmore wants to merge 3 commits into
prismic/env/register#220angeloashmore wants to merge 3 commits into
Conversation
This was referenced Jul 8, 2026
4 tasks
491a87e to
a1bc457
Compare
Add the `prismic/env/register` export, which sets the framework's public environment variable from the active environment at config-load time, and wire `gen setup` to import it in the framework config for Next.js, Nuxt, and SvelteKit. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
a1bc457 to
dafee7a
Compare
… notice `gen setup` adds `prismic` as a project dependency when it injects the `prismic/env/register` import, so the import resolves at runtime. When `prismic` is installed as a project dependency, the update notice now points to the package manager (e.g. `npm install prismic@latest`) instead of `npx`, which would fetch a fresh copy without changing the installed version. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The module used top-level `await`, which fails when a bundler loads a config file that doesn't support it (e.g. Next.js loading `next.config.ts`), throwing `ReferenceError: await is not defined`. Resolve the active environment synchronously instead. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Resolves:
Note
Top of the stack: #218 → #219 → #220 (this PR). Merge #218 then #219 first — this PR targets #219's branch.
Because this PR's base is #219, its per-PR prerelease (
prismic@pr-220) contains the full environments flow (A+B+C) and is the one to install for end-to-end testing.Description
Adds the
prismic/env/registerexport so a running app can follow the active environment, not just the CLI. A site adds one import to the top of its framework config:The preload reads the active environment (from #218) and sets the framework's public environment variable before the app boots.
gen setupadds the import automatically for Next.js, Nuxt, and SvelteKit (ESM configs only).Two supporting changes make the import work in a real project:
gen setupaddsprismicas a project dependency when it injects the import, soprismic/env/registerresolves at runtime.npm install prismic@latest) whenprismicis a project dependency, instead ofnpx, which would fetch a fresh copy without changing the installed version. Thenpxmessage still shows whenprismicis not installed locally.Checklist
Preview
How to QA 1
prismic env set my-repo-stagingRun
prismic gen setupand confirm it addsimport "prismic/env/register"to the framework config andprismicto the project's dependencies. Then runnpm run devand confirm the app reads the active environment asNEXT_PUBLIC_/NUXT_PUBLIC_/PUBLIC_PRISMIC_ENVIRONMENT.To check the update notice, install
prismicin a project and confirm the notice suggests your package manager (e.g.npm install prismic@latest) rather thannpx.Footnotes
Please use these labels when submitting a review:
⚠️ #issue: Strongly suggest a change.
❓ #ask: Ask a question.
💡 #idea: Suggest an idea.
🎉 #nice: Share a compliment. ↩