kit.files.* deprecation
#14240
Replies: 44 comments 75 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 ArchitectureCurrent Workarounds (that kit.files would eliminate)1. Static Asset SharingCurrent solution: Custom symlink management via pnpm symlinksWith 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.
-
|
On a long-running project of mine, Svelte provides the UI but co-exists with a non-Node non-JS server application. For project-local organizational reasons, the UI lives in a We could probably adapt if you remove those configuration options, but we'd strongly prefer to keep the parallel organizational scheme of Rust in one place, JS in another, both within the same repository. Deprecating (and ultimately removing) The points about maintainability and learnability are well taken, but even so, we'd strongly prefer to keep those options. |
Beta Was this translation helpful? Give feedback.
-
|
Hello everyone, I am currently using Electron.js with SvelteKit. I keep my Electron files in a Accordingly, I corrected the config like this (minimal example): const config = {
kit: {
files: {
assets: 'renderer/static',
hooks: {
server: 'renderer/hooks.server',
client: 'renderer/hooks.client'
},
lib: 'renderer/lib',
params: 'renderer/params',
routes: 'renderer/routes',
serviceWorker: 'renderer/service-worker',
appTemplate: 'renderer/app.html',
errorTemplate: 'renderer/error.html'
}
}
}However, it seems that by default, Svelte expects its files to be in the project root. I've been using Svelte since 2019, and I'm excited about the roadmap and current trends. 99% of the updates have been truly user-friendly and beneficial. However, this particular change regarding folder structure is confusing to me and many others. For junior developers just starting out, a standardized structure across all projects is convenient and understandable. But for enterprise projects—or anything more complex than "Hello, World!"—where Svelte might only be a part of the project, it shouldn't dominate the root folder or dictate the entire structure. That feels strange at best. If I have misunderstood this change, could someone explain how I can maintain my custom folder structure? How should I configure the config file now? |
Beta Was this translation helpful? Give feedback.
-
|
Hm, I hope that this deprecation will be reverted. In a case when we host lots of sites from one repo in cloudflare workers, using this option |
Beta Was this translation helpful? Give feedback.
-
|
Hello! I bring another use case: GitHub Pages. For GH Pages, the name Thanks! P. S.: FWIW, removing this configuration makes Sveltekit a more opinionated framework. I don't think we want Sveltekit to be an opinionated framework. Of course, I don't own it, so this remains a single user opinion. |
Beta Was this translation helpful? Give feedback.
-
|
So you're deprecating a useful feature that was not added for reasons "lost to time", but rather for user choice & flexibility. Guess some people indeed have forgotten about the importance of personal freedom.. Organizing my app a certain way is my choice, and having the ability to do so is a benefit. And the only listed, concrete functionality-based reason for doing so is... observability? That is not something the average person uses, it even clearly says to seriously consider using it before going all in! That's not something every project needs, but will EVERYONE be using DIRECTORIES? Yes sir! The learnability argument is invalid because if someone can grasp how to use Svelte, they can grasp how to set folder paths in a configuration file. LLMs as a reason is also invalid because they can't even do Svelte 5 yet, I've tried. The syntax is way too new (thanks to your new syntax with all the react-y "runes"), so they're useless for any new svelte application. With consistent changes like these I find it difficult to believe more people will switch to the latest, either, so how much new training data will they really get?... The best part: the officially given reason for removing a useful feature:
Pathetic. |
Beta Was this translation helpful? Give feedback.
-
|
I think there are obvious edge cases where this creates problems, mono-repos being a great example, but I think the fundamental reasoning for why it was deprecated in the first place should be reconsidered. I understand the reasoning that it will allow people to be able to jump between projects without having to learn a new project structure. However, that reasoning doesn't hold up in real world applications. It actually is causing the exact opposite problem. The key thing this decision missed is most companies already have a standardized folder structure in place before they even consider adopting Svelte. They likely have been making web apps already for years. If they decide to use Svelte on future projects, instead of creating consistency, this decision unnecessarily forces a situation where they cannot have consistency and it will be harder to jump between projects:
The truth is, most companies can't move to Svelte's opinionated folder structure as a standard because legacy apps exist and they already have a standard. Instead of your intended outcome, you have now made it impossible for companies to create consistency. They must now maintain projects with completely different folder structures. Now look at the alternative. If you leave these options:
You see, it doesn't matter that it's different from Svelte projects outside the company because the code we interact with daily is inside the company. Would you rather have consistency within your company or break consistency inside the company so that a portion of your apps match apps outside your company? The second option doesn't make sense. This is why the logic for this deprecation breaks down in real world scenarios. One last thought. You might think that tools like Prettier solve a similar problem, but it is actually the exact opposite. Prettier is a standard that a company can choose to adopt or they can choose to adopt another one. You can no longer choose whether to adopt Svelte's enforced folder standard. Think about what that means. Let's say your company has been using Prettier for years. Svelte decides to enforce its own formatting standard and Prettier is no longer compatible with Svelte. Do you think because of your decision they should go back and reformat all their existing projects to match your idea of the best formatting? This would obviously be a poor decision and inappropriate to expect from companies, but deprecating these options is creating the exact same situation. It is not Svelte's job to decide and enforce a company's culture and standards. Period. That is the main problem with this decision. |
Beta Was this translation helpful? Give feedback.
-
|
Just to follow up on my last comment, I think the most appropriate approach to this would be to not deprecate the features but leave a note in the configuration documentation that it is bad practice to change these values without a very good reason. Emphasize that the Svelte defaults are the accepted community standards everyone should strive to follow if possible. You could even list a few reasons, such as incompatibility with AI. I think that would push developers to use the default folder structure without backing people into a corner that need this feature, whether for unique mono-repo cases, compatibility issues with other packages, or to maintain consistency with their existing folder structure standards. I also don't think you need to keep "throat clearing" messages throughout the docs. The vast majority of frameworks and packages I've used have options to change default folder paths and is something people expect. The only reason they would even know these features were deprecated is if they visited the configuration docs, which is where the above warning would be. |
Beta Was this translation helpful? Give feedback.
-
|
I have to create a new application today for a client that would require these configuration options, but I'm a bit unsure where this is going since the discussion started 6 months ago and therefore what configuration I should apply for this new project to be future-proof given that using the |
Beta Was this translation helpful? Give feedback.
-
|
Use case: Plugin system with mergeable routes We're building a modular SvelteKit architecture where multiple "plugins" (separate npm packages) can contribute their own routes. A Vite plugin merges routes from all installed plugins into a .website folder at build/dev time, with client-specific routes taking priority (allowing overrides).
This is currently the only way to achieve a WordPress-like plugin system in SvelteKit where packages can provide routes. Without files.routes, there's no way to point SvelteKit to a dynamically generated routes directory. Otherwise I will have to hack more sveltekit to gitignore
|
Beta Was this translation helpful? Give feedback.
-
|
Hi everyone, I'll admit I'm new to svelte, but I thought I'd leave my 5 cents on my simple use case: // svelte.config.ts
const config: Config = {
preprocess: vitePreprocess(),
kit: {
files: {
src: 'src/client/'
},
adapter: adapter({
pages: 'build',
assets: 'build',
precompress: false,
strict: true
})
}
};
export default config;In my case, I'm using a monorepo where server files stay in It's a very basic use and I'm not sure if it can already be done differently. |
Beta Was this translation helpful? Give feedback.
-
|
Dudes, did I get it right, that due to kit.files.* deprecation it'll be that alternative: Looks like it fits everything at a first glance |
Beta Was this translation helpful? Give feedback.
-
My use case: multiple route configurations from a single applicationA single SvelteKit application that produces different builds by switching the routes directory via an environment variable: // svelte.config.js
files: {
routes: `src/${env?.BUILD_ROUTES || 'routes'}`
}
Application code, components, and libraries are shared across builds. Only the route entry points differ per build target. Workarounds without this option
Every workaround adds complexity, fragility, and maintenance burden to replace one configuration line that solves this cleanly. |
Beta Was this translation helpful? Give feedback.
-
|
I have a SvelteKit + Rust project. Cargo expects Rust source files in |
Beta Was this translation helpful? Give feedback.
-
|
Just want to let folks know that we won't be deprecating I do think it would be really nice if we could do something like: import { routes as authRoutes } from 'better-auth/svelte-kit';
import { env } from '$env/dynamic/private';
import { PLATFORM } from '$env/static/private';
import { cloudflareRoutes } from 'my-lib';
export default config = {
kit: {
routes: {
configure((routes) => {
if (PLATFORM === 'cloudflare') {
routes.push(cloudflareRoutes);
}
if (env.ADMIN === 'true') {
routes.push(authRoutes);
}
})
}
}
} |
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.libandkit.files.routes(akasrc/libandsrc/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.remotesoption 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
sourceinstead ofsrcorpagesinstead ofroutesfor 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