Sha256: 11e9d7a26eb14c4ac492ea8c261c94392d56720244ff5aa5ac375af8721d69fa

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 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,
          exclude: ["transform-typeof-symbol"]
        }
      ],
      moduleExists("@babel/preset-typescript") && "@babel/preset-typescript"
    ].filter(Boolean),
    plugins: [["@babel/plugin-transform-runtime", { helpers: false }]].filter(
      Boolean
    )
  }
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shakapacker-8.0.2 package/babel/preset.js
shakapacker-8.0.1 package/babel/preset.js