Skip to content

feat(nuxt): core API & flat layout support - #1248

Merged
yamcodes merged 6 commits into
devfrom
1242-featnuxt-core-api-flat-layout-support
Jun 29, 2026
Merged

feat(nuxt): core API & flat layout support#1248
yamcodes merged 6 commits into
devfrom
1242-featnuxt-core-api-flat-layout-support

Conversation

@yamcodes

Copy link
Copy Markdown
Owner

Fixes #1242

This PR adds core API and flat layout support to @arkenv/nuxt, aligning it with the Next.js integration features.

Changes:

  • Extended ModuleOptions.layout type to support "flat", treating "simple" as a deprecated alias with dev-time warnings.
  • Refactored build-time key extraction helper in @arkenv/build to support parameterized framework prefixes, avoiding duplicate AST RegExp parsing in @arkenv/nuxt and @arkenv/nextjs.
  • Updated createEnvInternal to support runtime key categorization and proxy shielding under the flat layout using NUXT_PUBLIC_, NODE_ENV, and exposeToClient.
  • Added flat signature overloads and runtime handlers to the main createEnv entrypoint in @arkenv/nuxt with robust TypeScript type inference.

@yamcodes yamcodes added enhancement New feature or improvement @arkenv/nuxt Issues or Pull Requests involving the Nuxt integration for ArkEnv labels Jun 27, 2026
@yamcodes yamcodes linked an issue Jun 27, 2026 that may be closed by this pull request
6 tasks
@changeset-bot

changeset-bot Bot commented Jun 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3330c83

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@arkenv/nuxt Patch
@arkenv/build Patch
@arkenv/nextjs Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added docs Adds or changes documentation, or acts as documentation in and of itself tests This issue or PR is about adding, removing or changing tests @arkenv/nextjs Issues or Pull Requests involving the Next.js integration for ArkEnv labels Jun 27, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jun 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

arkenv

npm i https://pkg.pr.new/arkenv@1248

@arkenv/build

npm i https://pkg.pr.new/@arkenv/build@1248

@arkenv/bun-plugin

npm i https://pkg.pr.new/@arkenv/bun-plugin@1248

@arkenv/cli

npm i https://pkg.pr.new/@arkenv/cli@1248

@arkenv/fumadocs-ui

npm i https://pkg.pr.new/@arkenv/fumadocs-ui@1248

@arkenv/nextjs

npm i https://pkg.pr.new/@arkenv/nextjs@1248

@arkenv/nuxt

npm i https://pkg.pr.new/@arkenv/nuxt@1248

@arkenv/vite-plugin

npm i https://pkg.pr.new/@arkenv/vite-plugin@1248

commit: 3330c83

@arkenv-bot

arkenv-bot Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

📦 Bundle Size Report

Package Size Limit Diff Status
@arkenv/nextjs 1.32 kB 2.93 kB 0.0%
@arkenv/nextjs/shared 1.15 kB 1.46 kB 0.0%
@arkenv/nextjs/server 1.21 kB 1.95 kB 0.0%
@arkenv/nextjs/client 1.21 kB 1.95 kB 0.0%
@arkenv/nextjs/config 3.46 kB 3.91 kB +0.6%

All size limits passed!

@arkenv-bot

arkenv-bot Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (Asia/Almaty)
arkenv Ready Ready Preview, Comment Jun 29 2026, 9:24 PM (Asia/Almaty)

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The new flat createEnv(schema, options) overload in @arkenv/nuxt declares an options.runtimeEnv field, but createEnvInternal never consumes it, so passing runtimeEnv silently does nothing. This is inconsistent with @arkenv/nextjs and is likely to mislead users migrating to the flat layout.

Reviewed changes — Nuxt flat-layout support and build-package extraction refactor.

  • Add a createEnv(schema, options) overload to @arkenv/nuxt (universal, server, client, and shared entry points) with flat-layout TypeScript inference.
  • Refactor @arkenv/build so extractKeys accepts a framework public prefix and detects both the legacy nested layout and the flat layout.
  • Update @arkenv/nextjs to use the shared @arkenv/build extraction logic instead of duplicating the parser.
  • Update the Nuxt module to recognize "flat" as a layout option and emit a one-time deprecation warning for "simple".
  • Add runtime and build-time extraction tests for the Nuxt flat layout.

ℹ️ Nitpicks

  • .changeset/nuxt-flat-layout.md bumps both packages as patch, but the changeset adds a new public API (createEnv(schema, options) and a new module layout option). Under semantic-versioning conventions that usually warrants minor.
  • packages/nuxt/src/type-regression.test-d.ts only exercises the legacy createEnv({ server, client, shared }) signature; consider adding type-level coverage for the new flat overload so inference regressions are caught by pnpm --filter @arkenv/nuxt typecheck.

Note: 1 inline comment(s) dropped because they did not anchor to lines inside the PR diff:

  • packages/nuxt/src/type-regression.test-d.ts:88 (RIGHT) — line 88 (RIGHT) is not inside a diff hunk

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

