Skip to content

Support standard validator mode in Bun plugin#763

Merged
yamcodes merged 7 commits intomainfrom
762-make-bun-plugin-work-with-standard-validator-mode
Jan 21, 2026
Merged

Support standard validator mode in Bun plugin#763
yamcodes merged 7 commits intomainfrom
762-make-bun-plugin-work-with-standard-validator-mode

Conversation

@yamcodes
Copy link
Owner

@yamcodes yamcodes commented Jan 21, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Bun plugin now supports configurable validator modes, enabling use of standard schema libraries (Zod, Valibot) without requiring ArkType as a dependency.
  • Documentation

    • Updated installation and usage guidance to reflect that ArkType is optional when using standard validators; clarified default behavior and configuration options.

✏️ Tip: You can customize this high-level summary in your review settings.

- Design document for validator mode
- Proposal for validator mode support
- Specification of new requirements
- Tasks for implementation plan
@yamcodes yamcodes linked an issue Jan 21, 2026 that may be closed by this pull request
@changeset-bot
Copy link

changeset-bot bot commented Jan 21, 2026

🦋 Changeset detected

Latest commit: 273239f

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

This PR includes changesets to release 1 package
Name Type
@arkenv/bun-plugin 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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 21, 2026

Warning

Rate limit exceeded

@yamcodes has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 2 minutes and 10 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Walkthrough

This PR adds optional validator configuration support to the @arkenv/bun-plugin by accepting an ArkEnvConfig parameter in the arkenv factory function, propagating it through processEnvSchema to createEnv, enabling use of standard schema validators like Zod without requiring ArkType.

Changes

Cohort / File(s) Summary
Changeset & Release Documentation
.changeset/mighty-radios-walk.md
Documents the new optional ArkEnvConfig parameter for validator mode support in the Bun plugin.
Feature Implementation (Bun Plugin)
packages/bun-plugin/src/plugin.ts, packages/bun-plugin/src/utils.ts
Adds ArkEnvConfig as optional second parameter to arkenv factory function; propagates config through processEnvSchema to createEnv call with config merging behavior.
Feature Tests
packages/bun-plugin/src/plugin.test.ts
Adds mocked createEnv with spy verification; introduces test validating config passing and merged options to createEnv.
Feature Documentation & Specifications
apps/www/content/docs/bun-plugin/index.mdx, openspec/changes/bun-plugin-validator-mode/design.md, openspec/changes/bun-plugin-validator-mode/proposal.md, openspec/changes/bun-plugin-validator-mode/specs/bun-plugin/spec.md, openspec/changes/bun-plugin-validator-mode/tasks.md
Documents validator mode usage with Standard Schema libraries, design rationale, implementation specifications, and task breakdown; updates installation guidance and examples.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

Possibly related PRs

Suggested labels

@arkenv/bun-plugin, arkenv, tests

Poem

🐰 A hop and a skip through config we go,
Parameter passing, letting validators flow!
Zod and Valibot now find their way,
Standard schemas brighten the Bun plugin day! ✨
No more ArkType chains, just flexible cheer,
The plugin's evolution blooms crystal clear! 🌿

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding support for standard validator mode in the Bun plugin. It directly matches the primary objective across all modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the docs Improvements or additions to documentation label Jan 21, 2026
@yamcodes yamcodes marked this pull request as ready for review January 21, 2026 17:54
@github-actions github-actions bot added www Improvements or additions to arkenv.js.org tests This issue or PR is about adding, removing or changing tests labels Jan 21, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 21, 2026

Open in StackBlitz

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

commit: 273239f

@arkenv-bot
Copy link
Contributor

arkenv-bot bot commented Jan 21, 2026

📦 Bundle Size Report

Package Size Limit Diff Status
@arkenv/vite-plugin 1.56 kB 1.95 kB +0.6%
@arkenv/bun-plugin 2.03 kB 2.44 kB +1.0%

All size limits passed!

@arkenv-bot
Copy link
Contributor

arkenv-bot bot commented Jan 21, 2026

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

Project Deployment Review Updated (Asia/Almaty)
arkenv Ready Ready Preview, Comment Jan 21 2026, 11:48 PM (Asia/Almaty)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@openspec/changes/bun-plugin-validator-mode/proposal.md`:
- Around line 1-20: Update the proposal to follow openspec format by adding a
"Why" section that concisely states the motivation (support validator mode
without requiring ArkType), a "What Changes" section listing concrete
modifications (e.g., change arkenv() factory to accept optional ArkEnvConfig,
update processEnvSchema to accept/pass-through config, mention files
packages/bun-plugin and packages/bun-plugin/src/utils.ts) and mark any breaking
changes with explicit "BREAKING" labels, and an "Impact" section describing
who/what is affected (users removing arktype, downstream type inference via
InferType and dependency on vite-plugin-validator-mode); ensure each section is
clearly titled and scannable.

In `@openspec/changes/bun-plugin-validator-mode/tasks.md`:
- Around line 1-11: Convert the grouped, already-checked checklist into a
numbered, initially-unchecked checklist: replace the three section headings
("Core Implementation", "Documentation", "Verification") and their checked items
with a single numbered list where each task is an individual numbered "1. - [
]", "2. - [ ]" etc., preserving the exact task text (e.g., "Update
`@arkenv/bun-plugin` signature to `arkenv(schema, config?)`", "Update
`processEnvSchema` to accept and pass `config` to `createEnv`", "Add JSDoc
examples showing `validator: \"standard\"` usage", "Update plugin documentation
with Standard Schema examples", "Add test case for `validator: \"standard\"` in
Bun plugin tests", "Verify using a Zod schema in an example project with
`arktype` uninstalled"); ensure all boxes start unchecked (`[ ]`) so they can be
marked `[x]` as work completes.

In `@packages/bun-plugin/src/utils.ts`:
- Around line 9-18: processEnvSchema currently forces process.env by merging {
...config, env: process.env }, which ignores any ArkEnvConfig.env provided;
change the merge so createEnv receives the config's env when present and falls
back to process.env only if config.env is undefined (i.e., pass the same
{...config, env: config.env ?? process.env} behavior), keeping the existing
createEnv(options as any, ...) call and type assertion.

Comment on lines 1 to 20
# Proposal: Support Validator Mode in Bun Plugin

## Problem
Currently, the `@arkenv/bun-plugin` does not allow users to specify a validator engine. It defaults to ArkType, which causes a crash if the user removes `arktype` from their project and tries to use Standard Schema validators (e.g., Zod, Valibot). This prevents the "validator" mode from being truly usable in Bun projects.

## Solution
1. Update the `@arkenv/bun-plugin` factory function to accept an optional `ArkEnvConfig` object as a second argument.
2. In the plugin's `processEnvSchema` utility, pass this configuration to the `createEnv` call.
3. Leverage the existing `InferType` improvements (from `vite-plugin-validator-mode`) to ensure proper type inference for Standard Schema validators.

## Scope
- `packages/bun-plugin`: Update `arkenv()` plugin factory signature and implementation.
- `packages/bun-plugin/src/utils.ts`: Update `processEnvSchema` to accept and pass through config.

## Alternatives Considered
- **Refactoring the Entire Plugin**: Not necessary; a surgical addition of the second argument is sufficient, mirroring the Vite plugin approach.
- **Requiring ArkType always**: This contradicts the goal of supporting Standard Schema as an alternative.

## Dependencies
- Requires `vite-plugin-validator-mode` to be complete (for `InferType` and `ArkEnvConfig` export).
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add required Why, What Changes (with BREAKING markers), and Impact sections.
The proposal format does not follow the required openspec structure. Please restructure accordingly so it’s compliant and scannable.

As per coding guidelines, proposal.md must include Why, What Changes (with BREAKING markers), and Impact sections.

🤖 Prompt for AI Agents
In `@openspec/changes/bun-plugin-validator-mode/proposal.md` around lines 1 - 20,
Update the proposal to follow openspec format by adding a "Why" section that
concisely states the motivation (support validator mode without requiring
ArkType), a "What Changes" section listing concrete modifications (e.g., change
arkenv() factory to accept optional ArkEnvConfig, update processEnvSchema to
accept/pass-through config, mention files packages/bun-plugin and
packages/bun-plugin/src/utils.ts) and mark any breaking changes with explicit
"BREAKING" labels, and an "Impact" section describing who/what is affected
(users removing arktype, downstream type inference via InferType and dependency
on vite-plugin-validator-mode); ensure each section is clearly titled and
scannable.

Comment on lines 1 to 11
# Tasks: Bun Plugin Validator Mode Support

- [x] **Core Implementation**
- [x] Update `@arkenv/bun-plugin` signature to `arkenv(schema, config?)`.
- [x] Update `processEnvSchema` to accept and pass `config` to `createEnv`.
- [x] **Documentation**
- [x] Add JSDoc examples showing `validator: "standard"` usage.
- [x] Update plugin documentation with Standard Schema examples.
- [x] **Verification**
- [x] Add test case for `validator: "standard"` in Bun plugin tests.
- [x] Verify using a Zod schema in an example project with `arktype` uninstalled.
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Align tasks checklist with required numbered, initially-unchecked format.
The tasks list is grouped and already checked. Please convert to numbered checklist items and keep them unchecked initially, updating to [x] as work completes.

As per coding guidelines and based on learnings, tasks.md should use numbered - [ ] items and start unchecked.

🤖 Prompt for AI Agents
In `@openspec/changes/bun-plugin-validator-mode/tasks.md` around lines 1 - 11,
Convert the grouped, already-checked checklist into a numbered,
initially-unchecked checklist: replace the three section headings ("Core
Implementation", "Documentation", "Verification") and their checked items with a
single numbered list where each task is an individual numbered "1. - [ ]", "2. -
[ ]" etc., preserving the exact task text (e.g., "Update `@arkenv/bun-plugin`
signature to `arkenv(schema, config?)`", "Update `processEnvSchema` to accept
and pass `config` to `createEnv`", "Add JSDoc examples showing `validator:
\"standard\"` usage", "Update plugin documentation with Standard Schema
examples", "Add test case for `validator: \"standard\"` in Bun plugin tests",
"Verify using a Zod schema in an example project with `arktype` uninstalled");
ensure all boxes start unchecked (`[ ]`) so they can be marked `[x]` as work
completes.

- Allow `config.env` to override `process.env`
- Update proposal document for validator mode
- Simplify task list for implementation
- Handles cases where arkenvConfig.env is undefined
- Falls back to loadEnv when env is missing
@github-actions github-actions bot added the @arkenv/vite-plugin Issues or Pull Requests involving the Vite plugin for ArkEnv label Jan 21, 2026
@yamcodes yamcodes merged commit 06de0ef into main Jan 21, 2026
18 checks passed
@yamcodes yamcodes deleted the 762-make-bun-plugin-work-with-standard-validator-mode branch January 21, 2026 18:47
@arkenv-bot arkenv-bot bot mentioned this pull request Jan 21, 2026
yamcodes pushed a commit that referenced this pull request Jan 21, 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 main, this PR will
be updated.


# Releases
## arkenv@0.9.1

### Patch Changes

- #### Fix Standard Schema type inference
_[`#758`](#758)
[`3b747b0`](3b747b0)
[@yamcodes](https://github.com/yamcodes)_

Fixed type inference when using `validator: "standard"` mode. The `env`
object now correctly infers types from Standard Schema validators like
Zod or Valibot.

## @arkenv/bun-plugin@0.1.1

### Patch Changes

- #### Support configuration
_[`#763`](#763)
[`06de0ef`](06de0ef)
[@yamcodes](https://github.com/yamcodes)_

Add support for an optional configuration object as the second argument.
This allows you to set the `validator` mode to `"standard"`, enabling
support for libraries like Zod or Valibot without an ArkType dependency.

    ```ts
    import { z } from "zod";
    import arkenv from "@arkenv/bun-plugin";

    arkenv(
      {
        BUN_PUBLIC_API_URL: z.string().url(),
      },
      {
        validator: "standard",
      }
    );
    ```

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

<small>


[`3b747b0`](3b747b0)

</small>

-   `arkenv@0.9.1`

</details>

## @arkenv/vite-plugin@0.0.28

### Patch Changes

- #### Support configuration
_[`bb832b1`](bb832b1)
[@yamcodes](https://github.com/yamcodes)_

Add support for an optional configuration object as the second argument.
This allows you to set the `validator` mode to `"standard"`, enabling
support for libraries like Zod or Valibot without an ArkType dependency.

    ```ts
    import { z } from "zod";
    import arkenvVitePlugin from "@arkenv/vite-plugin";

    arkenvVitePlugin(
      {
        VITE_API_URL: z.string().url(),
      },
      {
        validator: "standard",
      }
    );
    ```

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

<small>


[`3b747b0`](3b747b0)

</small>

-   `arkenv@0.9.1`

</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/vite-plugin Issues or Pull Requests involving the Vite plugin for ArkEnv docs Improvements or additions to documentation tests This issue or PR is about adding, removing or changing tests www Improvements or additions to arkenv.js.org

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make Bun plugin work with standard validator mode

1 participant