Skip to content

Move repeated types to @repo/types#544

Merged
yamcodes merged 10 commits into
mainfrom
copilot/move-infer-type-to-types
Dec 12, 2025
Merged

Move repeated types to @repo/types#544
yamcodes merged 10 commits into
mainfrom
copilot/move-infer-type-to-types

Conversation

Copilot AI commented Dec 12, 2025

Copy link
Copy Markdown
Contributor

InferType and FilterByPrefix were duplicated across vite-plugin and bun-plugin. Consolidate to @repo/types for single source of truth.

Changes

  • Created FilterByPrefix in @repo/types

    • Generic utility type for filtering environment variables by prefix
    • Previously duplicated in both plugins with plugin-specific defaults
  • Cleaned up vite-plugin

    • Removed duplicate InferType definition (already in @repo/types)
    • Removed duplicate ImportMetaEnvAugmented export (already in types.ts)
    • Import FilterByPrefix from @repo/types
  • Updated bun-plugin

    • Import FilterByPrefix from @repo/types

Design

FilterByPrefix is generic without defaults. Plugin-specific types provide appropriate defaults:

// @repo/types - generic, reusable
export type FilterByPrefix<T extends Record<string, unknown>, Prefix extends string>

// vite-plugin - applies VITE_ default
export type ImportMetaEnvAugmented<TSchema, Prefix = "VITE_"> = 
  FilterByPrefix<InferType<TSchema>, Prefix>

// bun-plugin - applies BUN_PUBLIC_ default  
export type ProcessEnvAugmented<TSchema, Prefix = "BUN_PUBLIC_"> = 
  FilterByPrefix<InferType<TSchema>, Prefix>
Original prompt

This section details on the original issue you should resolve

<issue_title>Move InferType (and any other repeated types) to @repo/types</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Summary by CodeRabbit

  • Refactor
    • Internal code organization improvements consolidating shared utilities across packages to reduce duplication and improve maintainability.

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

@changeset-bot

changeset-bot Bot commented Dec 12, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 74f608f

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

This PR includes changesets to release 3 packages
Name Type
@arkenv/vite-plugin Patch
@arkenv/bun-plugin Patch
@repo/types 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

@vercel

vercel Bot commented Dec 12, 2025

Copy link
Copy Markdown

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

Project Deployment Preview Comments Updated (UTC)
arkenv Ready Ready Preview Comment Dec 12, 2025 1:24pm

@coderabbitai

coderabbitai Bot commented Dec 12, 2025

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@yamcodes has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 21 minutes and 15 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 99db13f and 74f608f.

📒 Files selected for processing (3)
  • .changeset/clever-phones-play.md (1 hunks)
  • packages/internal/types/src/index.ts (1 hunks)
  • packages/vite-plugin/src/index.ts (1 hunks)

Walkthrough

This PR consolidates repeated internal types (FilterByPrefix, InferType) into a centralized @repo/types package and updates the Bun and Vite plugins to import them instead of defining them locally. Both plugins are refactored to reuse the shared core types.

Changes

Cohort / File(s) Summary
Type consolidation
packages/internal/types/src/filter-by-prefix.ts, packages/internal/types/src/index.ts
New module exports FilterByPrefix type to filter records by a string prefix using mapped types; re-exported from the types package public API.
Changesets
.changeset/clever-phones-play.md, .changeset/sunny-walls-flow.md
Patch changesets document the refactor and new FilterByPrefix export in @repo/types with no end-user visible changes.
Bun plugin type refactor
packages/bun-plugin/src/types.ts
Removed local FilterByPrefix definition and now imports it from @repo/types alongside InferType. ProcessEnvAugmented type signature preserved.
Vite plugin type refactor
packages/vite-plugin/src/index.ts, packages/vite-plugin/src/types.ts
Removed local InferType definition from index.ts and local FilterByPrefix definition from types.ts; both now imported from @repo/types. ImportMetaEnvAugmented remains exported.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Verify FilterByPrefix and InferType type definitions are compatible with their previous local implementations
  • Confirm all import paths are correctly updated across both plugins
  • Check that exported type signatures remain unchanged to avoid breaking changes

Possibly related PRs

  • Internal types package #419: Implements the same internal types consolidation pattern, moving shared types into @repo/types and updating plugins to import them.
  • Add Bun plugin #439: Adds the Bun plugin and its types; this PR updates the same ProcessEnvAugmented and type definitions modified there.
  • Infer the import.meta.env type #415: Modifies FilterByPrefix, InferType, and ImportMetaEnvAugmented helpers for the Vite plugin; this PR centralizes those same types.

Suggested labels

arkenv, @arkenv/bun-plugin

Poem

🐰 Types once scattered, now unite,
Shared across Bun and Vite's sight,
No duplication left behind,
One source of truth for types refined!

Pre-merge checks and finishing touches

✅ 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 accurately summarizes the main change: consolidating repeated types (InferType and FilterByPrefix) into the @repo/types package, which aligns with all modifications across vite-plugin, bun-plugin, and the types package.
Linked Issues check ✅ Passed The pull request fully addresses issue #543 by centralizing InferType and FilterByPrefix into @repo/types, removing duplicates from plugins, and allowing plugin-specific defaults for generic types.
Out of Scope Changes check ✅ Passed All changes are directly scoped to consolidating repeated types into @repo/types; no unrelated modifications or scope creep detected in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

- Created FilterByPrefix type in @repo/types
- Removed duplicate InferType from vite-plugin
- Removed duplicate ImportMetaEnvAugmented export from vite-plugin
- Updated vite-plugin and bun-plugin to import FilterByPrefix from @repo/types

Co-authored-by: yamcodes <2014360+yamcodes@users.noreply.github.com>
Copilot AI changed the title [WIP] Move InferType and repeated types to @repo/types Move repeated types to @repo/types Dec 12, 2025
Copilot AI requested a review from yamcodes December 12, 2025 12:58
@github-actions github-actions Bot added docs Adds or changes documentation, or acts as documentation in and of itself @arkenv/vite-plugin Issues or Pull Requests involving the Vite plugin for ArkEnv labels Dec 12, 2025
@pkg-pr-new

pkg-pr-new Bot commented Dec 12, 2025

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 74f608f

@arkenv-bot

arkenv-bot Bot commented Dec 12, 2025

Copy link
Copy Markdown
Contributor

📦 Bundle Size Report

Package Size Limit Diff Status
@arkenv/vite-plugin 887 B 2 kB 0.0%
@arkenv/bun-plugin 1.43 kB 2 kB 0.0%

All size limits passed!

@github-actions github-actions Bot added the example Issues or Pull Requests concerning at least one ArkEnv example. (Found in the `examples/` directory) label Dec 12, 2025
@yamcodes

Copy link
Copy Markdown
Owner

@coderabbitai review

@yamcodes
yamcodes marked this pull request as ready for review December 12, 2025 13:10
@coderabbitai

coderabbitai Bot commented Dec 12, 2025

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 434f0d6 and 99db13f.

⛔ Files ignored due to path filters (1)
  • examples/basic/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (7)
  • .changeset/clever-phones-play.md (1 hunks)
  • .changeset/sunny-walls-flow.md (1 hunks)
  • packages/bun-plugin/src/types.ts (1 hunks)
  • packages/internal/types/src/filter-by-prefix.ts (1 hunks)
  • packages/internal/types/src/index.ts (1 hunks)
  • packages/vite-plugin/src/index.ts (1 hunks)
  • packages/vite-plugin/src/types.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)

