GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — vp migrate: only rewrite the vite/vitest imports that vite-plus actually owns · Issue #2004 · voidzero-dev/vite-plus

vp migrate: only rewrite the vite/vitest imports that vite-plus actually owns #2004

New issue
Copy link
New issue
Copy link
Closed
#1891
Closed
vp migrate: only rewrite the vite/vitest imports that vite-plus actually owns#2004
#1891
Copy link
Assignees
fengmk2
Labels
bugSomething isn't working

Description

@fengmk2
fengmk2
opened on Jul 1, 2026
Issue body actions

Problem

vp migrate rewrites every vite/vitest import specifier to vite-plus, then tries to exclude the cases where that's wrong with package-level heuristics (vite-plugin-*/unplugin-* names, vite in dependencies/peerDependencies). This is the wrong altitude: the correctness of the rewrite is a property of the imported symbol, not of the package, so the heuristics leak.

vite-plus is not a superset of the Vite library. It is Vite (export * from '@voidzero-dev/vite-plus-core' in packages/cli/src/index.ts) plus a small set of deliberately-owned overrides (defineConfig, defineProject, lazyPlugins). Those are the only symbols where importing from vite-plus is better than importing from vite. Rewriting any other (pass-through) symbol carries no benefit and can break, because vite-plus's exposed surface is not guaranteed to match vite's.

Reproduction

A monorepo package that uses Vite's programmatic API. In packages/cloudflare/src/deploy.ts:

// before migrate (correct):
type ProjectViteApi = Pick<typeof import("vite"), "createBuilder" | "loadConfigFromFile">;

// after migrate (broken):
type ProjectViteApi = Pick<typeof import("vite-plus"), "createBuilder" | "loadConfigFromFile">;

createBuilder/loadConfigFromFile are Vite-core APIs; vite resolves to vite-plus-core and has them, but typeof import("vite-plus") does not expose them, so the type breaks. Real-world instance: fengmk2/vinext#22 (comment)

Note: this is not a resolution problem. packages/cloudflare does depend on vite-plus and it resolves fine. It is purely a surface mismatch.

Root cause

crates/vite_migration/src/import_rewriter.rs (get_package_rewrite_context / SkipPackages) decides whether to rewrite a package's vite imports from dependencies/peerDependencies + the plugin-name convention. A package that declares vite only in devDependencies and isn't a plugin (like packages/cloudflare) is not skipped, so its programmatic/type vite imports get rewritten.

Proposed fix

Make the rewrite symbol-scoped. Rewrite a vite/vitest import to vite-plus only for the bindings vite-plus deliberately owns; leave every other binding on vite/vitest, splitting a mixed import when needed:

  • import { defineConfig } from 'vite' becomes from 'vite-plus'
  • import { createBuilder, loadConfigFromFile } from 'vite' stays unchanged
  • import { defineConfig, loadEnv } from 'vite' splits: defineConfig from vite-plus, loadEnv from vite
  • typeof import("vite") used for createBuilder stays unchanged

Derive the owned-symbol set from vite-plus's own explicit (non-star) exports so it stays in sync. This is a smaller migrator: it removes the plugin-name check and the deps/peerDeps skip (one correct invariant replaces the topology guesses) and fixes the whole class at once (programmatic API, type-only imports, plugin internals, monorepo consumers).

Notes

  • Interim option if symbol-splitting is too much for a first pass: scope the rewrite to config entry files only (vite.config.*, vitest.config.*), where the unified defineConfig is the only real reason to rewrite. Simpler, still fixes this case.
  • Possible separate bug: if export * is meant to forward createBuilder and the built vite-plus .d.ts drops it, that is a vite-plus types bug worth fixing independently. The migrate should not depend on vite-plus being a perfect superset regardless.
Reacted by JongKyung Lee

Activity

  1. fengmk2
    self-assigned this
    on Jul 1, 2026
  2. fengmk2
    added
    bugSomething isn't working
    on Jul 1, 2026
  3. fengmk2
    added a commit that references this issue on Jul 1, 2026

    feat(migrate): scope the vite to vite-plus rewrite to config entry files

    3f51afb
  4. fengmk2
    linked a pull request that will close this issuefeat(migrate): upgrade existing Vite+ projects across versions #1891on Jul 1, 2026
  5. fengmk2
    added 5 commits that reference this issue on Jul 1, 2026

    refactor(migrate): drop dead extra_config_files path, preserve tsconf…

    c006a76

    style(migrate): apply rustfmt to the #2004 import_rewriter tests

    7da2ece

    fix(migrate): apply 13 code-review fixes across migrate paths

    9b2f64e

    test(migrate): declare module 'vite' augmentations follow the config …

    e29973c

    fix(migrate): keep declare module 'vite' augmentations on 'vite'

    6f99ee3
  6. fengmk2
    closed this as completedin #1891on Jul 2, 2026
  7. fengmk2
    added a commit that references this issue on Nov 3, 2026

    fix(lint): keep imports that vp migrate keeps per package (#3192)

    d8e8def
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @fengmk2
    fengmk2

Labels

bugSomething isn't working

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.