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

Too many index.svelte files in SvelteKit demo app #1874

Closed
bfanger opened this issue Jul 11, 2021 · 3 comments · Fixed by #1878 · May be fixed by leonardoadame/Affiliate-tech#967, leonardoadame/Affiliate-tech#974 or leonardoadame/Affiliate-tech#978

Comments

@bfanger
Copy link
Contributor

bfanger commented Jul 11, 2021

Describe the problem

  • "index" does not describe the component
  • Showing the filename in the editor tab is no longer enough
  • Automatic importing gets unnecessary complicated (does't work)
  • command+p to open a component doesn't works as good
  • git: Reading the Changes is slightly harder

Describe the proposed solution

Rename the "src/lib/Counter/index.svelte" to "src/lib/Counter/Counter.svelte"

Keep the src/routes/todos/index.svelte as-is, that filename is used for routing.
(I'd personally would split the rendering of the form of into a component, but for example-code it's easier to digest if it remains in a single file )

Alternatives considered

I've worked with vue and react codebases that worked with lots of index.ts files. When I've renamed these files to have meaningful and predictable filenames the reaction has been universally positive.

An alternative is to do nothing, the filename convention in the example does not affect how we setup a svelte-kit project.

Importance

nice to have

@dummdidumm
Copy link
Member

This would be a breaking change as the semantics for counter/Counter.svelte right now would be "url is counter/counter. For refactoring, you now would need to rename both the file and the folder when you want to change the URL, you could miss one of those renames and have a weird error.
I too don't like code bases with too many files that have the same name, but the IDEs (for me at least) do a pretty good job at showing the whole path which makes it easy to spot what index file I'm after. I can even search for a file "counter" and (VS Code at least) the index file also shows up.

@bfanger
Copy link
Contributor Author

bfanger commented Jul 11, 2021

@dummdidumm No, the change i suggest is not for the src/routes/**/*.svelte, its for the src/lib/**/*.svelte

If you want to write any component the demo template suggests to create a folder with the component name with an index.svelte inside.

@dummdidumm
Copy link
Member

Ah okay, thanks for the clarification. So this is only about the setup template showcasing something which is not ideal in your opinion (which I agree with in this case btw).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment