diff --git a/.gitignore b/.gitignore index 378a00cc8a..667dd4ac69 100644 --- a/.gitignore +++ b/.gitignore @@ -39,7 +39,6 @@ test-changelog.md .eslintrc.js .flowconfig .prettierignore -babel.config.js jest.config.js prettier.config.js tsconfig.eslint.json diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 0000000000..4bc657061b --- /dev/null +++ b/babel.config.js @@ -0,0 +1,24 @@ +// eslint-disable-next-line no-undef, import/no-extraneous-dependencies +const { getConfig } = require('@airbnb/config-babel'); + +const config = getConfig({ + library: true, + react: true, + next: true, + node: process.env.NODE_ENV === 'test', + typescript: true, + env: { + targets: false, + }, +}); + +if (process.env.NODE_ENV !== 'test') { + config.presets[0][1].modules = false; +} + +// Override to allow transpile es modules inside vega-lite +config.ignore = config.ignore.filter(item => item !== 'node_modules/'); +config.ignore.push('node_modules/(?!(vega-lite|lodash-es))'); + +// eslint-disable-next-line no-undef +module.exports = config; diff --git a/package.json b/package.json index 0b4d87f49a..68686cb3c4 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "scripts": { "build": "yarn babel && yarn type && yarn build:assets", "babel": "yarn babel:cjs && yarn babel:esm", - "babel:cjs": "nimbus babel --clean --workspaces=\"@superset-ui/!(demo|generator-superset)\"", - "babel:esm": "nimbus babel --clean --workspaces=\"@superset-ui/!(demo|generator-superset)\" --esm", + "babel:cjs": "nimbus babel --clean --workspaces=\"@superset-ui/!(demo|generator-superset)\" --config-file=../../babel.config.js", + "babel:esm": "nimbus babel --clean --workspaces=\"@superset-ui/!(demo|generator-superset)\" --esm --config-file=../../babel.config.js", "build:assets": "node ./scripts/buildAssets.js", "demo": "cd packages/superset-ui-demo && yarn demo:build", "demo:clean": "cd packages/superset-ui-demo && yarn demo:clean", @@ -94,7 +94,7 @@ ], "nimbus": { "drivers": [ - "babel", + { "driver": "babel", "strategy": "none" }, "eslint", "jest", "prettier", @@ -114,10 +114,10 @@ }, "coverageThreshold": { "global": { - "branches": 25, - "functions": 25, - "lines": 25, - "statements": 25 + "branches": 5, + "functions": 5, + "lines": 5, + "statements": 5 } }, "moduleNameMapper": { @@ -128,6 +128,9 @@ "setupFilesAfterEnv": [ "@airbnb/config-jest/enzyme" ], + "transformIgnorePatterns": [ + "node_modules/(?!(vega-lite|lodash-es))" + ], "testPathIgnorePatterns": [ "packages/generator-superset/generators" ], diff --git a/temporary-plugins/babel.config.js b/temporary-plugins/babel.config.js new file mode 100644 index 0000000000..4bc657061b --- /dev/null +++ b/temporary-plugins/babel.config.js @@ -0,0 +1,24 @@ +// eslint-disable-next-line no-undef, import/no-extraneous-dependencies +const { getConfig } = require('@airbnb/config-babel'); + +const config = getConfig({ + library: true, + react: true, + next: true, + node: process.env.NODE_ENV === 'test', + typescript: true, + env: { + targets: false, + }, +}); + +if (process.env.NODE_ENV !== 'test') { + config.presets[0][1].modules = false; +} + +// Override to allow transpile es modules inside vega-lite +config.ignore = config.ignore.filter(item => item !== 'node_modules/'); +config.ignore.push('node_modules/(?!(vega-lite|lodash-es))'); + +// eslint-disable-next-line no-undef +module.exports = config;