next.js
a9c3206c - feat: make typed routes output deterministic (#80432)

Commit
195 days ago
feat: make typed routes output deterministic (#80432) ### What? This PR makes changes to the next plugin for typed routes. The issue here is that the output of the plugin, specifically the part where static and dynamic routes are defined changes constantly. This PR makes the output of the plugin deterministic. ### Why? We work in a monorepo with multiple Next.js projects. We encountered multiple issues with git and git hooks. If you had a stale `.next` output the routes type would also be stale and caused issues on commit when you want to sync your work with an upbranch causing either to rebuild the app you are not developing or completly removing the `.next` folder. As a solution we choose to commit `.next/types/link.d.ts` (the output file of the mentioned next.js plugin) and that solved the issue. Now we have a smaller issue regarding the un-deterministic file output which I want to solve with this MR. ### How? Before writing the routes in the file, the routes are sorted using native `sort` method on the array instance. The actual sort order is not relevant here, the fact that the output is in the same order everytime is the key. --------- Co-authored-by: Steven <steven@ceriously.com>
Author
Parents
Loading