Skip to content

Improve plugin docs - #891

Merged
yamcodes merged 11 commits into
mainfrom
improve-plugin-docs
May 8, 2026
Merged

Improve plugin docs#891
yamcodes merged 11 commits into
mainfrom
improve-plugin-docs

Conversation

@yamcodes

@yamcodes yamcodes commented May 2, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Documentation

    • Reorganized Vite plugin docs into a Quickstart with clearer typing guidance and reordered pages
    • Improved Bun plugin docs with stepwise setup and a dedicated typing flow
    • Standardized “typesafety” terminology across guides
  • Improvements

    • Stronger editor typing for env access (better autocomplete and type checking)
    • Added JSX/TSX code-block support across docs and examples

@changeset-bot

changeset-bot Bot commented May 2, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 43dbe5c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@github-actions github-actions Bot added docs Adds or changes documentation, or acts as documentation in and of itself arkenv Changes to the `arkenv` npm package. @arkenv/vite-plugin Issues or Pull Requests involving the Vite plugin for ArkEnv example Issues or Pull Requests concerning at least one ArkEnv example. (Found in the `examples/` directory) www Improvements or additions to arkenv.js.org tests This issue or PR is about adding, removing or changing tests labels May 2, 2026
@coderabbitai

coderabbitai Bot commented May 2, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

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

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ 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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cb2342ca-e918-4828-b9f9-bd802380205b

📥 Commits

Reviewing files that changed from the base of the PR and between 0bd284b and 43dbe5c.

📒 Files selected for processing (4)
  • apps/www/content/docs/bun-plugin/index.mdx
  • apps/www/content/docs/vite-plugin/index.mdx
  • packages/bun-plugin/README.md
  • tooling/playwright-www/tests/utils/a11y.ts

Walkthrough

Standardizes wording to "typesafety", restructures Vite and Bun plugin docs into Quickstarts, adds interface ImportMeta { readonly env: ImportMetaEnv } augmentations in examples/playgrounds, expands MDX/twoslash support to tsx/jsx, and reorders Vite doc pages in meta.json.

Changes

Docs, typing, examples & site tooling

Layer / File(s) Summary
Type augmentation (data shape)
apps/playgrounds/vite/src/vite-env.d.ts, examples/with-vite-react/src/vite-env.d.ts
Adds interface ImportMeta { readonly env: ImportMetaEnv } so import.meta.env is typed.
Core docs & examples (content changes)
apps/www/content/docs/vite-plugin/index.mdx, apps/www/content/docs/vite-plugin/typing-import-meta-env.mdx, apps/www/content/docs/vite-plugin/arkenv-in-viteconfig.mdx, apps/www/content/docs/bun-plugin/index.mdx, apps/www/content/docs/bun-plugin/typing-process-env.mdx, apps/playgrounds/vite/README.md, examples/with-vite-react/README.md
Rewrites plugin pages into Quickstart flows, inserts typing snippets (including ImportMeta), adds "Add Typesafety" guidance, and normalizes wording from "Type Safety" → "Typesafety".
Site integration / tooling
apps/www/content/docs/vite-plugin/meta.json, apps/www/lib/twoslash-options.ts, apps/www/source.config.ts, apps/www/bin/twoslash-mdx.ts, apps/www/bin/twoslash-mdx.ts
Reorders Vite sidebar (typing-import-meta-env before arkenv-in-viteconfig); expands twoslash/MDX code-language support to include tsx/jsx; broadens twoslash extraction regex.
Narrative/specs/changelogs/tests (labels only)
openspec/**, packages/arkenv/CHANGELOG.md, packages/vite-plugin/CHANGELOG.md, packages/arkenv/src/standard-mode.test.ts
Normalizes phrasing "type safety" → "typesafety" across specs, proposals, changelogs, and a test description; no behavioral changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐇 I hopped through docs and fixed each line,

"typesafety" now reads crisp and fine.
ImportMeta dons its tidy vest,
Examples hum and docs look best—
A carrot for the docs, now shine!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Improve plugin docs' accurately reflects the primary change—a comprehensive documentation redesign for both Vite and Bun plugin guides, including improved quickstart flows, enhanced typing guidance, and better structural organization.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch improve-plugin-docs

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

@pkg-pr-new

pkg-pr-new Bot commented May 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/arkenv@891
npm i https://pkg.pr.new/@arkenv/bun-plugin@891
npm i https://pkg.pr.new/@arkenv/fumadocs-ui@891
npm i https://pkg.pr.new/@arkenv/vite-plugin@891

commit: 43dbe5c

@arkenv-bot

arkenv-bot Bot commented May 2, 2026

Copy link
Copy Markdown
Contributor

📦 Bundle Size Report

Package Size Limit Diff Status
arkenv 1.73 kB 1.95 kB 0.0%
arkenv/standard 1.01 kB 1.07 kB 0.0%
arkenv/core 441 B 500 B 0.0%
@arkenv/bun-plugin 2.4 kB 2.44 kB 0.0%
@arkenv/vite-plugin 1.91 kB 2.93 kB 0.0%

All size limits passed!

@arkenv-bot

arkenv-bot Bot commented May 2, 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 May 8 2026, 2:56 PM (Asia/Almaty)

@coderabbitai coderabbitai 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.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/www/content/docs/bun-plugin/index.mdx`:
- Around line 121-150: Add a short prerequisite note to this section stating
that external validators (e.g., Zod or Valibot) must be installed when used
alongside ArkType; specifically call out the imported symbol "z" from "zod" in
the src/env.ts example and provide a one-line install suggestion (e.g., install
zod or valibot) so readers don't get an unresolved-module error when copying the
snippet; update the prose around the code block mentioning the dependency and,
if helpful, list the package names "zod" and "valibot" as optional
prerequisites.

In `@apps/www/content/docs/vite-plugin/index.mdx`:
- Around line 87-106: Add a brief prerequisite note above the "Using Standard
Schema validators (Zod, Valibot)" example that calls out external validator
packages must be installed (e.g., zod or valibot) when using Standard Schema
validators; reference the example's import { z } from "zod" and the Env = type({
... }) usage so readers know to run npm/yarn install for those validator
packages before copying the vite.config.ts snippet.

In `@apps/www/lib/twoslash-options.ts`:
- Line 28: The CLI's MDX twoslash regex in apps/www/bin/twoslash-mdx.ts
currently only matches (ts|js) code blocks so newly added "tsx"/"jsx" blocks
from twoslash-options.ts won't be processed; update the regex (the
codeBlockRegex or equivalent constant used in twoslash-mdx.ts) to include tsx
and jsx (i.e. match ts|tsx|js|jsx) so the CLI path picks up those code fences
and captures their content the same way as ts/js blocks.

In `@openspec/changes/improve-plugin-docs/design.md`:
- Line 44: The doc mentions arkenvVitePlugin(Env) but the implemented docs use
arkenv(Env); update the reference in the design text to match the implemented
API by replacing arkenvVitePlugin(Env) with arkenv(Env) (or vice versa if you
intend to change the implementation) and ensure the example and any surrounding
text refer to the same symbol (arkenv(Env)) as used in
apps/www/content/docs/vite-plugin/index.mdx.

In `@openspec/changes/improve-plugin-docs/walkthrough.md`:
- Line 38: The walkthrough uses a different env key (VITE_MY_ENV) than the
examples (VITE_MY_VAR); update the walkthrough sentence that mentions export
const Env in the vite.config.ts / vite-env.d.ts snippet to use the same key name
as the examples (VITE_MY_VAR) so import.meta.env.VITE_MY_VAR is consistently
referenced across the walkthrough and example schema.
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1e6dbfcf-0618-4235-9d38-11cdb88f2457

📥 Commits

Reviewing files that changed from the base of the PR and between 7d70eea and 49f5978.

📒 Files selected for processing (28)
  • apps/playgrounds/vite/README.md
  • apps/playgrounds/vite/src/vite-env.d.ts
  • apps/www/content/docs/bun-plugin/index.mdx
  • apps/www/content/docs/bun-plugin/typing-process-env.mdx
  • apps/www/content/docs/vite-plugin/arkenv-in-viteconfig.mdx
  • apps/www/content/docs/vite-plugin/index.mdx
  • apps/www/content/docs/vite-plugin/meta.json
  • apps/www/content/docs/vite-plugin/typing-import-meta-env.mdx
  • apps/www/lib/twoslash-options.ts
  • apps/www/source.config.ts
  • examples/with-vite-react/README.md
  • openspec/changes/archive/2025-11-20-add-arkenv-vite-config/design.md
  • openspec/changes/archive/2025-11-20-add-arkenv-vite-config/proposal.md
  • openspec/changes/archive/2025-11-20-add-arkenv-vite-config/specs/vite-config-usage/spec.md
  • openspec/changes/archive/2025-11-20-add-arkenv-vite-config/tasks.md
  • openspec/changes/archive/2025-11-20-fix-vite-plugin-env-filter/design.md
  • openspec/changes/archive/2025-11-28-add-bun-plugin/design.md
  • openspec/changes/archive/2025-11-28-add-bun-plugin/proposal.md
  • openspec/changes/archive/2025-12-22-coercion-public-api/proposal.md
  • openspec/changes/archive/2026-01-21-fix-standard-mode-inference/proposal.md
  • openspec/changes/improve-plugin-docs/design.md
  • openspec/changes/improve-plugin-docs/proposal.md
  • openspec/changes/improve-plugin-docs/tasks.md
  • openspec/changes/improve-plugin-docs/walkthrough.md
  • openspec/specs/vite-config-usage/spec.md
  • packages/arkenv/CHANGELOG.md
  • packages/arkenv/src/standard-mode.test.ts
  • packages/vite-plugin/CHANGELOG.md

Comment thread apps/www/content/docs/bun-plugin/index.mdx
Comment thread apps/www/content/docs/vite-plugin/index.mdx
Comment thread apps/www/lib/twoslash-options.ts
Comment thread openspec/changes/improve-plugin-docs/design.md Outdated
Comment thread openspec/changes/improve-plugin-docs/walkthrough.md Outdated
@coderabbitai

coderabbitai Bot commented May 2, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 5 file(s) based on 5 unresolved review comments.

Files modified:

  • apps/www/bin/twoslash-mdx.ts
  • apps/www/content/docs/bun-plugin/index.mdx
  • apps/www/content/docs/vite-plugin/index.mdx
  • openspec/changes/improve-plugin-docs/design.md
  • openspec/changes/improve-plugin-docs/walkthrough.md

Commit: 7f807dc0c1b1af94d8b06b18763040a0c9e1cfb4

The changes have been pushed to the improve-plugin-docs branch.

Time taken: 7m 55s

coderabbitai Bot and others added 2 commits May 2, 2026 18:49
Fixed 5 file(s) based on 5 unresolved review comments.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
apps/www/bin/twoslash-mdx.ts (1)

17-18: ⚡ Quick win

Derive fence languages from shared Twoslash config to prevent drift.

This regex duplicates arktypeTwoslashOptions.langs; future updates can silently desync extraction vs processing. Build the alternation from the shared langs list instead.

♻️ Proposed refactor
-const codeBlockRegex =
-	/```(ts|tsx|js|jsx) twoslash(?:.*)\r?\n([\s\S]*?)\r?\n```/g;
+const escapedLangs = arktypeTwoslashOptions.langs
+	.map((lang) => lang.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))
+	.join("|");
+
+const codeBlockRegex = new RegExp(
+	"```(" + escapedLangs + ")\\s+twoslash(?:.*)\\r?\\n([\\s\\S]*?)\\r?\\n```",
+	"g",
+);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/www/bin/twoslash-mdx.ts` around lines 17 - 18, Replace the hard-coded
language alternation in the existing const codeBlockRegex with a RegExp built
from arktypeTwoslashOptions.langs: map and escape each lang (escape special
regex chars), join them with "|" to form the alternation, then construct a new
RegExp string that captures the language group and the twoslash code block body
(preserving the same capture groups and \r?\n handling) and instantiate it with
the "g" flag; overwrite the previous codeBlockRegex declaration so extraction
stays in sync with arktypeTwoslashOptions.langs.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/www/content/docs/vite-plugin/index.mdx`:
- Line 4: Update the description string at the top of the MDX (the line that
currently reads "The ArkEnv plugin for Vite lets you validate environment
variables at build-time with ArkEnv") to end with "with ArkType" instead of
"with ArkEnv" so it reads "The ArkEnv plugin for Vite lets you validate
environment variables at build-time with ArkType"; edit the description field in
the document (the same line shown in the diff) to replace the trailing "ArkEnv"
with "ArkType".
- Line 4: Update the description frontmatter in
apps/www/content/docs/vite-plugin/index.mdx: replace the trailing phrase "with
ArkEnv" with "with ArkType" so the sentence reads "The ArkEnv plugin for Vite
lets you validate environment variables at build-time with ArkType." Locate and
edit the description string in the file's frontmatter (the line starting with
description:) to make this one-word replacement.

---

Nitpick comments:
In `@apps/www/bin/twoslash-mdx.ts`:
- Around line 17-18: Replace the hard-coded language alternation in the existing
const codeBlockRegex with a RegExp built from arktypeTwoslashOptions.langs: map
and escape each lang (escape special regex chars), join them with "|" to form
the alternation, then construct a new RegExp string that captures the language
group and the twoslash code block body (preserving the same capture groups and
\r?\n handling) and instantiate it with the "g" flag; overwrite the previous
codeBlockRegex declaration so extraction stays in sync with
arktypeTwoslashOptions.langs.
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6c12d0b9-2578-457c-8e25-2a146913fa32

📥 Commits

Reviewing files that changed from the base of the PR and between 49f5978 and baa79a9.

⛔ Files ignored due to path filters (2)
  • examples/with-bun-react/bun.lock is excluded by !**/*.lock
  • examples/with-bun/bun.lock is excluded by !**/*.lock
📒 Files selected for processing (6)
  • apps/www/bin/twoslash-mdx.ts
  • apps/www/content/docs/bun-plugin/index.mdx
  • apps/www/content/docs/vite-plugin/index.mdx
  • examples/with-vite-react/src/vite-env.d.ts
  • openspec/changes/improve-plugin-docs/design.md
  • openspec/changes/improve-plugin-docs/walkthrough.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • openspec/changes/improve-plugin-docs/walkthrough.md
  • apps/www/content/docs/bun-plugin/index.mdx
  • openspec/changes/improve-plugin-docs/design.md

Comment thread apps/www/content/docs/vite-plugin/index.mdx Outdated
@coderabbitai

coderabbitai Bot commented May 2, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 1 file(s) based on 1 unresolved review comment.

Files modified:

  • apps/www/content/docs/vite-plugin/index.mdx

Commit: 8fdef603b555ba873cefda2bf532e574e4b8fd56

The changes have been pushed to the improve-plugin-docs branch.

Time taken: 4m 9s

coderabbitai Bot and others added 2 commits May 2, 2026 19:13
Fixed 1 file(s) based on 1 unresolved review comment.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/www/content/docs/vite-plugin/index.mdx (1)

132-137: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

"Static Analysis" feature description misleads about the plugin's actual role.

The documented claim that the plugin "Automatically replaces import.meta.env.VARIABLE with validated values during the build" overstates ArkEnv's responsibility. The plugin validates environment variables using its schema and configures Vite's define option to expose them. The actual replacement and inlining of values is Vite's standard behavior, not unique to ArkEnv. Reword the bullet to emphasize the plugin's core feature—validation against a schema—rather than the replacement mechanism, which Vite handles automatically.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/www/content/docs/vite-plugin/index.mdx` around lines 132 - 137, Update
the "Static Analysis" bullet to avoid claiming ArkEnv performs value
replacement; instead state that ArkEnv validates env vars against a schema and
configures Vite's define option to expose validated values, leaving the actual
inlining/replacement to Vite; specifically edit the bullet that mentions
`import.meta.env.VARIABLE` and reference ArkEnv and Vite's `define` behavior
(`define`) so the text emphasizes schema validation and configuration rather
than implying ArkEnv does the replacement.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/www/content/docs/vite-plugin/index.mdx`:
- Around line 7-16: Update the installation example in the package-install block
so it installs both the plugin and its peer dependency: change the current
package line that reads "@arkenv/vite-plugin arkenv" to explicitly include
"arktype" as well, ensuring users run a single install command that lists
arkenv/vite-plugin, arkenv, and arktype to avoid missing peer dependency import
errors.

---

Outside diff comments:
In `@apps/www/content/docs/vite-plugin/index.mdx`:
- Around line 132-137: Update the "Static Analysis" bullet to avoid claiming
ArkEnv performs value replacement; instead state that ArkEnv validates env vars
against a schema and configures Vite's define option to expose validated values,
leaving the actual inlining/replacement to Vite; specifically edit the bullet
that mentions `import.meta.env.VARIABLE` and reference ArkEnv and Vite's
`define` behavior (`define`) so the text emphasizes schema validation and
configuration rather than implying ArkEnv does the replacement.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 102ba14b-2dbb-4462-858b-091ad0aea84b

📥 Commits

Reviewing files that changed from the base of the PR and between baa79a9 and 0bd284b.

📒 Files selected for processing (1)
  • apps/www/content/docs/vite-plugin/index.mdx

Comment thread apps/www/content/docs/vite-plugin/index.mdx
@yamcodes
yamcodes merged commit 079df32 into main May 8, 2026
20 checks passed
@yamcodes
yamcodes deleted the improve-plugin-docs branch May 8, 2026 10:02
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 arkenv Changes to the `arkenv` npm package. docs Adds or changes documentation, or acts as documentation in and of itself example Issues or Pull Requests concerning at least one ArkEnv example. (Found in the `examples/` directory) 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.

1 participant