**/*.{ts,tsx}: Prefer type over interface for type definitions in TypeScript
Use TypeScript 5.1+ features when appropriate
Leverage const type parameters for better inference in TypeScript
Use JSDoc comments for public APIs
Use tabs for indentation (configured in Biome)
Use double quotes for strings (configured in Biome)
Organize imports automatically (Biome handles this)
Avoid explicit types when TypeScript can infer them (noInferrableTypes error)
Use as const where appropriate for immutable values (useAsConstAssertion error)
Don't reassign function parameters (noParameterAssign error)
Place default parameters last in function signatures (useDefaultParameterLast error)
Always initialize enum values (useEnumInitializers error)
Declare one variable per statement (useSingleVarDeclarator error)
Avoid unnecessary template literals (noUnusedTemplateLiteral error)
Prefer Number.parseInt over global parseInt (useNumberNamespace error)
Use kebab-case for TypeScript filenames (e.g., create-env.ts)
Use camelCase for function names (e.g., createEnv)
Use PascalCase for type names (e.g., ArkEnvError)
Use UPPER_SNAKE_CASE for environment variables and constants
Include examples in JSDoc comments when helpful for public APIs
Document complex type logic with JSDoc comments
Use ArkEnvError for environment variable validation errors
Provide clear, actionable error messages that include the variable name and expected type

**/*.{ts,tsx}: Use createEnv(schema) as the main function for validated environment objects, available as the default export
Use built-in validators (host, port, url, email) from src/types.ts when available instead of custom validation
Use ArkEnvError for environment variable errors, not generic errors
Environment schema definitions should use built-in validators, ArkType string literals, and support default values in the schema pattern
Use logical grouping for related environment variables in schemas
Use descriptive env...

Files:

  • packages/internal/types/src/filter-by-prefix.ts
  • packages/vite-plugin/src/types.ts
  • packages/internal/types/src/index.ts
  • packages/vite-plugin/src/index.ts
  • packages/bun-plugin/src/types.ts
**/*.{ts,tsx,json,md}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use Biome for linting and formatting instead of ESLint and Prettier

Files:

  • packages/internal/types/src/filter-by-prefix.ts
  • packages/vite-plugin/src/types.ts
  • packages/internal/types/src/index.ts
  • packages/vite-plugin/src/index.ts
  • packages/bun-plugin/src/types.ts
**/index.ts

📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)

Use barrel exports (index.ts) for package entry points

Files:

  • packages/internal/types/src/index.ts
  • packages/vite-plugin/src/index.ts
🧠 Learnings (23)
📓 Common learnings
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Leverage `const` type parameters for better inference in TypeScript
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's type inference for TypeScript types instead of manual type definitions
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Keep environment variable schemas readable and TypeScript-like using ArkType syntax

Applied to files:

  • packages/vite-plugin/src/types.ts
  • packages/vite-plugin/src/index.ts
  • packages/bun-plugin/src/types.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use ArkType's `type()` function to define schemas in environment variable definitions

Applied to files:

  • packages/vite-plugin/src/types.ts
  • packages/vite-plugin/src/index.ts
  • packages/bun-plugin/src/types.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: ArkType validates environment variables at runtime and TypeScript types are inferred from the schema definition

Applied to files:

  • packages/vite-plugin/src/types.ts
  • packages/vite-plugin/src/index.ts
  • packages/bun-plugin/src/types.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Use `ArkEnvError` for environment variable validation errors

Applied to files:

  • packages/vite-plugin/src/types.ts
  • packages/bun-plugin/src/types.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's type inference for TypeScript types instead of manual type definitions

Applied to files:

  • packages/vite-plugin/src/types.ts
  • packages/internal/types/src/index.ts
  • packages/vite-plugin/src/index.ts
  • .changeset/clever-phones-play.md
  • packages/bun-plugin/src/types.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's built-in types (e.g., `string.host`, `number.port`) where possible in environment schemas

Applied to files:

  • packages/vite-plugin/src/types.ts
  • packages/vite-plugin/src/index.ts
  • .changeset/clever-phones-play.md
  • packages/bun-plugin/src/types.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Convert ArkType validation errors to `ArkEnvError` for user-friendly error messages that include variable name and expected type

Applied to files:

  • packages/vite-plugin/src/types.ts
  • packages/vite-plugin/src/index.ts
  • packages/bun-plugin/src/types.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Environment schema definitions should use built-in validators, ArkType string literals, and support default values in the schema pattern

Applied to files:

  • packages/vite-plugin/src/types.ts
  • packages/vite-plugin/src/index.ts
  • packages/bun-plugin/src/types.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use `ArkEnvError` for environment variable errors, not generic errors

Applied to files:

  • packages/vite-plugin/src/types.ts
  • packages/bun-plugin/src/types.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use `createEnv(schema)` as the main function for validated environment objects, available as the default export

Applied to files:

  • packages/vite-plugin/src/types.ts
  • packages/vite-plugin/src/index.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Leverage `const` type parameters for better inference in TypeScript

Applied to files:

  • packages/internal/types/src/index.ts
  • packages/vite-plugin/src/index.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Prefer `type` over `interface` for type definitions in TypeScript

Applied to files:

  • packages/internal/types/src/index.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Avoid explicit types when TypeScript can infer them (`noInferrableTypes` error)

Applied to files:

  • packages/internal/types/src/index.ts
  • packages/vite-plugin/src/index.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/index.ts : Use barrel exports (`index.ts`) for package entry points

Applied to files:

  • packages/internal/types/src/index.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Use TypeScript 5.1+ features when appropriate

Applied to files:

  • packages/internal/types/src/index.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use the scoped `$` type system for custom types defined in `scope.ts`

Applied to files:

  • packages/internal/types/src/index.ts
  • packages/vite-plugin/src/index.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use union types for enums in ArkType schemas (e.g., `"'dev' | 'prod'"`) instead of separate enum definitions

Applied to files:

  • packages/internal/types/src/index.ts
  • packages/vite-plugin/src/index.ts
  • .changeset/clever-phones-play.md
  • packages/bun-plugin/src/types.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use TypeScript for the primary language throughout the project

Applied to files:

  • packages/internal/types/src/index.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Organize imports automatically (Biome handles this)

Applied to files:

  • packages/internal/types/src/index.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Document complex type logic with JSDoc comments

Applied to files:

  • packages/internal/types/src/index.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Use `as const` where appropriate for immutable values (`useAsConstAssertion` error)

Applied to files:

  • packages/internal/types/src/index.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/scope.ts : Define custom types in `scope.ts` using ArkType's scoped type system for reusability across schemas

Applied to files:

  • packages/vite-plugin/src/index.ts
🪛 LanguageTool
.changeset/clever-phones-play.md

[grammar] ~6-~6: Ensure spelling is correct
Context: ...v/bun-plugin": patch --- #### Internal refacoring to reduce type duplication Refactor th...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

⏰ 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 (e2e)
  • GitHub Check: test-e2e (a11y)
🔇 Additional comments (8)
packages/internal/types/src/index.ts (1)

8-8: LGTM!

The re-export correctly follows the established pattern and makes FilterByPrefix available through the package's public API.

packages/internal/types/src/filter-by-prefix.ts (1)

1-13: LGTM!

The FilterByPrefix type is well-implemented and properly documented. The mapped type with template literal keys correctly filters environment variables by prefix while preserving type safety.

.changeset/sunny-walls-flow.md (1)

1-7: LGTM!

The changeset accurately documents the new FilterByPrefix export and its purpose for reuse across plugins.

packages/vite-plugin/src/types.ts (2)

1-1: LGTM!

The import correctly consolidates FilterByPrefix and InferType from the centralized @repo/types package, eliminating local type duplication.


45-48: LGTM!

The ImportMetaEnvAugmented type correctly uses the externally sourced FilterByPrefix and InferType, maintaining the same public API while benefiting from the centralized type definitions.

packages/bun-plugin/src/types.ts (2)

1-1: LGTM!

The import correctly consolidates FilterByPrefix and InferType from the centralized @repo/types package, consistent with the vite-plugin refactoring.


47-50: LGTM!

The ProcessEnvAugmented type correctly uses the externally sourced types, maintaining the same public API with the "BUN_PUBLIC_" prefix default while eliminating duplication.

packages/vite-plugin/src/index.ts (1)

1-1: LGTM!

The import correctly brings in InferType from the centralized @repo/types package.

Comment thread .changeset/clever-phones-play.md Outdated
Comment thread packages/vite-plugin/src/index.ts Outdated
@github-actions github-actions Bot removed the example Issues or Pull Requests concerning at least one ArkEnv example. (Found in the `examples/` directory) label Dec 12, 2025
@yamcodes

Copy link
Copy Markdown
Owner

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Dec 12, 2025

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@vercel

vercel Bot commented Dec 12, 2025

Copy link
Copy Markdown

Deployment failed with the following error:

Resource is limited - try again in 7 hours (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/yamcodes?upgradeToPro=build-rate-limit

@yamcodes

Copy link
Copy Markdown
Owner

@coderabbitai review - all good ?

@coderabbitai

coderabbitai Bot commented Dec 12, 2025

Copy link
Copy Markdown
Contributor
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check the new FilterByPrefix type definition in @repo/types
cat packages/internal/types/src/filter-by-prefix.ts

echo -e "\n--- Index exports ---"
cat packages/internal/types/src/index.ts

echo -e "\n--- Vite plugin types ---"
cat packages/vite-plugin/src/types.ts

echo -e "\n--- Bun plugin types ---"
cat packages/bun-plugin/src/types.ts

echo -e "\n--- Vite plugin index (InferType usage) ---"
cat packages/vite-plugin/src/index.ts

Length of output: 7072


@yamcodes Yes, all good! ✅

The refactoring looks excellent:

Type Centralization

  • FilterByPrefix and InferType are now properly centralized in @repo/types
  • Clean generic design: FilterByPrefix has no default prefix, allowing each plugin to specify its own

🎯 Plugin Integration

  • Both vite-plugin and bun-plugin correctly import from @repo/types
  • Each applies appropriate defaults (VITE_ and BUN_PUBLIC_)
  • Public APIs (ImportMetaEnvAugmented, ProcessEnvAugmented) remain unchanged

📝 Documentation

  • Comprehensive JSDoc with template parameters
  • Helpful usage examples in both plugin types

🔒 No Breaking Changes

  • Public API signatures preserved
  • Type safety maintained throughout

This successfully achieves the objectives from issue #543 and eliminates code duplication while maintaining a clean, reusable architecture.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@yamcodes
yamcodes merged commit d4800f9 into main Dec 12, 2025
17 of 18 checks passed
@yamcodes
yamcodes deleted the copilot/move-infer-type-to-types branch December 12, 2025 13:29
@arkenv-bot arkenv-bot Bot mentioned this pull request Dec 12, 2025
yamcodes pushed a commit that referenced this pull request Dec 12, 2025
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/bun-plugin@0.0.4

### Patch Changes

- #### Internal refactoring to reduce type duplication
_[`#544`](#544)
[`d4800f9`](d4800f9)
[@copilot-swe-agent](https://github.com/apps/copilot-swe-agent)_

Refactor the plugins to re-use internal types like `FilterByPrefix` and
`InferType`, defined in the core internal types package.

    This should have no effect for the end-user.

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

<small>

</small>

-   `arkenv@0.7.8`

</details>

## @arkenv/vite-plugin@0.0.21

### Patch Changes

- #### Internal refactoring to reduce type duplication
_[`#544`](#544)
[`d4800f9`](d4800f9)
[@copilot-swe-agent](https://github.com/apps/copilot-swe-agent)_

Refactor the plugins to re-use internal types like `FilterByPrefix` and
`InferType`, defined in the core internal types package.

    This should have no effect for the end-user.

- #### Fix Vite types backwards compatibility
_[`9da6939`](9da6939)
[@yamcodes](https://github.com/yamcodes)_

Externalize `vite` to support all Vite versions by using the consumer's
installed types - even versions prior to what the plugin was built on.

    This includes support for Vite 6, 5, all the way back to Vite 2.

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

<small>

</small>

-   `arkenv@0.7.8`

</details>

## @repo/types@0.0.3

### Patch Changes

- #### Export `FilterByPrefix`
_[`#544`](#544)
[`d4800f9`](d4800f9)
[@copilot-swe-agent](https://github.com/apps/copilot-swe-agent)_

    This is a type that is reused by the Bun plugin and the Vite plugin.

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 Adds or changes documentation, or acts as documentation in and of itself

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move InferType (and any other repeated types) to @repo/types

2 participants