-
-
Notifications
You must be signed in to change notification settings - Fork 432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Increase build performance by skipping node_modules file lookups #1226
base: main
Are you sure you want to change the base?
Conversation
Skip attempting to lookup node_modules output files names inside getInputFileNameFromOutput. This should never resolve if the allowTsInNodeModule loader option is not set
Thanks for contributing! This is a pretty discreet change and, on the face of it, it seems pretty safe to roll with. @andrewbranch do you have any views on this? I'm mindful of your comments here: #1215 (comment) It would be straightforward to revert this if it turns out to be problematic. |
Side note: it's time to drop Travis usage. I believe they've dropped free support for open source projects. Fortunately @g-plane has already sorted out support with GitHub actions and so we're good. Funny old year, first appveyor starts consistently failing so we have to move away from that. Now Travis. Good odds on GHAs longterm support though 😉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nit to start with. I’ll have to investigate what this is used for in order to understand whether allowTsInNodeModules
is a sufficient guard for it. Maybe I’ll try making an example project with node_modules symlinks.
Co-authored-by: Andrew Branch <[email protected]>
I couldn’t observe any bad effects with this—when using a monorepo with symlinked packages through node_modules, I only ever witnessed the realpath being passed through here. With the |
I think there's a couple holes in the file watch/resolution paths based on some evidence I've seen in profiling. Specifically, there's a few caches that are cached at the beginning of every watch-build (fileExists, directoryExists cache) that result in a ton of filesystem operations to repopulate. These operations end up causing a bunch of additional garbage collection (as seen in #1228 both before and after). I'm guessing that there's a smarter approach that can be taken to invalidate only the portions of the affected cache based on webpack-watch callback. (An investigation like that would require a bit more understanding about the internal workings of the typescript compiler and ts-loader than I currently possess) |
@@ -852,6 +852,14 @@ export function makeSolutionBuilderHost( | |||
function getInputFileNameFromOutput( | |||
outputFileName: string | |||
): string | true | undefined { | |||
// Unless we explicitly want to compile files in node_modules, exclude them from lookups | |||
if ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @andrewbranch i am not familiar with monorepo projects out there that this will impact. I think somewhere we are missing the cache and that would be better solution in my opinion
Just wanted to check in here again. We've been using a patched version of ts-loader with this change with good success. I realize that there's probably a better solution deals with the multiple different runtime caches that exist, but unfortunately I don't have the familiarity or the bandwidth to work on this now. I'd love to bring this PR to a resolution before it gets too stale. |
Hey @berickson1 Thanks for checking in. I'm mindful of @sheetalkamat's comment:
My gut feeling is that if we merged this as is we'd probably get you to a better working place but break others. That makes me a little nervous I'm afraid. |
I understand your sentiment and can sympathize. Given there's nobody else clamouring for this, it might be fine to close it out and keep us running on a fork (not ideal, but we will live). Eventually if this is solved "properly" , we could remove the patch in our fork. If you (or someone else) were able to provide a cut more guidance about how the internal caches are supposed to behave, I may be able to help validate that. From my prior observations, the majority of caches are wiped out on file change callbacks, which seems to be the root of the problem. I'm just nervous to start blindly making changes there :) |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Closing as stale. Please reopen if you'd like to work on this further. |
FWIW, We've been running with a patched version of ts-loader with this optimization since the PR has been opened with no unexpected effects |
I'm open to us adding this - but I'd quite like for this to use the cache approach suggested by Andrew / Sheetal question @berickson1 : are you running on webpack 5? |
|
How would you feel about implementing the cache approach suggested by @sheetalkamat / @andrewbranch ? |
Skip attempting to lookup node_modules output files names inside getInputFileNameFromOutput. This should never resolve if the allowTsInNodeModule loader option is not set.
Tested in a closed-source project & showed a large improvement in speed over 8.0.12 (~20% decrease in build times)
Relates to #1215