Skip to content

migrate: rewrite tsdown/client and vite/client in TS imports and tsconfig.json types array #1502

@naokihaba

Description

@naokihaba

Description

When running vp migrate, tsdown is removed as a dependency and replaced with vite-plus equivalents.
However, two patterns are currently left unrewritten, causing broken imports and TypeScript errors after migration.

relates: #1501

Cases to handle

1. import "tsdown/client" in .ts files

// before
import "tsdown/client";

// after
import "vite-plus/pack/client";

Real-world example: https://github.com/Tarrowren/css-class-intellisense/c91dd77dc1fb5acf/lezer/less/test/test-less.ts#L1

2. types array in tsconfig.json

// before
{ "compilerOptions": { "types": ["tsdown/client"] } }
{ "compilerOptions": { "types": ["vite/client"] } }

// after
{ "compilerOptions": { "types": ["vite-plus/pack/client"] } }
{ "compilerOptions": { "types": ["vite-plus/client"] } }

Real-world example: https://github.com/ascorbic/cirrus/blob/98aec98dc56de58f8d6010565cef6cfc5c62311e/packages/pds/tsconfig.json#L5

Suggested solution

Case 1 — import in .ts files

Add a new ast-grep rule to REWRITE_TSDOWN_RULES (import_rewriter.rs)
to match import "tsdown/client" and rewrite it to import "vite-plus/pack/client",
alongside the existing tsdown rule.

Case 2 — tsconfig.json types array

Add a new function to packages/cli/src/utils/tsconfig.ts using the existing
jsonc-parser dependency to rewrite entries in compilerOptions.types:

  • "tsdown/client""vite-plus/pack/client"
  • "vite/client""vite-plus/client"

Call this function from migrator.ts alongside cleanupDeprecatedTsconfigOptions().

Alternative

  • Document as manual steps instead of automating. (Even though I don't want to)

Additional context

No response

Validations

  • Read the Contributing Guidelines.
  • Confirm this request is for Vite+ itself and not for Vite, Vitest, tsdown, Rolldown, or Oxc.
  • Check that there isn't already an issue requesting the same feature.

Metadata

Metadata

Assignees

Priority

None yet

Start date

None yet

Target date

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions