-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Change $layout.svelte to @layout.svelte and [param].svelte to {param}.svelte? #1149
Comments
If |
It doesn't need to, since you don't have a reason to type |
Yeah there's no techical reason, more an alignment question |
@GrygrFlzr points out that |
As a vscode user myself I think this change would be great and I'd avoid a considerate amount of URL copy/pasting around. I remember NextJS RFC about this but I don't think the |
Can someone remind me what is the downside of having |
Ha yes, Next and Nuxt explicitly based their dynamic parameter syntax on Sapper — I guess past me accidentally sabotaged them. The prefix is there because |
Also I think it |
Thanks for the clarification @Rich-Harris and I see your point. Looks like we have 2 "special" files (layout, error) that need to be excluded from route creation. It looks like we're saying that the overhead of adding new files to an exclusion list is greater than having a special character to signal this is a 'special' file but at the same time, any special files need to have some code changes associated that would handle those use-cases. When you refer to a breaking change, is this in regards to SvelteKit, sapper or something else? If we're talking about SvelteKit this current stage might be the right time to have breaking changes (if there even a right time for that 😀) Is it an option to have a new folder, something like Thinking about this having a new folder would work for the root files but it wouldn't for nested layouts unless we'd use a similar filesystem structure inside the |
Some findings about the VS Code Ctrl+Click behavior on Windows: src/routes/[dynamic]/[nested]/test.svelte goes to the folder This works the same for
|
@ivoreis It's a breaking change for future versions of SvelteKit that add new special files. It's also just bad design. |
Almost all the other solutions mentioned above give me the gut feeling that things won't work elsewhere. I think using |
@Rich-Harris yeah I agree, while I was typing I got to the same conclusion. So ATM it looks like we have a few options (@, _, $, +) for file special file prefixing, what are the criteria that we'd use to decide the best option? |
For dynamic parameters, it seems that the only plausible characters that don't behave differently between VSCode and iTerm (iTerm makes filenames with
That becomes interactive (i.e. cmd-clickable) in iTerm and VSCode; I can't guarantee the same is true everywhere, but it seems like the surest bet. I still think |
|
|
windows: pissing in the punchbowl since 1985 |
ok, new proposal!
Works without backticks, interactive in both iTerm and VSCode, allowed in windows |
One more.
Tilde has a nice calming wavy effect. Ergonomically easy to reach. |
@arxpoetica With the latter variant, |
@GrygrFlzr yeah, I immediately realized, and deleted my comment—which is why you're yelling into the void. |
Here's an argument for We can also reduce the ugliness by 50%, by having |
I'm indifferent about changing prefixes for stuff like layout files, but I for sure don't like trading |
@dummdidumm I'm coming around to this opinion. |
Have we discarded the underscore (_) option?
I do like how expressive I'm not saying we should change this convention, but if it slightly improves the development experience for everyone, wouldn't we want that @dummdidumm ? |
|
I've added an example that covers that: dynamic routing is wrapped by |
feasible, but deeply confusing |
Yeah, it looks like there isn't any obvious solution. The other option that doesn't need encoding and plays well across multiple systems is the tilde |
Honestly, I'm leaning more toward this being a "bug" with IDEs / terminals that provide clickable links. I no longer favor |
How about using |
|
Any freshly created nuxt project always comes with an preconfigured |
What about using * for those files? like src/routes/*layout.svelte, will it work with vscode and iTerm? |
|
missed that |
Here's an issue for the VS Code bug where I posted some details showing the line number where the bug is in case anyone wants to try fixing VS Code instead of changing SvelteKit: microsoft/vscode#118687 |
I still don't think that |
It's an issue because if we later want to add |
Core team has been bikeshedding this, and we think the best option is to use two underscores for special files:
We don't like any of the alternatives to |
We need to make sure to change this for the manifest files: kit/packages/kit/src/core/dev/index.js Lines 58 to 63 in 3b21b7e
Also we may want to have a test for this. |
* rename $layout to __layout, etc - closes #1149 * changeset * fix cheapwatch options * error on bad files * rename test files * tweak docs * error on encountering $layout etc * fix
Ok hear me out.
I think we closed #894 prematurely; it does make sense to use a character that doesn't require special handling, if possible. It's awkward to type
src/routes/$layout.svelte
on the command line — you get to the$
and either have to reach for the backslash, or curse your lack of forethought in not typing'src
(single quote only, no doubles!) instead ofsrc
.Even if you don't find yourself typing/tab-completing route filenames on the command line frequently, you might find yourself attempting to cmd-click on the filename in your editor's integrated terminal (e.g. in the output from
git diff
ortsc
or whatever) in order to edit the file. At least in VSCode, that doesn't work for filenames containing$layout
, probably because something somewhere is replacing it with thelayout
environment variable.These problems go away with
@
.Related to the cmd-click problem: VSCode doesn't recognise this as a file — if you hover it, it will only highlight the file up to the
[
character:This, on the other hand...
...works perfectly:
I should note that this behaviour appears to be specific to VSCode; iTerm reverses the treatment of
[bar]
and{bar}
. But I think it's probably more important that cmd-click works in integrated editor terminals, and VSCode is the most popular one of the bunch.Aesthetically,
@layout.svelte
and@error.svelte
seem fine, and I actually prefer{param}
to[param]
, not least because it's more aligned with the syntax of Svelte itself.The text was updated successfully, but these errors were encountered: