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

Generated ROUTES.ts breaks with kebab-cased actions in vite-plugin-kit-routes #858

Closed
MikaelSiidorow opened this issue Jan 27, 2025 · 6 comments

Comments

@MikaelSiidorow
Copy link

Describe the bug

A fresh SvelteKit project with actions:

export const actions: Actions = {
  saveInfo: saveInfo,
  signOut: signOut,
};

Properly generates actions:

const ACTIONS = {
  "saveInfo /": `/?/saveInfo`,
  "signOut /": `/?/signOut`,
}
/* ... */
export type KIT_ROUTES = {
  PAGES: { '/': never, }
  SERVERS: Record<string, never>
  ACTIONS: { 'saveInfo /': never, 'signOut /': never }
  LINKS: Record<string, never>
  Params: Record<string, never>
}

But when using kebab-case:

export const actions: Actions = {
  "save-info": saveInfo,
  "sign-out": signOut,
};

It generates broken ROUTES.ts with:

const ACTIONS = {
  "undefined /": `/?/undefined`,
  "undefined /": `/?/undefined`,
}
/* ... */
export type KIT_ROUTES = {
  PAGES: { '/': never, }
  SERVERS: Record<string, never>
  ACTIONS: { 'undefined /': never, 'undefined /': never }
  LINKS: Record<string, never>
  Params: Record<string, never>
}

Severity

annoyance

Steps to Reproduce the Bug

  1. Create a fresh SvelteKit project
  2. Add vite-plugin-kit-route
  3. Add an action with kebab-case naming
  4. Observe broken generated routes

Reproduction

No response

@MikaelSiidorow MikaelSiidorow changed the title Generated ROUTES.ts breaks with kebab-cased actions in vite-plugin-kit-route Generated ROUTES.ts breaks with kebab-cased actions in vite-plugin-kit-routes Jan 27, 2025
@jycouet
Copy link
Owner

jycouet commented Jan 27, 2025

Thank you for the report, I'll have a look.

Is it common to have actions in kebab-cased ? 😬

@MikaelSiidorow
Copy link
Author

Thank you for the report, I'll have a look.

Is it common to have actions in kebab-cased ? 😬

At least the Svelte docs cleverly avoid multi word actions 😅

I have always used kebab-case in SvelteKit as it feels more web and URL native, but it's not a big deal. I switched to camelCase now to work around this issue, but it's suspicious that it breaks like so

jycouet added a commit that referenced this issue Jan 29, 2025
@jycouet
Copy link
Owner

jycouet commented Jan 29, 2025

Could you test on vite-plugin-kit-routes@0.8.0 ? And let me know ?
I let you close the issue if everything works fine ✌️

@jycouet jycouet reopened this Jan 29, 2025
@jycouet

This comment has been minimized.

This comment has been minimized.

@MikaelSiidorow
Copy link
Author

@jycouet it looks to be working perfectly now! Awesome 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants