Skip to content

Better (package-based) monorepo support #10447

@githorse

Description

@githorse

Description

The documentation on setting up a monorepo with Vite is pretty minimal. (Compare nx's, for example.) I don't fully understand this sentence:

It will not attempt to bundle the linked dep, and will analyze the linked dep's dependency list instead.

More importantly, though, is this part:

When making changes to the linked dep, restart the dev server with the --force command line option for the changes to take effect.

Since most of my code is in the libraries, not the app, this means I'll have to reboot constantly, which would seem to defeat the purpose of Vite.

Is Vite not intended for monorepos? (Not for package-based monorepos?) Whether the answer is yes or no, could the documentation be expanded to better address the question? If the answer is yes, could we have some sort of --watch feature that rebuilds on changes in linked packages in a monorepo?

Suggested solution

  • Expand the documentation to better explain how (package-based) monorepos are intended to work with Vite.
  • Provide a simple working demo/tutorial of Vite in a package-based monorepo. (Ideally, with a Typescript project -- getting Typescript sub-packages to work correctly with other build tools has been tricky, to say the least.)
  • Implement a --watch or equivalent feature to automatically pick up changes to packages in a monorepo.

Additional context

My repository is a monorepo consisting of a few apps and a large set of libraries, each constituting a package:

root/
  packages/
     app1/
     app2/
     lib1/
     lib2/
     lib3/

Apps reference libraries by importing them in package.json (and tsconfig.json), and libraries import other libraries the same way, forming a (rather complicated) DAG.

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions