kit.files.*
deprecation
#14240
Replies: 19 comments 23 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.
-
I’ll make my point in separate comment: And probably there could to be a universal and less complex mechanism like
for any dir without predefining possible keys in that object and without that magical Will not say for others, but it’ll totally suit needs of projects I work on |
Beta Was this translation helpful? Give feedback.
-
I understand the rationale, but this deprecation is defended as if SvelteKit were opinionated about folder structure, which it isn't. Having a plan to structure a project at scale isn't just an aesthetic preference; it's a requirement. I wouldn't mind this change if it meant that SvelteKit would be more opinionated about folder structure as a result of it, but it doesn't look like it will be. So, in my view, this is a mistake. |
Beta Was this translation helpful? Give feedback.
-
I have a complex monorepo (turborepo + pnpm workspaces) that would significantly benefit from retaining Current Architecture
Current Workarounds (that kit.files would eliminate)1. Static Asset SharingCurrent solution: Custom symlink management via pnpm symlinks With kit.files: Simple config per app // apps/site/svelte.config.js
export default {
kit: {
files: {
assets: '../../packages/ui/static'
}
}
} 2. Remote Functions IssueCurrent problem: Remote functions only work within individual apps, not shared packages 3. Shared ConfigurationCurrent: Complex config inheritance via // packages/config/svelte/svelte.config.js - Master config
export default {
kit: {
adapter: adapter(),
alias: {
"@packages/ui": resolve("../../packages/ui/src/lib"),
"@packages/tools": resolve("../../packages/tools/src"),
$root: resolve("../../../"),
$app: resolve("../../apps/app/src"),
$docs: resolve("../../apps/docs/src"),
$site: resolve("../../apps/site/src"),
$storybook: resolve("../../apps/storybook/src"),
$lib: "./src/lib",
},
experimental: { remoteFunctions: true }
}
}
// apps/**
import config from "@packages/config-svelte";
export default config; With kit.files: Simplified shared config, each app gets shared assets automatically // packages/config/svelte/svelte.config.js - Much simpler master config
export default {
kit: {
adapter: adapter(),
files: {
assets: '../../packages/ui/static' // All apps inherit shared assets
},
alias: {
"@packages/ui": resolve("../../packages/ui/src/lib"),
"@packages/tools": resolve("../../packages/tools/src"),
$lib: "./src/lib",
},
experimental: { remoteFunctions: true }
}
}
// apps/** (stays exactly the same - no symlink tooling needed)
import config from "@packages/config-svelte";
export default config; Why This Matters for Monorepos
|
Beta Was this translation helpful? Give feedback.
-
One more thing why we have to remap |
Beta Was this translation helpful? Give feedback.
-
We have a probably pretty esoteric situation: We have two versions of this site: https://view.qiime2.org/ One version is deployed with a service worker (and thus needs a different config) and the other is vendored into a CLI application, with a different initialization involving a local ephemeral file-server. It seemed at the time that the I imagine we could probably do the mono-repo approach and punt most of the application code out of sveltekit, but as largely Python developers, I don't think that would have occurred to us without this discussion. |
Beta Was this translation helpful? Give feedback.
-
Just to offer a thought: what about something like a build-time group in routes? It would be set via some mechanism during build/preview/dev and the entry-points are still in a consistent place:
This would be a bit weird looking, but I think someone unfamiliar with it would google it and find the relevant docs. LLMs I suspect wouldn't care, worst case they miss the build prefix, but it's still in routes and then sveltekit could even error on the "orphaned" routes, making fixing it straight-forward. |
Beta Was this translation helpful? Give feedback.
-
Offering one POV, I've resisted monorepos, surely somewhat irrationally, but also because I have a lot of interconnected projects with different needs and drawing boundaries at the monorepo doesn't make sense for most of them. So I put more time into workflows that work on sets of repos instead of a bundled one. Is it optimal? Probably not, I see advantages that fit well with JS's module system, but I wasn't seeking to adopt monorepos. But Svelte has had me eat my vegetables before and I liked it, it could be one of those. In an experimental project I have src/roots as my frontends directory, so each of its subdirs like src/roots/foo is the equivalent of a SvelteKit src/routes. This seems to scale nicely but it's an opinionated choice about the shape of things and it's not designed for the web. |
Beta Was this translation helpful? Give feedback.
-
Please don't deprecate this... I use this in every new project because I use a different asset folder depending on dev/prod. I can't use sveltekit if you remove this. I feel like any non-trivial project with self hosted load balancers and all the rest will require the assets path to be configurable and this so-called "fix" only helps for people making markdown blogs and vercel hosted apps with 5 total users (no offense). |
Beta Was this translation helpful? Give feedback.
-
I hope the svelte team reconsiders this decision. A lot of people have already been using this feature, and is a good selling point to use for svelte-kit. Svelte should be for EVERYONE, it shouldn't lock you in to a specific file structure it decides, And the |
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