Conversation
…ing and improved plugin usage - Updated Vite configuration to utilize `loadEnv` for environment variable management. - Refactored plugin imports and initialization for better clarity and structure. - Ensured server port is dynamically set based on environment variables.
|
| Name | Type |
|---|---|
| @arkenv/vite-plugin | Patch |
| arkenv | Patch |
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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded@yamcodes has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 4 minutes and 48 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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. 📒 Files selected for processing (7)
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughReorganizes documentation under /docs/arkenv, adds a Vite plugin/docs section and examples for using ArkEnv inside vite.config.ts with shared type() schemas, renames schema identifiers from envSchema → Env across examples/tests, adds middleware and redirects for docs paths, and updates tests and dependencies accordingly. Changes
Sequence Diagram(s)sequenceDiagram
participant Vite as Vite
participant Config as vite.config.ts
participant LoadEnv as loadEnv()
participant ArkEnv as arkenv(Env,...)
participant Plugin as `@arkenv/vite-plugin`
Vite->>Config: invoke with {mode}
Config->>LoadEnv: loadEnv(mode, cwd, "")
LoadEnv-->>Config: raw env map
Config->>ArkEnv: arkenv(Env, raw env)
ArkEnv-->>Config: validated/typed env
Config->>Vite: return config (server.port ← env.PORT) + plugins
Vite->>Plugin: plugin initialized with Env (validates VITE_* for client)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related issues
Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
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. Comment |
- Updated various dependencies in `package.json` to their latest versions, including `@sentry/nextjs`, `vite`, and `@vitejs/plugin-react`. - Enhanced test setup by refining console error and warning suppression methods for better clarity and maintainability. - Adjusted configurations to support new features and improvements in the updated dependencies.
- Introduced a new requirement ensuring that the environment object returned from `loadEnv` or any wrapper is type-safe. - Specified that unsafe patterns bypassing validation or type checking are forbidden. - Documented scenarios to prevent unsafe usage and emphasized the need for proper typing or wrapping of the environment object. - Updated existing documentation to explicitly forbid unsafe usage patterns in Vite config examples.
- Defined the environment variable schema using ArkType's `type()` function outside of `defineConfig` for reuse in both `loadEnv` and plugin contexts. - Updated `createEnv` to accept both raw schema objects and type definitions, improving type inference and validation. - Modified Vite plugin to utilize the new schema structure, ensuring type safety and reducing code duplication. - Enhanced documentation to reflect the new schema usage and type safety requirements for Vite configuration.
📦 Bundle Size Report
✅ All size limits passed! |
commit: |
… handling - Updated dependencies in pnpm-lock.yaml, including rolldown-vite to version 7.2.7 and added @arkenv/vite-plugin. - Refactored Vite configuration to use consistent naming for plugins and improved environment variable handling. - Introduced middleware in the Next.js application to manage documentation routing and added redirects for better user experience. - Enhanced documentation with new guides for ArkEnv integration and usage examples. This commit enhances type safety and usability across the project, ensuring a smoother development experience.
…mentation updates - Added tests for `createEnv` to validate type definitions, type inference, schema reuse, and error handling. - Updated `packages/arkenv/README.md` to include a link to the Vite plugin documentation for better guidance on usage. - Created a new documentation page `arkenv-in-viteconfig.mdx` detailing the integration of ArkEnv in Vite configurations, including examples and distinctions between server-only and client-exposed environment variables. This commit improves the robustness of the ArkEnv integration with Vite and enhances the clarity of documentation for users.
…nv and Vite integration - Deleted the design document outlining the context, goals, decisions, and implementation details for integrating ArkEnv with Vite. - Removed the proposal document detailing the rationale, architectural challenges, and potential solutions for using ArkEnv with unprefixed environment variables in Vite. - Cleared out the tasks document that tracked the evaluation, implementation, documentation, and testing of the integration. - Eliminated the specs document that defined requirements and scenarios for using ArkEnv in Vite config files. This commit cleans up obsolete documentation related to the ArkEnv and Vite integration, streamlining the project structure.
- Marked validation tasks as complete, confirming successful spec validation and example functionality. - Added details on the successful Vite playground build and type checking for `arkenv` and `vite-plugin` packages. - Created a new documentation page explaining Vite's environment loading behavior and providing clear examples of config vs client variables. This commit enhances the documentation clarity and ensures all validation steps are thoroughly addressed.
- Added an important note in the Vite configuration documentation emphasizing the necessity of installing the core `arkenv` package. - Updated links to the ArkEnv documentation across multiple README files to direct users to the correct page for better navigation. This commit enhances user guidance and ensures clarity in the integration process.
- Added an important note highlighting the requirement to install the core `arkenv` package for proper functionality. - Removed redundant note to streamline the documentation. This commit improves clarity and ensures users are aware of necessary dependencies for using ArkEnv in Vite configurations.
- Modified test cases in `quickstart.test.ts` to update integration links for VSCode, JetBrains, and environment variables guide to point to the new ArkEnv paths. - Ensured that the expected URLs in the tests align with the updated documentation structure. This commit enhances the accuracy of the Quickstart tests, ensuring they reflect the latest documentation changes for ArkEnv.
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (5)
packages/arkenv/README.md (2)
63-63: Update Features section to acknowledge Vite support.The Features section states "Works in Node.js and Bun," but the header badges include Vite and the Plugins section (line 120) emphasizes the Vite plugin. Given the PR's focus on Vite config integration, update this to mention Vite support or link to the Vite example.
Based on learnings, runtime support documentation should link to specific examples: Node.js (examples/basic), Bun (examples/with-bun), and Vite (examples/with-vite-react-ts). Please verify the Vite example path exists and update accordingly.
116-116: Add Vite example link to Requirements section.The Requirements section links to Node.js and Bun examples but omits the Vite example. Given the PR's emphasis on Vite integration and the retrieved learning that documentation should link to specific examples, this should include a link to the Vite example as well.
Consider updating this line to:
- Tested on [Node.js **LTS** and **Current**](https://github.com/yamcodes/arkenv/tree/main/examples/basic), [Bun **1.2**](https://github.com/yamcodes/arkenv/tree/main/examples/with-bun), and [Vite](https://github.com/yamcodes/arkenv/tree/main/examples/with-vite-react-ts). Older versions may work but are not officially supported.Please verify the Vite example path and confirm this update aligns with the documentation strategy.
packages/vite-plugin/README.md (1)
20-52: Installation section looks good, but consider enhancing examples reference per project learnings.The installation instructions are comprehensive and cover all major package managers. However, based on learnings from a related PR, runtime support documentation should link to specific examples. Consider adding a reference to the Vite example (e.g.,
examples/with-vite-react-ts) alongside the playground link.You could enhance the documentation by adding an examples section like:
## Quick Start See [examples/with-vite-react-ts](https://github.com/yamcodes/arkenv/tree/main/examples/with-vite-react-ts) for a complete working example.tooling/playwright-www/tests/quickstart.test.ts (1)
145-145: Path updates and improved navigation handling.The updated path correctly reflects the new documentation structure. The explicit
waitForURLwith wildcard pattern and timeout (lines 151-156) is a good defensive practice for handling navigation timing.Consider applying consistent navigation pattern:
For consistency and reliability, consider applying the same explicit
waitForURLpattern to the integration links tests (lines 98-99, 111-112):await vscodeLink.click(); +await page.waitForURL( + "**/docs/arkenv/integrations/vscode", + { timeout: 10000 } +); await expect(page).toHaveURL("/docs/arkenv/integrations/vscode");This would make all navigation tests handle timing consistently, though the current approach may already be sufficient if those navigations are faster.
Also applies to: 151-159
openspec/specs/vite-config-usage/spec.md (1)
3-4: Update the Purpose section.The Purpose section contains placeholder text indicating it was created during archiving and needs updating.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (12)
apps/www/content/docs/vite-plugin/arkenv-in-viteconfig.mdx(1 hunks)examples/basic/README.md(1 hunks)examples/with-bun/README.md(1 hunks)openspec/changes/archive/2025-11-20-add-arkenv-vite-config/design.md(1 hunks)openspec/changes/archive/2025-11-20-add-arkenv-vite-config/proposal.md(1 hunks)openspec/changes/archive/2025-11-20-add-arkenv-vite-config/specs/vite-config-usage/spec.md(1 hunks)openspec/changes/archive/2025-11-20-add-arkenv-vite-config/tasks.md(1 hunks)openspec/specs/vite-config-usage/spec.md(1 hunks)packages/arkenv/README.md(1 hunks)packages/arkenv/src/create-env.test.ts(1 hunks)packages/vite-plugin/README.md(1 hunks)tooling/playwright-www/tests/quickstart.test.ts(2 hunks)
✅ Files skipped from review due to trivial changes (3)
- openspec/changes/archive/2025-11-20-add-arkenv-vite-config/design.md
- openspec/changes/archive/2025-11-20-add-arkenv-vite-config/proposal.md
- examples/with-bun/README.md
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/www/content/docs/vite-plugin/arkenv-in-viteconfig.mdx
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: yamcodes
Repo: yamcodes/arkenv PR: 132
File: packages/arkenv/README.md:13-14
Timestamp: 2025-09-09T17:37:19.650Z
Learning: For yamcodes/arkenv project: Runtime support documentation should link to specific examples: Node.js (examples/basic), Bun (examples/with-bun), Vite (examples/with-vite-react-ts).
📚 Learning: 2025-09-09T17:37:19.650Z
Learnt from: yamcodes
Repo: yamcodes/arkenv PR: 132
File: packages/arkenv/README.md:13-14
Timestamp: 2025-09-09T17:37:19.650Z
Learning: For yamcodes/arkenv project: Runtime support documentation should link to specific examples: Node.js (examples/basic), Bun (examples/with-bun), Vite (examples/with-vite-react-ts).
Applied to files:
examples/basic/README.mdopenspec/changes/archive/2025-11-20-add-arkenv-vite-config/tasks.mdpackages/vite-plugin/README.mdpackages/arkenv/README.mdtooling/playwright-www/tests/quickstart.test.tsopenspec/specs/vite-config-usage/spec.mdopenspec/changes/archive/2025-11-20-add-arkenv-vite-config/specs/vite-config-usage/spec.md
📚 Learning: 2025-09-10T19:35:18.179Z
Learnt from: yamcodes
Repo: yamcodes/arkenv PR: 136
File: .changeset/vast-bananas-win.md:2-3
Timestamp: 2025-09-10T19:35:18.179Z
Learning: The arkenv package is currently in v0.x.x (pre-1.0) development phase, where breaking changes are acceptable in minor version bumps according to semantic versioning conventions.
Applied to files:
examples/basic/README.md
🧬 Code graph analysis (3)
openspec/changes/archive/2025-11-20-add-arkenv-vite-config/tasks.md (5)
packages/vite-plugin/src/index.test.ts (6)
config(39-75)mockTransformedEnv(135-182)mockCreateEnv(102-133)mockTransformedEnv(261-304)pluginInstance(95-100)mockCreateEnv(232-259)packages/arkenv/src/index.test.ts (1)
vi(65-81)packages/arkenv/src/error.integration.test.ts (1)
it(15-183)packages/vite-plugin/src/index.ts (1)
arkenv(15-36)packages/arkenv/src/custom-types.integration.test.ts (1)
it(190-224)
packages/arkenv/src/create-env.test.ts (4)
packages/arkenv/src/type.ts (1)
type(3-3)packages/arkenv/src/create-env.ts (1)
createEnv(47-65)packages/arkenv/src/types.ts (1)
port(6-14)packages/arkenv/src/custom-types.integration.test.ts (2)
it(128-188)it(190-224)
openspec/changes/archive/2025-11-20-add-arkenv-vite-config/specs/vite-config-usage/spec.md (4)
packages/arkenv/src/type.test.ts (5)
envType(86-108)envType(29-47)envType(202-217)envType(171-190)envType(5-9)packages/arkenv/src/create-env.ts (1)
createEnv(47-65)packages/vite-plugin/src/index.test.ts (1)
config(39-75)packages/vite-plugin/src/index.ts (1)
arkenv(15-36)
🪛 LanguageTool
openspec/specs/vite-config-usage/spec.md
[style] ~36-~36: This phrase is redundant. Consider using “outside”.
Context: ...nction (not as a raw object) and placed outside of defineConfig to enable reuse in both ...
(OUTSIDE_OF)
openspec/changes/archive/2025-11-20-add-arkenv-vite-config/specs/vite-config-usage/spec.md
[style] ~33-~33: This phrase is redundant. Consider using “outside”.
Context: ...nction (not as a raw object) and placed outside of defineConfig to enable reuse in both ...
(OUTSIDE_OF)
🪛 markdownlint-cli2 (0.18.1)
packages/vite-plugin/README.md
9-9: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3
(MD001, heading-increment)
🔇 Additional comments (6)
tooling/playwright-www/tests/quickstart.test.ts (1)
94-94: Path updates look correct.The updated paths correctly reflect the new documentation structure under
/docs/arkenv/integrations/. The test logic remains sound.Also applies to: 99-99, 107-107, 112-112
openspec/changes/archive/2025-11-20-add-arkenv-vite-config/specs/vite-config-usage/spec.md (1)
1-90: Comprehensive and well-structured specification.The specification clearly defines requirements for using ArkEnv in Vite config files, including:
- Type-safe validation with
type()definitions- Schema reuse between loadEnv and the Vite plugin
- Clear forbidden patterns to prevent type-safety bypasses
- Proper error handling expectations
The distinction between server-only config variables and client-exposed
VITE_*variables is well-documented.Note: The static analysis hint about "outside of" being redundant is a false positive—"placed outside of
defineConfig" is clear and idiomatic in this context.packages/arkenv/src/create-env.test.ts (1)
113-189: Comprehensive test coverage for type definitions—consider naming consistency.The new test suite thoroughly validates:
- Type definition acceptance via
type()- Correct type inference and value coercion
- Schema reuse across multiple
createEnvinvocations- Error handling for invalid type definitions
- Custom environment integration
However, the tests use
envSchemaas the variable name (lines 118, 133, 151, 166, 174), while the PR summary indicates a broader effort to rename schema variables fromenvSchematoEnvacross the codebase. While these are local test variables, consider usingEnvfor consistency with the naming convention established elsewhere in this PR.Would you like to align the test variable naming with the
Envconvention used in other parts of this PR?openspec/specs/vite-config-usage/spec.md (1)
6-93: Well-structured specification—approved.This specification document provides clear, comprehensive requirements for ArkEnv integration with Vite config files. The requirements properly cover:
- Type-safe environment validation patterns
- Schema reuse strategies
- Error handling expectations
- Forbidden unsafe patterns
The scenarios effectively illustrate the expected behavior and constraints.
Note: The static analysis hint flagging "outside of" is a false positive.
openspec/changes/archive/2025-11-20-add-arkenv-vite-config/tasks.md (1)
1-73: Thorough task completion documentation.This checklist provides excellent tracking of the implementation work, including:
- Solution evaluation with clear choice documentation
- Implementation details for
createEnvand Vite plugin updates- Test coverage verification
- Documentation and example updates
- Validation steps
The notes clarify that no separate
loadEnvwrapper was needed sincecreateEnvaccepts type definitions directly, which simplifies the API surface.examples/basic/README.md (1)
76-76: Link update aligns with docs reorganization.The change at line 76 correctly updates the "Next steps" link to point to the reorganized
/docs/arkenvstructure, consistent with the PR's documentation reorganization objective.
…iles - Corrected links in the `README.md` files for the basic and with-bun examples to point to the updated ArkEnv documentation. - Adjusted the heading level in the Vite plugin documentation for consistency. This commit ensures that users have accurate navigation paths for environment variable setup and improves the overall documentation structure.
- Modified the test case in `docs-navigation.test.ts` to update the navigation links from the homepage to the quickstart documentation, ensuring they point to the correct ArkEnv paths. - Adjusted expected URL checks to align with the updated documentation structure. This commit enhances the accuracy of the documentation navigation tests, ensuring they reflect the latest changes in the ArkEnv documentation.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
tooling/playwright-www/tests/docs-navigation.test.ts (1)
58-71: Updated quickstart navigation path looks correctUsing
a[href='/docs/arkenv/quickstart']and asserting navigation to/docs/arkenv/quickstartaligns this test with the new docs routing; the sequencing (visibility → click →waitForURL→toHaveURL) is solid and should be reliable across browsers.As a small polish, you could DRY the quickstart path into a constant and reuse it for the locator and both URL expectations in this file to avoid future drift if the path changes again, but this is optional.
packages/vite-plugin/README.md (2)
5-7: Consider using blank lines for spacing instead of<br/>tags.While
<br/>tags render correctly in HTML, standard markdown practice favors blank lines for paragraph spacing (consistent rendering across platforms and toolchains). This is a minor stylistic choice, but aligns better with markdown conventions.-<br/> -<br/> -<br/> +Also applies to: 11-12
9-9: Documentation link is present; consider also linking the specific Vite example application.The docs link (line 9) and playground link (line 62) are good, but per your documentation standards, explicitly linking
examples/with-vite-react-tsalongside the playground would help users find runnable reference code more directly.For example, you could update the Playground section:
## Playground +* [Vite + React + TypeScript Example](https://github.com/yamcodes/arkenv/tree/main/examples/with-vite-react-ts) * [vite-playground](https://github.com/yamcodes/arkenv/tree/main/apps/playgrounds/vite)Based on learnings from PR #132.
Also applies to: 62-62
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
examples/basic/README.md(2 hunks)examples/with-bun/README.md(2 hunks)packages/vite-plugin/README.md(1 hunks)tooling/playwright-www/tests/docs-navigation.test.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- examples/basic/README.md
- examples/with-bun/README.md
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: yamcodes
Repo: yamcodes/arkenv PR: 132
File: packages/arkenv/README.md:13-14
Timestamp: 2025-09-09T17:37:19.650Z
Learning: For yamcodes/arkenv project: Runtime support documentation should link to specific examples: Node.js (examples/basic), Bun (examples/with-bun), Vite (examples/with-vite-react-ts).
📚 Learning: 2025-09-09T17:37:19.650Z
Learnt from: yamcodes
Repo: yamcodes/arkenv PR: 132
File: packages/arkenv/README.md:13-14
Timestamp: 2025-09-09T17:37:19.650Z
Learning: For yamcodes/arkenv project: Runtime support documentation should link to specific examples: Node.js (examples/basic), Bun (examples/with-bun), Vite (examples/with-vite-react-ts).
Applied to files:
packages/vite-plugin/README.md
🧬 Code graph analysis (1)
tooling/playwright-www/tests/docs-navigation.test.ts (1)
tooling/playwright-www/tests/quickstart.test.ts (5)
page(36-42)page(88-114)page(18-34)page(158-165)page(53-66)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: test-e2e (a11y)
- GitHub Check: test-e2e (e2e)
🔇 Additional comments (2)
packages/vite-plugin/README.md (2)
9-9: Heading structure is now correct.The heading hierarchy (h1 → h2 for all top-level sections) follows markdown standards and resolves the previous increment issue. Good fix.
Also applies to: 14-14, 20-20, 54-54, 60-60, 64-64
20-52: Installation section restructuring is well-organized.The multi-package-manager approach with collapsible details and npm open by default is a solid UX improvement. All commands follow correct syntax for their respective tools (npm install, pnpm add, yarn add, bun add).
- Modified various test files to update URLs from the old `/docs` structure to the new `/docs/arkenv` paths, ensuring all tests point to the correct documentation. - Adjusted expected titles and navigation checks to align with the updated documentation structure. This commit enhances the accuracy of the tests, ensuring they reflect the latest changes in the ArkEnv documentation.
A natural continuation of #381
Summary by CodeRabbit
New Features
Documentation
Chores
✏️ Tip: You can customize this high-level summary in your review settings.