Sha256: d42c2bf1b00484648dcdced90c51d77cbede20ad57191138f7c53aa23c5b85d2

Contents?: true

Size: 1.21 KB

Versions: 10

Compression:

Stored size: 1.21 KB

Contents

const { moduleExists } = require('shakapacker')

module.exports = function config(api) {
  const validEnv = ['development', 'test', 'production']
  const currentEnv = api.env()
  const isDevelopmentEnv = api.env('development')
  const isProductionEnv = api.env('production')
  const isTestEnv = api.env('test')

  if (!validEnv.includes(currentEnv)) {
    throw new Error(
      `Please specify a valid NODE_ENV or BABEL_ENV environment variable. Valid values are "development", "test", and "production". Instead, received: "${JSON.stringify(
        currentEnv
      )}".`
    )
  }

  return {
    presets: [
      isTestEnv && ['@babel/preset-env', { targets: { node: 'current' } }],
      (isProductionEnv || isDevelopmentEnv) && [
        '@babel/preset-env',
        {
          useBuiltIns: 'entry',
          corejs: '3.8',
          modules: 'auto',
          bugfixes: true,
          loose: true,
          exclude: ['transform-typeof-symbol']
        }
      ],
      moduleExists('@babel/preset-typescript') && [
        '@babel/preset-typescript',
        { allExtensions: true, isTSX: true }
      ]
    ].filter(Boolean),
    plugins: [
      ['@babel/plugin-transform-runtime', { helpers: false }]
    ].filter(Boolean)
  }
}

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
shakapacker-6.2.1 package/babel/preset.js
shakapacker-6.2.0 package/babel/preset.js
shakapacker-6.1.1 package/babel/preset.js
shakapacker-6.1.0 package/babel/preset.js
shakapacker-6.1.0.beta.0 package/babel/preset.js
shakapacker-6.0.2 package/babel/preset.js
shakapacker-6.0.1 package/babel/preset.js
shakapacker-6.0.0 package/babel/preset.js
shakapacker-6.0.0.rc.14 package/babel/preset.js
shakapacker-6.0.0.rc.13 package/babel/preset.js