Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does a "babel" field in package.json take precedence over a .babelrc file?

Tags:

babeljs

If I've got a .babelrc file and a "babel" field in package.json, what happens?

Do the settings get merged? And which settings take precedence?

The docs don't say.

like image 734
callum Avatar asked Oct 17 '15 14:10

callum


1 Answers

Babel will take setting in .babelrc as final over cli or any other source of config.

No merging of settings will occur either as babel will drop any previous settings when it encounters .babelrc

So when .babelrc is present only the settings contained in that file will be active.

Could you clarify your answer: Does this mean settings are merged and those in .babelrc take precedence?

No settings will be merged and the .babelrc settings will take precedence over everything else.

The exception to this however could occur when webpack is used since having babel as a loader with option babelrc: false, will omit .babelrc setting from the webpack flow. This can be useful if there are other packages that rely on babel but are not necessery or compatible with webpack.

like image 143
Bartekus Avatar answered Oct 18 '22 13:10

Bartekus