New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose findbabelrc method #7259
Conversation
rajasekarm
commented
Jan 23, 2018
Q | A |
---|---|
Fixed Issues? | |
Patch: Bug Fix? | |
Major: Breaking Change? | |
Minor: New Feature? | |
Tests Added + Pass? | |
Documentation PR | |
Any Dependency Changes? | |
License | MIT |
Im all in for this change - it would be good though to document why this is needed. Most times finding this should be left to babel |
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/6837/ |
I think that we should expose a method which loads the config (merges the applicable |
@@ -30,7 +30,7 @@ export function findBabelrc( | |||
filepath: string, | |||
envName: string, | |||
): ConfigFile | null { | |||
const dirname = path.dirname(filepath); | |||
const dirname = filepath ? path.dirname(filepath) : process.cwd(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also consider changing this function to accept a dirname
as the argument. Then you can call
findBabelrc(process.cwd(), "");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One concern I have about exposing this is that we probably want to change the signature of this function more in the future, and it will be easy to miss that we're breaking a public API. I'm wondering if it would be better to make a new function right in src/index.js
that calls through to this. For instance we may add flags to tell a the .babelrc.js
file whether Babel allows a promise to be returned, and we'll probably add another parameter for passing a root
folder to stop searching at.
Yeah, this seems more useful :) still I'd like to discuss exact use cases (we could even list them in the docs and advise people not to use it for regular use cases) |
I'm going to close this for now since I don't think it's what we want, but I do think exposing something will be good, and we can continue this discussion in Slack. |