houdini/babel.config.js

103 lines
2.6 KiB
JavaScript
Raw Normal View History

2019-11-05 22:39:13 +00:00
module.exports = function(api) {
var validEnv = ['development', 'test', 'production']
var currentEnv = api.env()
var isDevelopmentEnv = api.env('development')
var isProductionEnv = api.env('production')
var isTestEnv = api.env('test')
if (!validEnv.includes(currentEnv)) {
throw new Error(
'Please specify a valid `NODE_ENV` or ' +
'`BABEL_ENV` environment variables. Valid values are "development", ' +
'"test", and "production". Instead, received: ' +
JSON.stringify(currentEnv) +
'.'
)
}
return {
presets: [
isTestEnv && [
2020-05-27 22:05:25 +00:00
'@babel/preset-env',
2019-11-05 22:39:13 +00:00
{
targets: {
2020-05-27 22:05:25 +00:00
node: 'current',
},
modules: 'commonjs',
},
'@babel/preset-react',
2019-11-05 22:39:13 +00:00
],
(isProductionEnv || isDevelopmentEnv) && [
2020-05-27 22:05:25 +00:00
'@babel/preset-env',
2019-11-05 22:39:13 +00:00
{
forceAllTransforms: true,
useBuiltIns: 'entry',
corejs: 3,
modules: false,
2020-05-27 22:05:25 +00:00
exclude: ['transform-typeof-symbol'],
},
2020-05-27 18:07:17 +00:00
],
2020-05-27 22:05:25 +00:00
[
'@babel/preset-react',
{
development: isDevelopmentEnv || isTestEnv,
useBuiltIns: true,
},
],
['@babel/preset-typescript', { 'allExtensions': true, 'isTSX': true }],
2019-11-05 22:39:13 +00:00
].filter(Boolean),
plugins: [
2020-05-27 22:05:25 +00:00
'babel-plugin-macros',
'@babel/plugin-syntax-dynamic-import',
isTestEnv && 'babel-plugin-dynamic-import-node',
'@babel/plugin-transform-destructuring',
["@babel/plugin-proposal-decorators", { legacy: true }],
2019-11-05 22:39:13 +00:00
[
2020-05-27 22:05:25 +00:00
'@babel/plugin-proposal-class-properties',
2019-11-05 22:39:13 +00:00
{
2020-05-27 22:05:25 +00:00
loose: true,
},
2019-11-05 22:39:13 +00:00
],
[
2020-05-27 22:05:25 +00:00
'@babel/plugin-proposal-object-rest-spread',
2019-11-05 22:39:13 +00:00
{
2020-05-27 22:05:25 +00:00
useBuiltIns: true,
},
2019-11-05 22:39:13 +00:00
],
[
2020-05-27 22:05:25 +00:00
'@babel/plugin-transform-runtime',
2019-11-05 22:39:13 +00:00
{
helpers: false,
regenerator: true,
2020-05-27 22:05:25 +00:00
corejs: false,
},
2019-11-05 22:39:13 +00:00
],
[
2020-05-27 22:05:25 +00:00
'@babel/plugin-transform-regenerator',
2019-11-05 22:39:13 +00:00
{
2020-05-27 22:05:25 +00:00
async: false,
},
],
isProductionEnv && [
'babel-plugin-transform-react-remove-prop-types',
{
removeImport: true,
},
],
isDevelopmentEnv && [
'babel-plugin-transform-imports',
{
'@material-ui/core': {
'transform': '@material-ui/core/esm/${member}',
'preventFullImport': true
},
'@material-ui/icons': {
'transform': '@material-ui/icons/esm/${member}',
'preventFullImport': true
}
}
]
2020-05-27 22:05:25 +00:00
].filter(Boolean),
2019-11-05 22:39:13 +00:00
}
}