5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-14 17:01:42 +00:00
panel/babel.config.js

72 lines
1.7 KiB
JavaScript
Raw Permalink Normal View History

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-11-19 23:35:29 +00:00
'@babel/preset-env',
{
targets: {
node: 'current'
}
}
],
(isProductionEnv || isDevelopmentEnv) && [
2020-11-19 23:35:29 +00:00
'@babel/preset-env',
{
forceAllTransforms: true,
useBuiltIns: 'entry',
corejs: 3,
modules: false,
exclude: ['transform-typeof-symbol']
}
],
['@babel/preset-typescript', { 'allExtensions': true, 'isTSX': true }]
].filter(Boolean),
plugins: [
2020-11-19 23:35:29 +00:00
'babel-plugin-macros',
'@babel/plugin-syntax-dynamic-import',
isTestEnv && 'babel-plugin-dynamic-import-node',
'@babel/plugin-transform-destructuring',
[
2020-11-19 23:35:29 +00:00
'@babel/plugin-proposal-class-properties',
{
loose: true
}
],
[
2020-11-19 23:35:29 +00:00
'@babel/plugin-proposal-object-rest-spread',
{
useBuiltIns: true
}
],
[
2020-11-19 23:35:29 +00:00
'@babel/plugin-transform-runtime',
{
2020-11-19 23:35:29 +00:00
helpers: false
}
],
[
2020-11-19 23:35:29 +00:00
'@babel/plugin-transform-regenerator',
{
async: false
}
]
].filter(Boolean)
}
}