Move repeated types to @repo/types#544
Conversation
🦋 Changeset detectedLatest commit: 74f608f The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
|
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 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 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 (3)
WalkthroughThis PR consolidates repeated internal types (FilterByPrefix, InferType) into a centralized Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Possibly related PRs
Suggested labels
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 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 |
- 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>
commit: |
📦 Bundle Size Report
✅ All size limits passed! |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
examples/basic/package-lock.jsonis 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}: Prefertypeoverinterfacefor type definitions in TypeScript
Use TypeScript 5.1+ features when appropriate
Leverageconsttype 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 (noInferrableTypeserror)
Useas constwhere appropriate for immutable values (useAsConstAssertionerror)
Don't reassign function parameters (noParameterAssignerror)
Place default parameters last in function signatures (useDefaultParameterLasterror)
Always initialize enum values (useEnumInitializerserror)
Declare one variable per statement (useSingleVarDeclaratorerror)
Avoid unnecessary template literals (noUnusedTemplateLiteralerror)
PreferNumber.parseIntover globalparseInt(useNumberNamespaceerror)
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
UseArkEnvErrorfor environment variable validation errors
Provide clear, actionable error messages that include the variable name and expected type
**/*.{ts,tsx}: UsecreateEnv(schema)as the main function for validated environment objects, available as the default export
Use built-in validators (host, port, url, email) fromsrc/types.tswhen available instead of custom validation
UseArkEnvErrorfor 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.tspackages/vite-plugin/src/types.tspackages/internal/types/src/index.tspackages/vite-plugin/src/index.tspackages/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.tspackages/vite-plugin/src/types.tspackages/internal/types/src/index.tspackages/vite-plugin/src/index.tspackages/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.tspackages/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.tspackages/vite-plugin/src/index.tspackages/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.tspackages/vite-plugin/src/index.tspackages/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.tspackages/vite-plugin/src/index.tspackages/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.tspackages/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.tspackages/internal/types/src/index.tspackages/vite-plugin/src/index.ts.changeset/clever-phones-play.mdpackages/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.tspackages/vite-plugin/src/index.ts.changeset/clever-phones-play.mdpackages/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.tspackages/vite-plugin/src/index.tspackages/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.tspackages/vite-plugin/src/index.tspackages/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.tspackages/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.tspackages/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.tspackages/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.tspackages/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.tspackages/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.tspackages/vite-plugin/src/index.ts.changeset/clever-phones-play.mdpackages/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
FilterByPrefixavailable through the package's public API.packages/internal/types/src/filter-by-prefix.ts (1)
1-13: LGTM!The
FilterByPrefixtype 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
FilterByPrefixexport and its purpose for reuse across plugins.packages/vite-plugin/src/types.ts (2)
1-1: LGTM!The import correctly consolidates
FilterByPrefixandInferTypefrom the centralized@repo/typespackage, eliminating local type duplication.
45-48: LGTM!The
ImportMetaEnvAugmentedtype correctly uses the externally sourcedFilterByPrefixandInferType, 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
FilterByPrefixandInferTypefrom the centralized@repo/typespackage, consistent with the vite-plugin refactoring.
47-50: LGTM!The
ProcessEnvAugmentedtype 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
InferTypefrom the centralized@repo/typespackage.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
Deployment failed with the following error: Learn More: https://vercel.com/yamcodes?upgradeToPro=build-rate-limit |
|
@coderabbitai review - all good ? |
🧩 Analysis chain🏁 Script executed: Length of output: 7072 @yamcodes Yes, all good! ✅ The refactoring looks excellent: ✨ Type Centralization
🎯 Plugin Integration
📝 Documentation
🔒 No Breaking Changes
This successfully achieves the objectives from issue #543 and eliminates code duplication while maintaining a clean, reusable architecture. ✅ Actions performedReview triggered.
|
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>
InferTypeandFilterByPrefixwere duplicated across vite-plugin and bun-plugin. Consolidate to@repo/typesfor single source of truth.Changes
Created
FilterByPrefixin @repo/typesCleaned up vite-plugin
InferTypedefinition (already in @repo/types)ImportMetaEnvAugmentedexport (already in types.ts)FilterByPrefixfrom @repo/typesUpdated bun-plugin
FilterByPrefixfrom @repo/typesDesign
FilterByPrefixis generic without defaults. Plugin-specific types provide appropriate defaults:Original prompt
InferType(and any other repeated types) to@repo/types#543💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.