Summary
This is the final, isolated security patch for the Nuxt parity epic. ADR-0013 requires the strict layout to block client-side imports of any server-only schema file, including userland files like ~/env/server.ts. The current Vite plugin only blocks the @arkenv/nuxt/server package entry point, so the boundary is incomplete.
Current behavior
The Vite plugin registered by @arkenv/nuxt/module blocks:
id === "@arkenv/nuxt/server"
- any file under
@arkenv/nuxt/src|dist named server
It does not block imports of the user's own env/server.ts (or any file ending with /server inside the configured schema directory), which means a developer can still import server-only schemas into a client component and leak server variable names/types to the browser bundle.
Desired behavior
Extend the Vite resolveId plugin so that, during the client build, it also rejects module IDs whose resolved path ends with /server inside the schema directory. The error message should remain the existing branded message:
[ArkEnv] Importing server-only environment schema on the client is not allowed!
The check should work for both absolute paths and Nuxt aliases that resolve into the schema directory (e.g., ~/env/server, ~~/env/server).
Acceptance criteria
Out of scope
- Flat layout parsing and runtime API changes.
- Build-time validation and codegen.
- Changing the error message text or adding a remediation hint (can be a follow-up).
References
Summary
This is the final, isolated security patch for the Nuxt parity epic. ADR-0013 requires the strict layout to block client-side imports of any server-only schema file, including userland files like
~/env/server.ts. The current Vite plugin only blocks the@arkenv/nuxt/serverpackage entry point, so the boundary is incomplete.Current behavior
The Vite plugin registered by
@arkenv/nuxt/moduleblocks:id === "@arkenv/nuxt/server"@arkenv/nuxt/src|distnamedserverIt does not block imports of the user's own
env/server.ts(or any file ending with/serverinside the configured schema directory), which means a developer can still import server-only schemas into a client component and leak server variable names/types to the browser bundle.Desired behavior
Extend the Vite
resolveIdplugin so that, during the client build, it also rejects module IDs whose resolved path ends with/serverinside the schema directory. The error message should remain the existing branded message:The check should work for both absolute paths and Nuxt aliases that resolve into the schema directory (e.g.,
~/env/server,~~/env/server).Acceptance criteria
env/server.ts(or any file ending with/serverinside the configured schema directory) during the client build.@arkenv/nuxt/serverand package-internal server entry points.~/env/server.tsfails the build, while a server-side import succeeds.Out of scope
References
@arkenv/nuxt/src/module.ts— current Vite plugin implementation