kit.files.*
deprecation
#14240
Replies: 10 comments 8 replies
-
I've made a small demo, of how we use routes in wild life: check .env file in a repo and svelte-config.js to get an idea. In real life projects different providers used (mostly static adapter with something, like Cloudflare, Vercel and probably soon will shift to Fastly), and base path hardly used (because lands embedded to sites managed by different partners). The land itself placed in $lib, if we can support api in exact adapter we also import api handlers from $lib (can extend repo if needed) |
Beta Was this translation helpful? Give feedback.
-
Me fight for Svelte in every company I work. And this is what I came up with in latest project:
Ye, we want to be global lib (which is Also, our teem refuse to make our project structure depend on browser urls since marketing-managers can change it any time and as often as they want it to. import type { Pattern, Error } from '/router/types.ts';
const error: Error = () => import('/src/error.svelte');
const base: Layout = {page: () => import('/src/base.svelte'), error: error};
const layouts = [base];
const patterns: Pattern[] = [
{re: '', page: () => import('/src/home.svelte'), layouts},
{re: 'users', page: () => import('/src/users/user.svelte'), layouts},
{re: 'users/(<id>[0-9]+)', page: () => import('/src/users/users.svelte'), layouts},
]
export { patterns, error} And we are happy with that. Honestly, when I first saw "The P.S. I do understand the value of simplicity (but not unification among all kinds of projects), and I'll be ok with any other mechanism of reorganising paths that'll be easier to maintain from Svelte's side |
Beta Was this translation helpful? Give feedback.
-
I've been a Svelte user for a while now, and the flexibility of the kit.files configuration was actually one of the key reasons I chose SvelteKit over other frameworks. The ability to customize the file structure isn't just an "aesthetic" preference for me; it's a critical part of how I manage complex projects. For example, in a current project, I have a monorepo setup where I share components and utility functions from a single $lib directory across multiple SvelteKit applications. Each application, however, has its own distinct set of routes and layouts. I'm able to manage this seamlessly by using the kit.files configuration to point to separate routes directories for each app, like this:
This setup allows me to build a single application with shared $lib components while maintaining entirely distinct layouts and pages for different "sub-projects" or modules. For example, I can have src/src-1 containing specific source code and src/routes/project-1 defining the routes for a particular part of my application, all within the same SvelteKit instance, reusing common components defined in $lib. I understand the goal of making SvelteKit more consistent and predictable, especially for new users and tools like LLMs. However, for those of us working on more unconventional, large-scale projects, this feature is a lifeline. I believe removing it entirely would be a step backward in terms of flexibility and would force developers to use "grubby" workarounds that are arguably less readable and harder to maintain than the current configuration options. |
Beta Was this translation helpful? Give feedback.
-
I've built my whole app in a way relying on "config.kit.files.routes" Please don't deprecate this, I see others complaining as well, which gives me hope you won't, and thanks for listening to us. files: { $project: 'src/lib/project/project_name/*' |
Beta Was this translation helpful? Give feedback.
-
In my project, I keep both frontend and backend in the same repository, and it is crucial for me to at least specify my own root directory for the entire frontend structure. Example stucture:
|
Beta Was this translation helpful? Give feedback.
-
@Rich-Harris Please reconsider deprecating this. It’s such an essential part of my workflow that its removal would make updating nearly impossible for me. I know I’m speaking for more than just myself, as many users rely on it without actively commenting here.
|
Beta Was this translation helpful? Give feedback.
-
For those affected by this change: wouldn't a simple symlink to a custom directory accomplish the same result? I apologize if this sounds naive but I didn't see any mention of this solution. |
Beta Was this translation helpful? Give feedback.
-
Just want to leave a +1 for revisiting #6031 |
Beta Was this translation helpful? Give feedback.
-
Supporting of configuration options for folder structure is crucial for monorepos. Workarounds like symlinks are problematic. Keeping customization options is vital for SvelteKit's adaptability to complex, real-world development scenarios, where SvelteKit often integrated within large existing codebases. |
Beta Was this translation helpful? Give feedback.
-
Similarly to @MegaDiablo, my personal and professional projects use SvelteKit in a repo where both the frontend and backends (Rust) live together. As a result, the
While one could argue that if In addition, our repo contains other tools - such as Node.js scripts - that share dependencies with the application. From that perspective, it also makes sense to keep the Currently, my
Examples: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
We deprecated the
kit.files.*
configuration options in #14152. This was prompted by the addition of remote functions, which SvelteKit was looking for insidekit.files.lib
andkit.files.routes
(akasrc/lib
andsrc/routes
, for 99% of people) — some people wanted to be able to put remote functions elsewhere insrc
, and the existing setup made that hard. We could have added akit.files.remotes
option or similar, but... ugh.Another example: observability. If you can configure other stuff in
src
, shouldn't you be able to configuresrc/instrumentation.server.ts
? If not, why the discrepancy?And so on. Faced with a choice of adding a new config option for every new feature, or just removing a feature that none of us could remember the original reason for, we decided it made sense to remove it. This makes things much simpler — not so much implementation-wise, but in terms of the framework's learnability and so on. Right now, every time we mention specific files or directories in the docs we either have to gloss over the configurability or add throat-clearing like this:
And every time someone moves between SvelteKit codebases, there's a chance they'll have to temporarily rewire their brain to get their bearings. This is particularly troublesome if you're an LLM: for coding assistants, it's hugely beneficial if project structure is predictable and documented.
But.
Some of you have since left comments on closed PRs and issues arguing against this decision. Continuing discussions on closed threads is never a good idea, so if there's a conversation to be had it's better to have it here.
We won't be moved by complaints like 'I want to use
source
instead ofsrc
orpages
instead ofroutes
for aesthetic reasons'. The whole point of a framework is to have a consistent vernacular, and if there are naming choices that truly don't make sense then they should change for everyone.But we do want to make sure that people have enough flexibility to solve esoteric cases. So far, at least, it seems like the only thing that's missing is the ability to configure
routes
, and if the outcome of this discussion is that we keep everything deprecated exceptroutes
, that seems like a useful discovery and an overall win. Perhaps we'll even revisit #6031 in light of this.Having said that, it's not yet totally clear to me what the limitations of a conventional monorepo setup would be. There is some weirdness involved — if you have multiple SvelteKit apps in a monorepo, you'll likely need to do this sort of thing which feels a bit grubby...
...but if there are limitations and sticking points here then perhaps we can address those too.
Appreciate those of you who have weighed in on this already — I realise adding deprecation notices is a heavy-handed way to gather feedback, but you are proof that it works!
Beta Was this translation helpful? Give feedback.
All reactions