Skip to content

Internal types package should not require build step #421

@yamcodes

Description

@yamcodes

Problem

The @repo/types internal package currently requires a build step (tsc) to generate .d.ts files in the dist/ directory, even though it's a types-only package with no runtime code.

This is necessary because:

  • tsdown's dts.resolve configuration needs the package to have declaration files to bundle types correctly
  • The package.json points to ./dist/index.d.ts for type resolution
  • Without the build step, TypeScript can't resolve the types during the bundling process

Why This Is Not Ideal

  1. Types-only packages shouldn't need builds - The original design was for a zero-build types package
  2. Adds unnecessary complexity - Requires maintaining a build script and dist directory
  3. Build order dependency - The internal types package must be built before packages that depend on it
  4. Goes against the original proposal - The proposal stated "no build config needed"

Current Workaround

The package currently has:

  • "build": "tsc" script to generate declaration files
  • "types": "./dist/index.d.ts" pointing to built files
  • Build step required before consuming packages can use the types

Potential Solutions

  1. Investigate tsdown alternatives - Find a way to make dts.resolve work with source .ts files directly
  2. Use a different bundling approach - Maybe inline the types directly in source files instead of using a separate package
  3. Wait for tsdown improvements - See if future versions support resolving types from source files
  4. Accept the build requirement - Document it as a necessary trade-off for type bundling

Related

Priority

Low - This is a technical debt item. The current solution works, but it's not ideal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    @arkenv/vite-pluginIssues or Pull Requests involving the Vite plugin for ArkEnvarkenvChanges to the `arkenv` npm package.enhancementNew feature or requestinfraInfrastructure related issue or pull request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions