Skip to content

Comments

Ignored imports#16

Open
jlews wants to merge 3 commits intobignimbus:masterfrom
jlews:ignored_imports
Open

Ignored imports#16
jlews wants to merge 3 commits intobignimbus:masterfrom
jlews:ignored_imports

Conversation

@jlews
Copy link

@jlews jlews commented Feb 10, 2020

Because I have some import statements that resolve to files contained in a peer dependant node module, I needed the ability to specify certain paths that the resolver would ignore, leaving the import statements intact.

I've implemented the two options for achieving this that I figured would be most useful to people.

Copy link
Owner

@bignimbus bignimbus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a good feature to have. It would be nice to add options for the new CLI as well (just merged).

pathToImport = this.aliases[aliasKeys[index]];
} else {
pathToImport = capture;
if(this.ignorePaths.indexOf(capture) === -1 && (!this.ignorePathPattern || !this.ignorePathPattern.test(capture))) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about inverting the base case here?

var isIgnored = this.ignorePaths.indexOf(capture) !== -1;
var isPatternIgnored = this.ignorePathPattern && this.ignorePathPattern.test(capture)
if (isIgnored || isPatternIgnored) {
    return m;
}
// ...

To the reader, adding another nesting level makes this method seem more complicated than it actually is with these changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants