perf: memorize exclude function in webpack config (#81525)
During JavaScript profiling, I identified repeated calls to the exclude
function in the webpack configuration and implemented caching to
optimize it.
<img width="2248" height="772" alt="image"
src="https://github.com/user-attachments/assets/1fdb03f3-2904-4195-a538-7b1f4646f0f2"
/>
I tested the performance using the
[chakra-ui-docs](https://github.com/SyMind/chakra-ui-docs) repository
with the following steps:
1. Execute `pnpm run dev`
2. Wait for the server to be ready (indicated by the 'Ready' message)
3. Run `curl` on the root endpoint (`/`)
| | Webpack | Rspack |
|-|-|-|
|After| Compiled / in 8.3s (2682 modules) | Compiled / in 2.3s (2650
modules) |
|Before| Compiled / in 7.8s (2682 modules) | Compiled / in 1983ms (2650
modules) |
---------
Co-authored-by: Benjamin Woodruff <github@benjam.info>