Comment thread packages/nuxt/src/index.ts

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — the new commits address the prior review feedback by wiring runtimeEnv through the Nuxt flat layout, adding flat type-regression coverage, and bumping the changeset severity.

  • Wired options.runtimeEnv into createEnvInternal for both legacy and flat layouts, with validation that every key exists in the schema.
  • Added runtime tests in packages/nuxt/src/index.test.ts verifying that runtimeEnv overrides process.env and rejects unknown keys.
  • Added a flat-layout type-regression test in packages/nuxt/src/type-regression.test-d.ts covering exposeToClient and runtimeEnv inference.
  • Bumped @arkenv/nuxt to minor in .changeset/nuxt-flat-layout.md.

Pullfrog  | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

Comment thread packages/build/src/index.ts
Comment thread packages/build/src/index.ts

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — the new commits refactor the shared build-time extraction parsers and tidy the changeset/comment wording.

  • Refactored @arkenv/build parsers to a regex token scannerextractCallArguments, extractBlock, parseBlockKeys, and extractArkenvBlock now share a single tokenizer that skips comments, strings, and template literals while matching braces/parens/brackets. @arkenv/nextjs and @arkenv/nuxt now delegate to extractKeys with their public prefixes (NEXT_PUBLIC_ / NUXT_PUBLIC_).
  • Switched the changeset severity to patch and updated the description to use "typesafe" instead of "type-safe".
  • Updated Nuxt strict entry points to pass strictLayout: "client" / "server" so the flat schema is interpreted as client-only/server-only in those dedicated entry points.
  • Standardized "typesafe" spelling in Nuxt entry-point JSDoc comments.

ℹ️ @arkenv/build extractors have no dedicated tests

The extraction logic is now the single implementation behind both Next.js and Nuxt codegen, but packages/build has no unit tests of its own. Both framework packages cover it indirectly through their config tests, and those pass. Adding focused tests for the token scanner directly in @arkenv/build would make future parser changes cheaper to validate and catch cross-framework edge cases earlier.

Pullfrog  | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — the latest commit cleans up lint-in-expression patterns in the shared parser and suppresses intentional deprecation warnings.

  • Refactored regex token-scanner loops in packages/build/src/index.ts to avoid assignment-in-expression patterns.
  • Added // biome-ignore lint/suspicious/noConsole annotations before deliberate dev-time deprecation warnings in packages/nuxt/src/create-env.ts and packages/nuxt/src/module.ts.

No new issues found; existing Nuxt/Next.js config and runtime tests pass, and @arkenv/nuxt typecheck passes.

Pullfrog  | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

@yamcodes
yamcodes merged commit be8034f into dev Jun 29, 2026
22 checks passed
@yamcodes
yamcodes deleted the 1242-featnuxt-core-api-flat-layout-support branch June 29, 2026 16:29
@arkenv-bot arkenv-bot Bot mentioned this pull request Jun 29, 2026
yamcodes pushed a commit that referenced this pull request Jun 29, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to dev, this PR will
be updated.


# Releases
## @arkenv/build@0.0.2

### Patch Changes

- #### Add flat layout support to `@arkenv/nuxt`
_[`#1248`](#1248)
[`be8034f`](be8034f)
[@yamcodes](https://github.com/yamcodes)_

Introduce flat layout schema support and typesafe `createEnv` signature
overloads to `@arkenv/nuxt`.

- Add `"flat"` layout mode to `ModuleOptions` and auto-detect it when a
single `env.ts` file is configured.
- Emit a deprecation warning in development when using the legacy
`"simple"` layout option.
- Expose flat `createEnv(schema, options)` overload with type inference
for `NUXT_PUBLIC_` prefixes, `NODE_ENV`, and custom `exposeToClient`
variables.
## @arkenv/nextjs@0.1.3

### Patch Changes

<details><summary>Updated 1 dependency</summary>

<small>


[`be8034f`](be8034f)

</small>

- `@arkenv/build@0.0.2`

</details>
## @arkenv/nuxt@0.0.2

### Patch Changes

- #### Add flat layout support to `@arkenv/nuxt`
_[`#1248`](#1248)
[`be8034f`](be8034f)
[@yamcodes](https://github.com/yamcodes)_

Introduce flat layout schema support and typesafe `createEnv` signature
overloads to `@arkenv/nuxt`.

- Add `"flat"` layout mode to `ModuleOptions` and auto-detect it when a
single `env.ts` file is configured.
- Emit a deprecation warning in development when using the legacy
`"simple"` layout option.
- Expose flat `createEnv(schema, options)` overload with type inference
for `NUXT_PUBLIC_` prefixes, `NODE_ENV`, and custom `exposeToClient`
variables.

<details><summary>Updated 1 dependency</summary>

<small>


[`be8034f`](be8034f)

</small>

- `@arkenv/build@0.0.2`

</details>

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

@arkenv/nextjs Issues or Pull Requests involving the Next.js integration for ArkEnv @arkenv/nuxt Issues or Pull Requests involving the Nuxt integration for ArkEnv docs Adds or changes documentation, or acts as documentation in and of itself enhancement New feature or improvement tests This issue or PR is about adding, removing or changing tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(nuxt): core API & flat layout support

1 participant