Skip to content
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

cwd: 'babelrc' doesn't find .babelrc.js #311

Open
good-idea opened this issue Aug 17, 2018 · 5 comments
Open

cwd: 'babelrc' doesn't find .babelrc.js #311

good-idea opened this issue Aug 17, 2018 · 5 comments

Comments

@good-idea
Copy link

I was having trouble getting babel to export aliased modules -- they were always transpiling with absolute paths instead of relative ones. I had been configuring babel with a .babelrc.js file instead of .babelrc --- when I renamed it, things started working as expected.

It would be ideal if .babelrc.js files were supported!

I'm happy to put together a PR for this. It looks like find-babel-config isn't very active, it might make sense to handle this from within this module.

@fatfisz
Copy link
Contributor

fatfisz commented Aug 17, 2018

find-babel-config supports .babelrc.js though: https://github.com/tleunen/find-babel-config/tree/master/test/data/babelrcjs

@tleunen
Copy link
Owner

tleunen commented Aug 22, 2018

Yeah... But we'll have to rework that option with Babel 7 anyway I believe...
babel.config.js works differently than the other filenames (see https://babeljs.io/docs/en/next/babelconfigjs).

So I wonder how useful is the babelrc custom cwd that we have instead of always using the root project... Defaulting on the root project, except if you provide a custom cwd. No more custom magic values.

@good-idea
Copy link
Author

@fatfisz That's odd - I was getting absolute paths (as if it weren't finding the cwd) when I had a .babelrc.js, and it started working with a .babelrc.

@tleunen In the case of a monorepo, with Babel 7's babel.config.js will also be used to help babel identify where package-specific configuration is. I'm not sure of the extent of what the cwd option does --- but the babel.config.js file may not always be the 'correct' working directory.

@tleunen
Copy link
Owner

tleunen commented Aug 22, 2018

What do you mean exactly. If you have one babel.config.js in each "package" in the monorepo. It will be ok. (But then I agree that the project root won't be the same).

But anyway, I think using the new core function loadPartialConfig (as explained here babel/babel#7472) will solve all issues related to that. Since we'll be relying on babel to know what file is used, thus knowing the "root".

@good-idea
Copy link
Author

It looks like babel.config.js will be used for setting up global config, and will ignore .babelrc files:

https://babeljs.io/docs/en/next/babelconfigjs

Unless you opt into them using the babelrcs or babelrcRoots options

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

No branches or pull requests

3 participants