Overhaul crawler options building and handling - #174
Merged
Conversation
commit: |
Contributor
Author
|
I'm a bit unhappy with this part in const cwd = options.cwd as string;
if (Array.isArray(patterns) && patterns.length === 0) {
return [];
}
const props: InternalProps = { root: cwd, depthOffset: 0 };
return buildCrawler(props, options, processPatterns(options, patterns, props), cwd);I want to separate the concerns of each step of |
SuperchupuDev
left a comment
Owner
There was a problem hiding this comment.
two small nits, other than that lgtm!!! you're doing an amazing cleanup work ❤️
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal
The goal of this PR is to reduce duplicate logic of building and handling the
Crawlerby reusing harmonizing flags and be more resilient to the result ofgetCrawler.Why
This change is necessary out of three reasons:
Instead of explicitly setting flags based on the given options, we reuse flags that logically harmonize states of
fdir.What has changed
Crawler,ProcessedPatternsandRelativeMapperand stricten types by adding explicit return types to some functions.Crawlerinto an extra file for easier project maintenance.fdiroptions by reusing harmonizingGlobOptionsoptions.buildCrawlerasExcludePredicateunder the assumption developers withdebug: truedon't have performance as their highest priority (yes, this impacts debugging performance very minimally)formatPathsmore resilent by always entering the function upongetCrawlerresult.noopfunctions on empty patterns to crawl, we now handle anundefinedCrawlerandRelativeMapper.commonPathinsideInternalPropshas been changed fromnulltoundefinedto reduce code.Metrics
From Part 2 (#170) to Part 3, we now have an even further reduction
Before All:
After Part 2 (#170) [CURRENT]:
After this Part:
Total shipped sizes
Before all:
14.22KB + 12.92KB + 4.7KB + 4.7KB = 36.54KBAfter part 2:
13.76 KB + 12.49 kB + 4.70 kB + 4.70 kB = 35.65 kBAfter this part:
13.40 KB + 12.14 KB + 4.7 KB + 4.7 KB = 34.94 KBThis is a bundle size reduction of
1.6 KB(4.3%) and saves60.8 GB(38 million weekly downloads) of weekly traffic.This PR is a split part of the closed PR #88, which grew too much in scope and changes.