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

Ejecting should keep .babelrc treated as root #1066

Closed
gaearon opened this Issue Nov 20, 2016 · 10 comments

Comments

Projects
None yet
7 participants
@gaearon
Member

gaearon commented Nov 20, 2016

Not sure there's an easy way to fix it but I think that after we eject and generate babel config in package.json it may start looking for more configs in parent folders (which it doesn't do now thanks to this).

If my understanding is correct this might "break" projects on ejecting if there are .babelrc in parent folders.

Help wanted: confirm whether it's an issue, and if it is, propose a fix.

@anilreddykatta

This comment has been minimized.

Contributor

anilreddykatta commented Apr 19, 2017

@gaearon If the project already has a .babelrc with different presets which one do you think should take preference?

@gaearon

This comment has been minimized.

Member

gaearon commented Apr 19, 2017

It is not supported to have .babelrc before ejecting.
I think ejecting should fail if you already have one.

@anilreddykatta

This comment has been minimized.

Contributor

anilreddykatta commented Apr 19, 2017

@gaearon Currently, we fail ejecting if we have .babelrc at project root?

@BrodaNoel

This comment has been minimized.

Contributor

BrodaNoel commented May 22, 2017

@gaearon any clue about it? I can work on it if you give me the first clue about where I should start.

@gaearon

This comment has been minimized.

Member

gaearon commented May 22, 2017

Any clue about what specifically?

@gustavogodoi

This comment has been minimized.

gustavogodoi commented Jan 15, 2018

PR #3803 opened to try to add this validation.

@viankakrisna

This comment has been minimized.

Contributor

viankakrisna commented Jan 24, 2018

eslint has root: true to tell it to stop searching for config in parent folder https://eslint.org/docs/user-guide/configuring#using-configuration-files i think we can port the feature to babel?

edit: related discussion: babel/babel#6766

@gustavogodoi

This comment has been minimized.

gustavogodoi commented Jan 24, 2018

Maybe we could use loader-utils to check the babel config. loaderUtils.getOptions(this).babelrc should get the config.

e.g. from babel-loader:
https://github.com/babel/babel-loader/blob/master/src/index.js#L113

@loganfsmyth

This comment has been minimized.

loganfsmyth commented Jan 30, 2018

Babel will stop searching up the directory hierarchy when it encounters:

  • A directory containing a .babelrc
  • A directory containing a package.json that contains a babel field.

I believe that means this should be fine as long as you create the .babelrc. As mentioned above, with babel/babel#6766 we may also add a concept of a root to Babel which would not search above the given root, among other things.

@stale

This comment has been minimized.

stale bot commented Nov 2, 2018

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 7 days if no further activity occurs.

@stale stale bot added the stale label Nov 2, 2018

@Timer Timer closed this Nov 2, 2018

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