Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Ergonomics of vp pack + plugins

Aperta
#2,632 1 commento 2 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript

Direzione di ricerca

Inizia dal percorso di estrazione della configurazione utilizzato da vp pack e dal comportamento di lazyPlugins controllato da VP_RESOLVING_CONFIG_METADATA; l’issue fornisce una riproduzione in vite.config.ts. Esegui vp pack con il plugin fornito e traccia come root e pack.plugins vengono inoltrati a tsdown. Il lavoro è completato quando i plugin di pack vengono eseguiti rimanendo lazy per vp lint e vp fmt, e la composizione dei plugin root è chiarita.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

pending triage
Description

Configuring plugins for library packaging via vp pack has confusing ergonomics and a potential bug when using lazyPlugins:

  1. Root plugins are ignored by vp pack: In a library project using vite.config.ts, plugins configured at the root (plugins: [...]) are not forwarded to tsdown during vp pack. Users must define them redundantly under pack.plugins.
  2. lazyPlugins fails silently inside pack.plugins: If a user attempts to wrap pack.plugins in lazyPlugins(() => [...]) to avoid running plugin factories during vp lint or vp fmt, the plugins never execute during vp pack.
Root Cause

When vp pack extracts the tsdown config from vite.config.ts, VP_RESOLVING_CONFIG_METADATA is set to "1".

Inside lazyPlugins:

function lazyPlugins(cb) {
  if (process.env["VP_RESOLVING_CONFIG_METADATA"] === "1") return;
  const result = cb();
  return result;
}

Because the metadata environment marker is active during config extraction for vp pack, lazyPlugins returns undefined. Consequently, tsdown runs with no plugins.

Reproduction

In vite.config.ts:

import { defineConfig, lazyPlugins } from 'vite-plus';

function myPlugin() {
  return {
    name: 'test-plugin',
    buildStart() {
      console.log('--- PLUGIN EXECUTED ---');
    },
  };
}

export default defineConfig({
  pack: {
    entry: ['src/index.ts'],
    // ❌ Fails: '--- PLUGIN EXECUTED ---' is never printed
    plugins: lazyPlugins(() => [myPlugin()]),

    // ⚠️ Works, but runs eagerly during `vp lint` / `vp fmt`:
    // plugins: [myPlugin()],
  },
  // ❌ Ignored by `vp pack`:
  // plugins: [myPlugin()],
});

Run:

vp pack
Suggested solution
  1. lazyPlugins should evaluate when resolving the build pipeline for vp pack, so plugins can be lazily loaded without executing during vp check / vp fmt / vp lint.
  2. Ideally, plugins defined at the root (plugins: [...]) should either auto merge with pack.plugins by default when building libraries, or vite-plus should provide clear ergonomics/typing on how root Vite plugins vs. pack plugins compose. It's frankly confusing having two separate places to specify the plugin arrays.
Alternative

No response

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.
Lingua principale
Rust
Stelle
6k
Fork
274
Merge medio
1g 11h
PR unite (30g)
206

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di voidzero-dev/vite-plus

Tutte le issue di voidzero-dev/vite-plus

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.