Skip to content

Internal types package#419

Merged
yamcodes merged 9 commits intomainfrom
416-internal-types-package
Nov 23, 2025
Merged

Internal types package#419
yamcodes merged 9 commits intomainfrom
416-internal-types-package

Conversation

@yamcodes
Copy link
Owner

@yamcodes yamcodes commented Nov 23, 2025

Closes #416

  • Introduced a public type helper for TypeScript projects to provide typesafe, autocompleted access to VITE_* environment variables.
  • Updated Vite plugin to expose schema-aware typings, allowing client environment types to be derived from the Env schema.
  • Added documentation on typing import.meta.env with ArkEnv schemas and improved clarity in Vite plugin documentation.

Summary by CodeRabbit

Release Notes

  • Chores
    • Updated arkenv dependency to version 0.7.6
    • Established internal shared types package infrastructure across workspace packages
    • Updated workspace configuration to include internal packages
    • Enhanced type resolution configuration for arkenv and vite-plugin packages
    • Added design and specification documentation for internal types architecture

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

- Introduced a public type helper for TypeScript projects to provide typesafe, autocompleted access to VITE_* environment variables.
- Updated Vite plugin to expose schema-aware typings, allowing client environment types to be derived from the Env schema.
- Added documentation on typing import.meta.env with ArkEnv schemas and improved clarity in Vite plugin documentation.
@yamcodes yamcodes linked an issue Nov 23, 2025 that may be closed by this pull request
@changeset-bot
Copy link

changeset-bot bot commented Nov 23, 2025

⚠️ No Changeset found

Latest commit: 1e3148d

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

@vercel
Copy link

vercel bot commented Nov 23, 2025

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

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
arkenv Skipped Skipped Nov 23, 2025 7:12pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 23, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

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

Walkthrough

This PR establishes a new internal types package (@repo/types) at packages/internal/types/ to centralize the InferType utility type. The InferType type is extracted from local definitions in packages/arkenv and packages/vite-plugin, replaced with imports from the new internal package. Build configurations and workspace settings are updated accordingly.

Changes

Cohort / File(s) Change Summary
New Internal Types Package
packages/internal/types/package.json, packages/internal/types/tsconfig.json, packages/internal/types/index.ts, packages/internal/types/infer-type.ts, packages/internal/types/README.md
Introduces a new internal, non-published types package with InferType<T> utility type. Includes type-checking configuration, package metadata (private: true), and documentation.
ArkEnv Type Migration
packages/arkenv/package.json, packages/arkenv/src/create-env.ts, packages/arkenv/tsdown.config.ts
Adds @repo/types as devDependency, replaces local InferType definition with import from internal types package, and updates tsdown config to resolve @repo/types.
Vite Plugin Type Migration
packages/vite-plugin/package.json, packages/vite-plugin/src/types.ts, packages/vite-plugin/tsdown.config.ts
Adds @repo/types as devDependency, replaces local InferType definition with import from internal types package, and updates tsdown config to resolve @repo/types.
Workspace Configuration
pnpm-workspace.yaml
Adds packages/internal/* glob pattern to include internal packages in workspace.
Design & Specification Documentation
openspec/changes/add-internal-types-package/design.md, openspec/changes/add-internal-types-package/proposal.md, openspec/changes/add-internal-types-package/specs/internal-types/spec.md, openspec/changes/add-internal-types-package/tasks.md
Adds design overview, proposal, specifications, and task documentation for the internal types package initiative.
Playground Dependency Update
apps/playgrounds/node/package.json
Updates arkenv dependency from workspace:* to 0.7.6.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Type extraction consistency: Verify that InferType definitions removed from arkenv and vite-plugin match the new centralized version in packages/internal/types/infer-type.ts
  • Build configuration: Confirm tsdown.config.ts updates in both packages correctly resolve the new @repo/types entry point
  • Workspace integration: Ensure pnpm-workspace.yaml changes don't unintentionally include/exclude other packages (note: apps/playgrounds/bun-react is now included)

Possibly related PRs

Suggested labels

example

Poem

🐰 Types once scattered, now they're home,
In @repo/types they safely roam,
No more duplication in the land,
One source of truth, forever planned! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes an out-of-scope change: updating apps/playgrounds/node/package.json to change arkenv dependency from 'workspace:*' to '0.7.6', which is unrelated to creating the internal types package. Remove the arkenv version bump in apps/playgrounds/node/package.json as it's outside the scope of the internal types package creation.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Internal types package' clearly and concisely summarizes the main change: introducing a new internal package for shared TypeScript types.
Linked Issues check ✅ Passed The PR successfully implements the objective from #416: creates an internal types package (packages/internal/types) exporting common types like InferType across the codebase.
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.

@github-actions github-actions bot added the docs Improvements or additions to documentation label Nov 23, 2025
@yamcodes yamcodes changed the title feat: enhance type safety for VITE_* environment variables Internal types package Nov 23, 2025
- Introduced a new internal types package located at `packages/internal/types/` to export common TypeScript types.
- Updated references to the new package name `@repo/types` in relevant files and documentation.
- Simplified package structure by removing unnecessary build steps, as it is a types-only package.
- Ensured that the package is not published to npm and is intended for internal use only within the monorepo.
- Added `@repo/types` dependency to `packages/arkenv` and `packages/vite-plugin` to utilize shared TypeScript types from the new internal types package.
- Updated relevant files to import `InferType` from `@repo/types`, removing duplicate type definitions in both packages.
- Modified `pnpm-workspace.yaml` to include the new internal types package and updated `.changeset/config.json` to ignore it during versioning.
@github-actions github-actions bot added arkenv Changes to the `arkenv` npm package. @arkenv/vite-plugin Issues or Pull Requests involving the Vite plugin for ArkEnv labels Nov 23, 2025
@arkenv-bot
Copy link
Contributor

arkenv-bot bot commented Nov 23, 2025

📦 Bundle Size Report

Package Size Limit Diff Status
@arkenv/vite-plugin 886 B 2 kB 0.0%
arkenv 729 B 2 kB 0.0%

All size limits passed!

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 23, 2025

Open in StackBlitz

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

commit: 1e3148d

@yamcodes yamcodes marked this pull request as ready for review November 23, 2025 17:43
- Removed `@repo/types` from the ignore list in `.changeset/config.json` to ensure it is included in versioning updates.
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 42 to 44
"dependencies": {
"@repo/types": "workspace:*"
},

Choose a reason for hiding this comment

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

P1 Badge Avoid depending on unpublished internal package

The arkenv package now declares @repo/types as a dependency. That package is marked private: true in packages/internal/types/package.json and is ignored from releases, so it will not be published to npm. Publishing arkenv with this dependency means any install outside the monorepo will attempt to resolve @repo/types from the registry and fail, breaking consumers’ installs and type-checking. Consider inlining the type or publishing a public types package instead.

Useful? React with 👍 / 👎.

Comment on lines 11 to 13
"dependencies": {
"@repo/types": "workspace:*",
"arkenv": "workspace:*"

Choose a reason for hiding this comment

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

P1 Badge Vite plugin now requires private workspace dependency

The Vite plugin adds a dependency on @repo/types, but that package is private and not published. When @arkenv/vite-plugin is installed from npm, npm will try to fetch @repo/types and fail because it only exists in the workspace, breaking plugin installs for users. The types should be bundled or exposed through a published package rather than depending on an unpublished workspace module.

Useful? React with 👍 / 👎.

- Changed `arkenv` dependency in `apps/playgrounds/node/package.json` to use a specific tarball file instead of workspace reference.
- Added `@repo/types` as a dependency in `packages/arkenv` and `packages/vite-plugin` to ensure consistent type usage across packages.
- Updated `tsdown.config.ts` files in both `packages/arkenv` and `packages/vite-plugin` to resolve types from `@repo/types`.
- Updated the `InferType` definition in `packages/internal/types/index.ts` to enhance type inference from ArkType definitions.
- Changed the output path for type definitions in `packages/internal/types/package.json` to `./dist/index.d.ts`.
- Modified `tsconfig.json` in `packages/internal/types` to enable declaration file generation and set the output directory.
- Removed unused `dts` configuration from `packages/vite-plugin/tsdown.config.ts`.
- Adjusted import statements in `packages/vite-plugin/src/types.ts` for consistency.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (2)
packages/vite-plugin/package.json (1)

15-15: Critical: Unpublished dependency will break external installs.

The vite-plugin package depends on @repo/types, which is marked as private and will not be published to npm. When users install @arkenv/vite-plugin from npm, the installation will fail because npm cannot resolve @repo/types.

Even as a devDependency, if the build process doesn't properly bundle or inline the types from @repo/types, the published package will have broken type references. Verify that the build tool (tsdown) is configured to bundle all type dependencies into the output.

Run the following script to verify tsdown configuration:

#!/bin/bash
# Check tsdown config for type bundling
echo "=== Vite Plugin tsdown.config.ts ==="
cat packages/vite-plugin/tsdown.config.ts

echo -e "\n=== Check if @repo/types is in dts.resolve ==="
rg -A 5 'dts.*resolve' packages/vite-plugin/tsdown.config.ts
packages/arkenv/package.json (1)

44-44: Critical: Unpublished dependency will break external installs.

The arkenv package depends on @repo/types, which is marked as private and will not be published to npm. When users install arkenv from npm, the installation will fail because npm cannot resolve @repo/types.

As a devDependency, if the build process doesn't properly bundle or inline the types from @repo/types into the published output, the package will have broken type references. Verify that tsdown is configured to bundle all type dependencies.

Run the following script to verify tsdown configuration:

#!/bin/bash
# Check tsdown config for type bundling
echo "=== ArkEnv tsdown.config.ts ==="
cat packages/arkenv/tsdown.config.ts

echo -e "\n=== Check if @repo/types is in dts.resolve ==="
rg -A 5 'dts.*resolve' packages/arkenv/tsdown.config.ts
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fc7a3ab and 0709d51.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (17)
  • apps/playgrounds/node/package.json (1 hunks)
  • openspec/changes/add-internal-types-package/design.md (1 hunks)
  • openspec/changes/add-internal-types-package/proposal.md (1 hunks)
  • openspec/changes/add-internal-types-package/specs/internal-types/spec.md (1 hunks)
  • openspec/changes/add-internal-types-package/tasks.md (1 hunks)
  • packages/arkenv/package.json (1 hunks)
  • packages/arkenv/src/create-env.ts (1 hunks)
  • packages/arkenv/tsdown.config.ts (1 hunks)
  • packages/internal/types/README.md (1 hunks)
  • packages/internal/types/index.ts (1 hunks)
  • packages/internal/types/infer-type.ts (1 hunks)
  • packages/internal/types/package.json (1 hunks)
  • packages/internal/types/tsconfig.json (1 hunks)
  • packages/vite-plugin/package.json (1 hunks)
  • packages/vite-plugin/src/types.ts (1 hunks)
  • packages/vite-plugin/tsdown.config.ts (1 hunks)
  • pnpm-workspace.yaml (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 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:

  • packages/arkenv/package.json
  • apps/playgrounds/node/package.json
🧬 Code graph analysis (1)
apps/playgrounds/node/package.json (1)
packages/vite-plugin/src/index.ts (1)
  • arkenv (50-86)
🪛 LanguageTool
openspec/changes/add-internal-types-package/tasks.md

[uncategorized] ~20-~20: The official name of this software platform is spelled with a capital “H”.
Context: ...## 4. Update Workflows - [x] 4.1 Review .github/workflows/size-limit.yml to ensure `pa...

(GITHUB)


[uncategorized] ~21-~21: The official name of this software platform is spelled with a capital “H”.
Context: ...ered by packages/**) - [x] 4.2 Review .github/workflows/pkg-pr-new.yml to ensure int...

(GITHUB)


[uncategorized] ~22-~22: The official name of this software platform is spelled with a capital “H”.
Context: ...ould not be published) - [x] 4.3 Review .github/workflows/test.yml to ensure internal ...

(GITHUB)

openspec/changes/add-internal-types-package/design.md

[style] ~82-~82: ‘for the benefit’ might be wordy. Consider a shorter alternative.
Context: ...organization, but it's a small overhead for the benefit of eliminating duplication - **Internal...

(EN_WORDINESS_PREMIUM_FOR_THE_BENEFIT)

⏰ 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). (3)
  • GitHub Check: test-e2e (e2e)
  • GitHub Check: test-e2e (a11y)
  • GitHub Check: test-build (latest)
🔇 Additional comments (15)
packages/internal/types/README.md (1)

1-28: LGTM! Clear and comprehensive documentation.

The README effectively documents the internal types package's purpose, usage patterns, and important constraints. The emphasis on internal-only usage and workspace protocol dependencies is appropriate.

packages/internal/types/tsconfig.json (1)

1-18: LGTM! Appropriate TypeScript configuration for a types-only package.

The configuration correctly uses emitDeclarationOnly: true for a types-only package, and the strict mode settings align with best practices.

openspec/changes/add-internal-types-package/specs/internal-types/spec.md (1)

1-32: LGTM! Well-structured specification.

The specification clearly defines requirements and scenarios for the internal types package, including proper handling in CI/CD workflows and workspace-only usage.

pnpm-workspace.yaml (1)

3-3: LGTM! Workspace configuration updated correctly.

Adding packages/internal/* to the workspace appropriately includes the new internal types package in the monorepo's workspace configuration.

packages/internal/types/index.ts (1)

1-8: LGTM! Clean entry point for the internal types package.

The simple re-export pattern is appropriate for a types-only package, and the header comment clearly documents the internal-only nature of the package.

packages/arkenv/tsdown.config.ts (1)

7-9: LGTM!

The dts.resolve configuration correctly enables tsdown to resolve type declarations from the internal @repo/types package when generating declaration files.

openspec/changes/add-internal-types-package/design.md (1)

1-97: LGTM!

The design document provides clear rationale for introducing the internal types package, covers alternatives considered, and outlines the migration plan. The decision to use workspace protocol and keep the package unpublished is appropriate for an internal utility.

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

1-1: LGTM!

Successfully migrated from local InferType definition to importing from the centralized @repo/types package.

packages/vite-plugin/tsdown.config.ts (1)

7-9: LGTM!

The dts.resolve configuration is correctly set up to resolve the internal @repo/types package during declaration file generation.

packages/internal/types/infer-type.ts (1)

1-17: LGTM!

The InferType utility correctly extracts the inferred type from ArkType definitions by handling both function call signatures (returning validated values) and direct type definitions (via type.Any).

packages/arkenv/src/create-env.ts (1)

1-1: LGTM!

Successfully migrated from local InferType definition to importing from the centralized @repo/types package. The type is used consistently across the function overloads.

openspec/changes/add-internal-types-package/proposal.md (1)

1-32: LGTM!

The proposal clearly articulates the rationale for introducing the internal types package and correctly identifies it as an internal refactoring with no breaking changes.

packages/internal/types/package.json (2)

18-24: arktype versions are consistent and compatible across the workspace.

All three packages (arkenv, internal/types, vite-plugin) specify the same devDependency version 2.1.27 and peerDependency range ^2.1.22. Version 2.1.27 satisfies the peerDependency constraint, ensuring no type mismatches or compatibility issues.


9-13: Exports configuration is correct as-is.

The current configuration using only the "types" condition is the appropriate pattern for a types-only package. The tsconfig.json's emitDeclarationOnly: true setting ensures only .d.ts files are generated with no JavaScript output, making additional "import" or "default" conditions unnecessary and misleading. The monorepo workspace configuration properly resolves @repo/types in consuming packages (arkenv and vite-plugin), confirming the setup works correctly.

openspec/changes/add-internal-types-package/tasks.md (1)

1-36: Well-structured task checklist; verify actual implementation completion.

The task list comprehensively documents the internal types package initiative with clear sections covering structure, type extraction, consumer updates, CI/CD workflows, testing, and documentation. The logical ordering and granular breakdown make it easy to track the implementation scope.

However, this is a checklist of completed tasks rather than implementation artifacts. All items are marked [x] complete, but the actual implementation files (new internal package structure, updated imports, modified configurations, etc.) need verification to confirm alignment with the documented tasks.

To verify the tasks were completed as documented, please confirm:

  1. The internal package structure exists at packages/internal/types/ with index.ts, infer-type.ts, and supporting config files
  2. Consumer packages (arkenv and vite-plugin) import InferType from @repo/types instead of local definitions
  3. Workflow files properly handle the internal package (type-check only, excluded from publishing)
  4. pnpm-workspace.yaml includes packages/internal/* and changesets config excludes @repo/types
  5. Documentation in the internal package README clearly indicates non-published status and usage guidelines

- Changed the `arkenv` dependency in both `apps/playgrounds/node/package.json` and `pnpm-lock.yaml` to use a workspace reference instead of a specific version, facilitating local development and consistency across packages.
@yamcodes yamcodes merged commit 697f54e into main Nov 23, 2025
19 checks passed
@yamcodes yamcodes deleted the 416-internal-types-package branch November 23, 2025 19:19
This was referenced Nov 27, 2025
This was referenced Dec 22, 2025
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 Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Internal types package

1 participant