next.js
7a05d5d2 - fix(build): improve static path generation performance and fix parameter collisions (#81254)

Commit
179 days ago
fix(build): improve static path generation performance and fix parameter collisions (#81254) ## Summary • **Performance**: Replace O(n²) parameter deduplication with O(n) Map-based approach • **Architecture**: Rewrite `assignErrorIfEmpty` using [Trie data structure](https://en.wikipedia.org/wiki/Trie) • **Testing**: Add comprehensive test coverage for edge cases including parameter collisions and complex route hierarchies ## Technical Details ### Performance Optimization - **Before**: O(n²) nested loops comparing each parameter combination against all previous ones - **After**: O(n) Map-based deduplication using unique string keys for each parameter combination - **Impact**: Significant performance improvement for routes with many parameter combinations ### Trie-Based Route Analysis Replaces linear route comparison with efficient Trie data structure: - **Nodes**: Represent unique parameter combinations - **Edges**: Represent parameter values with collision-safe keys - **Algorithm**: [DFS traversal](https://en.wikipedia.org/wiki/Depth-first_search) determines `throwOnEmptyStaticShell` based on child relationships **Example**: For routes `/blog/[slug]` and `/blog/first-post`: - Trie identifies `/blog/[slug]` as parent to concrete route `/blog/first-post` - Sets `throwOnEmptyStaticShell = false` for parent, `true` for concrete route
Author
Parents
Loading