mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Do not use env
key in Babel common preset (#48661)
The merging behavior of having both `plugins` and `env.test.plugins` in the Babel configuration is confusing and does not work how we would like (that is, disabling the idx Babel plugin in test environments.) There had been some [discussion about deprecating the `env` key in Babel](https://github.com/babel/babel/issues/5276) because of this behavior and recommending using conditional logic. The behavior has been modified in later versions of Babel, but still does not work as intended in our case. Change this to only add the idx plugin if we're in a non-test environment.
This commit is contained in:
parent
cc6aff7433
commit
fa951abfdc
1 changed files with 8 additions and 8 deletions
|
@ -28,17 +28,17 @@ const plugins = [
|
|||
// See https://github.com/babel/proposals/issues/12 for progress
|
||||
require.resolve('@babel/plugin-proposal-class-properties'),
|
||||
];
|
||||
const isTestEnv = process.env.BABEL_ENV === 'test' || process.env.NODE_ENV === 'test';
|
||||
|
||||
// Only load the idx plugin in non-test environments, since it conflicts with
|
||||
// Jest's coverage mapping.
|
||||
if (!isTestEnv) {
|
||||
plugins.push(require.resolve('@kbn/elastic-idx/babel'));
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
presets: [require.resolve('@babel/preset-typescript'), require.resolve('@babel/preset-react')],
|
||||
plugins: plugins.concat(require.resolve('@kbn/elastic-idx/babel')),
|
||||
// Do not use the idx plugin in the test environment because it causes
|
||||
// causes conflicts with Jest's coverage mapping.
|
||||
env: {
|
||||
test: {
|
||||
plugins,
|
||||
},
|
||||
},
|
||||
plugins,
|
||||
overrides: [
|
||||
{
|
||||
// Babel 7 don't support the namespace feature on typescript code.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue