-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
monorepo compatibility #2973
Comments
This would be awesome as SvelteKit currently seems not to support this kind of setup. In the mean time, do you have any workaround on your machine you'd like to share? 🙃 |
I'm afraid I don't have anything useful to share at the moment... the As soon as the source files and I could put I was thinking maybe a single svelte.config.js in the root of the repo, and then passing a reference to the subdir of the app using args and In The result is that vite's serving allow list looks for This whole thing would be a whole lot easier if there was just a single property that allowed the |
Actually, using the single
This allows for a nested sveltekit project to be targeted from command line args, like: Probably breaks a few other things, but seems to work for now. I haven't found a way to change the location of the |
Thank you for your effort! I'll see if I give it a try. For now it's just unsatisfactory to work with SvelteKit in a monorepo setup. |
So, the above config shows that The ideal solution would allow for individual apps to each have their own To get to this point, we would need to allow svelte-kit cli to:
Also, the need to put |
@martaver are you running a monorepo via Nx? I'm using Nx and have tried to create a shared component library but getting all sorts of weird bugs trying to run in a monorepo |
I'm also having trouble running svelte-kit in a (pnpm) monorepo. I get these errors for some but not all components:
Googling around tells me to downgrade vite, but I don't know how to do that without downgrading svelte-kit. A svelte-kit user also suggested downgrading vite in a discussion I opened. |
Since this issue was raised, we added You could always do this sort of thing: import config from '../../svelte.config.mjs';
export default config; (This makes it easier to have package/app-level overrides, as well.) Does that suffice? |
Going to close this as I believe the issue is now solved |
New to vite & sveltekit. I hit this issue while configuring an nx monorepo. Neither @martaver nor @Rich-Harris workarounds worked for me. What works is to start the dev server from the app dir
|
Describe the problem
Monorepos are becoming more common as more effort is invested into improved tooling. E.g.
nx
andbazel
.For the purposes of this feature request I'm excluding monorepo set ups such as
yarn workspaces
,lerna
andpnpm
that assume each 'package' has its ownpackage.json
andnode_modules
dir (even if its linked). I'm referring to monorepos that don't necessarily preserve the canonical structure of an app with a package.json at its source root.The requirements for getting tools to work with monorepos means potentially supporting multiple apps that might live under the same source root and share the same
node_modules
.The multiple app paradigm basically means that
svelte_kit
should support:package.json
)node_modules/.vite
bazel
specifically, would require args likesource_root_path
andoutput_path
to be able to be passed tosvelte_kit
binary as command arguments.Vite already supports this kind of set up, they demonstrate ways to run multiple apps under a single vite configuration here: https://vitejs.dev/guide/build.html#multi-page-app and tout being monorepo friendly.
Also vite is already friendly towards dependencies located in the same repo: https://vitejs.dev/guide/dep-pre-bundling.html#monorepos-and-linked-dependencies
It should be possible to host multiple apps under a single vite configuration. Why not the same for svelte-kit?
Describe the proposed solution
In theory, Vite already has all the tools needed to be monorepo friendly. It's just a matter of allowing svelte_kit to be run the same way.
Already, running:
node ../../node_modules/@sveltejs/kit/svelte-kit.js dev
from a nested kind of works... (It'll error up until you refresh the browser, and then won't serve some routes properly).Sveltekit could surface vite features like:
root
from command args, or perhaps a path to asvelte.config.js
, or...svelte.config.js
file.Seems... possible.... but here be dragons...?
Alternatives considered
Git submodules
...j/k
Importance
would make my life easier
Additional Information
I think spending a little amount of time on this now will allow for early adoption for tools like
nx
andbazel
.The text was updated successfully, but these errors were encountered: