Workspace boundary rules between packages (like `turbo boundaries`)

Aperta
#3,295 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
javascript, rust, typescript
Ambito
cli, tooling

Direzione di ricerca

Begin in the Vite+ Rust source where the vp check command is implemented and where workspace packages and their package.json/vite.config.ts are parsed. Study the turbo boundaries docs and the three checks (relative imports, undeclared deps, tag rules) to model the graph. Add a --boundaries mode with tag config from vite-plus field or root config, then write integration tests on a sample monorepo.

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

Descrizione

triage: not actionable
Description

As a developer moving a monorepo from Turborepo to Vite+, I want to declare which workspace packages may depend on which, and have a Vite+ command fail when a package breaks that, so our architecture rules keep being enforced in CI after turbo is gone.

We run turbo boundaries as a required CI step. Each package's turbo.json declares tags (backend, frontend, app), and the root has two rules:

"boundaries": {
  "tags": {
    // a backend package must never end up in a frontend bundle
    "backend": { "dependents": { "deny": ["frontend"] } },
    // apps are dependency sinks, no app imports another app
    "app": { "dependents": { "deny": ["app"] } }
  }
}

It also flags a file that imports a package not declared in its own package.json (cannot import package 'x' because it is not a dependency), which catches imports that only work because of hoisting. On our repo (88 packages, about 4,400 files) it runs in under a second.

Vite+ has nothing equivalent that we could find, so this is one of the things keeping turbo in our toolchain.

Suggested solution

Tags on workspace packages and allow/deny rules between them, checked against both package.json dependencies and actual imports. vp check seems like the natural home since it's already the CI gate, or a separate vp check --boundaries if it shouldn't run by default.

Config would sit naturally in the root vite.config.ts, with tags per package. Packages without a vite.config.ts (most of ours: NestJS backends and libraries) would need somewhere to put their tags, maybe a vite-plus field in package.json.

Alternative
  • Path-based lint rules in the style of ESLint's import/no-restricted-paths. They work on file paths, not package tags, so we'd keep a hand-written list per package.
  • dependency-cruiser or eslint-plugin-boundaries. Both work, but it's one more tool to configure, which is what we're trying to get away from.
  • What we did in the meantime: a ~340-line script that does turbo's three checks (relative imports leaving the package, undeclared package imports, tag rules over the dependency graph) and gives the same result as turbo boundaries on our repo. It works, but it's ours to maintain, and every team leaving turbo would write the same thing.
Additional context
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
6.5k
Fork
297
Merge medio
20h 18m
PR unite (30g)
236

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.