Urthen / case-sensitive-paths-webpack-plugin

Enforces case sensitive paths in Webpack requires.
MIT License
428 stars 45 forks source link

Speed improvements #46

Open ivasilov opened 4 years ago

ivasilov commented 4 years ago

Hey,

I ran some benchmarks on my webpack config and I saw that this plugin takes a significant time. After trying some rewrites and optimizations,I brought a 7-8 seconds build down to 5-6 seconds through the following speed improvements:

All in all, this brings 1200+ directory reads down to ~400. I also rewrote the package in Typescript to avoid any type bugs.

I can submit all improvements as separate PRs (for easier reviewing). Would you be interested in merging them?

Urthen commented 4 years ago

Hi there! I'd definitely love to see the use of promises - Originally this was written to support back to Node 4, but at this point even 8 is out of maintenance so I see no reason not to support native promises.

If you can improve caching too, by all means, and adding an ignore path makes sense. Not the first time that has come up.

As for the recursive parent path reads, that's actually intentional. Those calls are how this plugin checks the case on each directory in the path. Without them, you could get into a situation where a directory has the wrong case. Looking at the tests, I think I might not have actually written a test case for that, so even if you ran the tests I suspect this still might be a problem. I'll take a look at adding additional tests.

As for Typescript, I appreciate the effort but don't use it myself - rewriting to Typescript could make any future maintenance tasks for me harder.

Urthen commented 4 years ago

FYI I just added a new test which should verify that nested folder names are being caught. If you're going to take a further look at recursive parent reads, make sure this new test passes.

helloneele commented 4 years ago

👋 Would it be possible to get a release for the latest changes that got merged @Urthen? 🙂