When populating ExportMap, only load file if it's not ignored#1519
Merged
Conversation
fa64e29 to
f5123cc
Compare
5 similar comments
ljharb
approved these changes
Dec 5, 2019
f5123cc to
fb8ae71
Compare
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.
I was debugging a project trying to understand better how the
import/no-deprecatedrule works. While doing this I discovered thatExportMap.forwill do a I/O hit to read thepatheven if thepathis ignored:https://github.com/benmosher/eslint-plugin-import/blob/112a0bf442e52b25cd7029a9905df2508e191ac1/src/ExportMap.js#L313-L320
When the
pathis ignored, the function early exits and thecontentvariable is not referenced, so it's essentially a wasted I/O hit.This PR tweaks the condition to do the ignore check in one block, and check ambiguity in another.
In theory this should result in a performance boost for projects that ignore many paths as they will be skipped based off the ignore, rather than being loaded from the file system. It also cleans up the log a little bit because we know exactly why the path was ignored, because of the regex, or because it's ambiguous.