next-static-paths
next-static-paths copied to clipboard
Sort generated Paths to avoid git diff when running `next-static-paths`
I add as a pre-commit hook to files in pages the next-static-paths
script to generate the static-paths.d.ts
.
I notice that sometimes it creates useless git diff in static-paths.d.ts
that is the same as before but with a different paths order.
Diggin into the code I found it uses globby
inside.
As referenced here https://github.com/sindresorhus/globby/issues/131#issuecomment-513565156 the globby
results are not deterministic. I think this causes the git diff.
Can we sort the results to avoid this useless diff?
We can use globbySync
and run manual sort after it instead of globbyStream
https://github.com/Schniz/next-static-paths/blob/main/packages/next-static-paths/cli/command-generate.ts#L105 here but it can hurt performance a bit
Thanks!