vercel / next.js

The React Framework
https://nextjs.org
MIT License
122.59k stars 26.23k forks source link

Allow parallel route slot names in kebab-case #67151

Open joulev opened 4 days ago

joulev commented 4 days ago

What?

This PR adds support for parallel route slot names written with kebab-case. So instead of @deleteModal, we can have @delete-modal.

Why?

There are projects that prefer to use exclusively kebab-case for file/folder names due to various reasons, such as to prevent issues related to how different operating systems handle file system casing.

However, currently, parallel route slot names must be a valid JavaScript variable name. This PR aims to relax this requirement.

How?

- .map(([key, value]) => `${key}: ${value}`)
+ .map(([key, value]) => `${JSON.stringify(key)}: ${value}`)

This alone is not enough to support parallel route slot names like @!@#$%^&*(), but should be well enough to support more normal file name conventions. (Even slot names with a space are supported.)

ijjk commented 4 days ago

Allow CI Workflow Run

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

joulev commented 4 days ago

Now that I've written this, @/dirtycajunrice made a very good point: it would be a cool idea to automatically transform kebab-case slot names to camelCase, sort of like how Nuxt does transforming for component names. If this sounds good to you, let me know and I will try to implement that.

app/
  @slot-name/
    ...
  layout.tsx <- { children: React.ReactNode, slotName: React.ReactNode }