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

module resolving when cwd === "babelrc" #43

Closed
mikemonteith opened this issue Feb 17, 2017 · 9 comments · Fixed by #55
Closed

module resolving when cwd === "babelrc" #43

mikemonteith opened this issue Feb 17, 2017 · 9 comments · Fixed by #55
Assignees
Labels

Comments

@mikemonteith
Copy link

babel-plugin-module-resolver treats the string "babelrc" as a special case, which is not supported by this resolver.
From babel-plugin Readme:

cwd: By default, the working directory is the one used for the resolver, but you can override it for your project.
The custom value babelrc will make the plugin look for the closest babelrc configuration based on the file to parse.

babel-plugin relevant code:
https://github.com/tleunen/babel-plugin-module-resolver/blob/master/src/index.js#L53

@brannon
Copy link

brannon commented Feb 23, 2017

I just ran into this as well. Debugging through this plugin, I can see that it's not translating the value babelrc to the directory of the .babelrc file, it's using it as a literal directory name.

@tleunen
Copy link
Owner

tleunen commented Feb 23, 2017

Thank you for reporting this @mikemonteith. I'll try to take a look at it this weekend if nobody takes it before.

laurence-hudson-tessella added a commit to laurence-hudson-tessella/eslint-import-resolver-babel-module that referenced this issue Feb 28, 2017
laurence-hudson-tessella added a commit to laurence-hudson-tessella/eslint-import-resolver-babel-module that referenced this issue Feb 28, 2017
@laurence-hudson-tessella

Have submitted a trival PR. It resolve this issue for me (babelrc & eslintrc are both in the repo root directory, but I still need to set cwd: 'babelrc' because I need to run babel-node from directories which aren't the repo root). I'm not sure about other contexts.

@brannon
Copy link

brannon commented Mar 21, 2017

Any luck with the pull request?

@laurence-hudson-tessella

Nope, it has been open for >20 days, without comment. #45. In the short term I've just been using "eslint-import-resolver-babel-module": "laurence-hudson-tessella/eslint-import-resolver-babel-module#8c76c7d11285f8297a53462fed77c4cc5d5c8e03", in my devDeps.

@tleunen
Copy link
Owner

tleunen commented Mar 22, 2017

I'm sorry, I'm very busy since the beginning of the year.

We need to update the plugin to handle the babelrc string. Pretty much the same logic as what we can find here https://github.com/tleunen/babel-plugin-module-resolver/blob/master/src/index.js#L78-L87. I might also export the function from the babel plugin to keep the logic in one place only.

@tleunen
Copy link
Owner

tleunen commented Apr 25, 2017

Please try again with 4.0.0-beta.1 :)

@laurence-hudson-tessella

Thanks Tommy, 4.0.0-beta.1 with 3.0.0-beta.0 of the babel plugin works in my scenario (ie babelrc & eslintrc are both in the repo root directory).

@tleunen
Copy link
Owner

tleunen commented Apr 25, 2017

Great! Thank you for reporting this.

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