Skip to content
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

Modularize SvelteKit #2611

Open
benmccann opened this issue Oct 15, 2021 · 3 comments
Open

Modularize SvelteKit #2611

benmccann opened this issue Oct 15, 2021 · 3 comments
Labels
feature request New feature or request size:large significant feature with tricky design questions and multi-day implementation
Milestone

Comments

@benmccann
Copy link
Member

benmccann commented Oct 15, 2021

Describe the problem

A popular point of feedback from the other maintainers is that SvelteKit is not as modular as we had hoped we might make it at the beginning of the project

Describe the proposed solution

We could possible split out a few different pieces:

  • The core router without file system support
  • The file system router depending on the core router
  • Kit itself with Vite integration. We've already split out vite-plugin-svelte and I'm not sure there's much more that makes sense to split out there
  • Put optional features in plugins (e.g. AMP Move amp support to a plugin #2603)

I'd written a bit about this in sveltejs/rfcs#36 originally for Sapper and tried to update the proposal a bit for SvelteKit though further updates may be needed

I don't know whether it'd be possible to make the router implementation pluggable, but I think it'd be a cool goal. I also think it'd be nice to remove any globals which would help for testing (right now you can mostly only write tests if you use Jest and mock the globals) and allow you to have multiple router instances (@pngwn has long asked for microfrontend support and while that's not something I'm overly familiar with I could imagine multiple routers getting pulled in)

Alternatives considered

No response

Importance

nice to have

Additional Information

No response

@benmccann benmccann added this to the 1.0 milestone Oct 15, 2021
@jarda-svoboda
Copy link

A pluggable router might be a way how to possibly create something like this #1251 🤔

@AlbertMarashi
Copy link

AlbertMarashi commented Oct 19, 2021

+1 on standalone router option. Being able to create more configurable routes would be great.

I've created a runtime router for svelte before, so if you want me to provide thoughts I can too.

I had this issue related to generating manifests with for the router though.
sveltejs/svelte#4854

@bertybot
Copy link
Contributor

bertybot commented Nov 3, 2021

Do you think we could put in the option to override the default start.js file? The start.js file makes the system a whole lot less modular. We force an entry into the client with a bunch overhead even if the user doesn't use most of the features, and it also doesn't allow any configuration of the router.

It would be nice if we could write our own start.js or Sveltkit constructor like other JS frameworks. Vue allows you to set the entry with a Vue constructor and configure the features you want al a carte like a Router. We could fall back to the default one if the user don't supply one. It would also save on bundle size since right now the router is still loaded even if the user doesn't use it and ends up as a lot of dead code.

@benmccann benmccann added the feature request New feature or request label Mar 17, 2022
@benmccann benmccann modified the milestones: 1.0, post-1.0 Apr 5, 2022
@benmccann benmccann added the size:large significant feature with tricky design questions and multi-day implementation label Aug 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request size:large significant feature with tricky design questions and multi-day implementation
Projects
None yet
Development

No branches or pull requests

4 participants