Skip to content
This repository has been archived by the owner on Jun 8, 2023. It is now read-only.

fix: Add support for custom resolvePath from babel plugin #109

Merged
merged 1 commit into from
Jan 23, 2020

Conversation

johnny-c-jiang
Copy link
Contributor

babel-plugin-module-resolver supports customized resolver function which eslint-import-resolver-babel-module currently ignores, but should allow user to reuse

@codecov
Copy link

codecov bot commented Jan 16, 2020

Codecov Report

Merging #109 into master will increase coverage by 0.19%.
The diff coverage is 100%.

Impacted Files Coverage Δ
src/index.js 94.64% <100%> (+0.19%) ⬆️

Copy link
Owner

@tleunen tleunen left a comment

Choose a reason for hiding this comment

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

Sorry for the delay @johnny-c-jiang.

Minor comment, but it look good otherwise.

@@ -98,12 +99,14 @@ exports.resolve = (source, file, opts) => {
cwd: options.cwd || projectRootDir,
root: options.root || [],
alias: options.alias || {},
resolvePath: options.resolvePath,
Copy link
Owner

Choose a reason for hiding this comment

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

Shouldn't this be resolvePath: options.resolvePath || resolvePath?
So that you can remove your line 108 and always get the src from pluginOptions.resolvePath?

Copy link
Contributor Author

@johnny-c-jiang johnny-c-jiang Jan 22, 2020

Choose a reason for hiding this comment

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

Shouldn't this be resolvePath: options.resolvePath || resolvePath?
So that you can remove your line 108 and always get the src from pluginOptions.resolvePath?

I thought about it. It's similar, but due to the importance of resolvePath function, I made the fallback assignment right before it's being used, so if there's a falsy value coming from options or plugin, the module still works.

Could make the suggested change if you feel strongly about it :)

Copy link
Owner

Choose a reason for hiding this comment

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

so if there's a falsy value coming from options or plugin, the module still works.

In theory, this should really never happen since resolvePath will be the first default value being set. So any falsy value will always result to using the default function.

But I see your point to make extra sure (especially without using typescript here), so I'll accept it ;)

@tleunen tleunen changed the title Add customized resolvePath support fix: Add support for custom resolvePath from babel plugin Jan 23, 2020
@tleunen tleunen merged commit 5708051 into tleunen:master Jan 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants