You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Exploratory vision for v1: keep the user-facing strict layout tree small and intentional, and move Next.js codegen artifacts out of env/ into tool-owned virtual modules.
Supersedes the file-based direction in #1304 as the preferred end state. Related precursor: #1307 (Nuxt virtual alias — ships on dev, additive).
Problem
Next.js strict layout still requires manual server wiring:
Flat layout gets the same pattern (arkenv/gen or arkenv/gen/env) rather than generated/env.gen.ts in-tree
Exact specifier spelling (arkenv/gen/* vs #arkenv/* vs @arkenv/nextjs/gen/*), on-disk cache location, and commit-vs-gitignore policy are open judgment calls for this RFC.
#1307 proves the host-plugin can own resolution and auto-merge without committing factories next to schemas. v1 extends that idea to Next.js, where we still need some generated factory (for runtimeEnv), but it should not live in the user-facing tree.
Ship #1307 on dev as-is. Do not block it on this RFC. When this lands in v1, consider converging naming (#arkenv/… vs arkenv/gen/…) across hosts as a separate consistency pass.
#1304 remains the original problem statement and a valid interim file-based approach if we ever need a smaller step. This issue is the preferred v1 end state. Prefer implementing this over #1304’s server.gen.ts under env/generated/.
Open questions (human judgment)
Specifier namespace — arkenv/gen/client, #arkenv/gen/client, or @arkenv/nextjs/gen/client?
On-disk location — .arkenv/, node_modules/.arkenv/, or another cache? Committed for CI types, or always regenerated in withArkEnv / build?
Flat layout — same virtual surface, or keep a simpler single-module story?
Migration — soft compat for ./generated/env.gen imports in v1, or hard cut?
Summary
Exploratory vision for v1: keep the user-facing strict layout tree small and intentional, and move Next.js codegen artifacts out of
env/into tool-owned virtual modules.Supersedes the file-based direction in #1304 as the preferred end state. Related precursor: #1307 (Nuxt virtual alias — ships on
dev, additive).Problem
Next.js strict layout still requires manual server wiring:
#1304 proposed generating
server.gen.tsbesideenv.gen.tsto fix that. Design review found deeper issues with putting more machine output underenv/:env.gen.ts+server.gen.tsnaming is asymmetric and easy to misreadgenerated/+.genis redundant marking*.gen.tsnext to editable schemas invites misclicksenv/internal/+env/generated/together makesenv/feel like a mini-package, not an env validatorinternal/shared.ts→env/shared.tsis a DX footgun (invites@/env/sharedimports); app code should only import fromclientorserverVision (v1)
User-facing tree (unchanged intent)
internal/stays on purpose: awkward path as a guardrail so shared schema is not consumed directly.Machine-owned factories (new)
Codegen writes outside the schema tree (e.g.
.arkenv/or equivalent tool cache) and is exposed via stable virtual imports registered bywithArkEnv:Desired properties:
.gensuffix in the public import pathextends: [clientEnv](same DX goal as Generate server.gen.ts factory to eliminate manual extends: [clientEnv] in Next.js strict layout #1304 / (v1) Auto-extend client env in Nuxt strict layout via virtual module alias #1307)runtimeEnvbehaviorarkenv/genorarkenv/gen/env) rather thangenerated/env.gen.tsin-treeExact specifier spelling (
arkenv/gen/*vs#arkenv/*vs@arkenv/nextjs/gen/*), on-disk cache location, and commit-vs-gitignore policy are open judgment calls for this RFC.Relationship to #1307
Does not contradict — sets the stage.
dev)env/client.tsserver.ts@arkenv/nuxt/serverarkenv/gen/server(or similar)env/#1307 proves the host-plugin can own resolution and auto-merge without committing factories next to schemas. v1 extends that idea to Next.js, where we still need some generated factory (for
runtimeEnv), but it should not live in the user-facing tree.Ship #1307 on
devas-is. Do not block it on this RFC. When this lands in v1, consider converging naming (#arkenv/…vsarkenv/gen/…) across hosts as a separate consistency pass.Relationship to #1304
#1304 remains the original problem statement and a valid interim file-based approach if we ever need a smaller step. This issue is the preferred v1 end state. Prefer implementing this over #1304’s
server.gen.tsunderenv/generated/.Open questions (human judgment)
arkenv/gen/client,#arkenv/gen/client, or@arkenv/nextjs/gen/client?.arkenv/,node_modules/.arkenv/, or another cache? Committed for CI types, or always regenerated inwithArkEnv/ build?./generated/env.genimports in v1, or hard cut?#arkenv/client-envauto-extend model vs explicit generated server factory imports?Non-goals (for this RFC)
server.gen.tsas the final designdevenv/internal/shared.tsor makingshareda public importSuccess sketch
env/contains only user-authored modules (client,server,internal/*)server.tsneeds no manualextends: [clientEnv]