Permalink
Browse files

babel-preset: fix config to work even in non-static or non production…

… env
  • Loading branch information...
MoOx committed Dec 9, 2018
1 parent cd190c3 commit c3d16873daec4349ddc76d8a688affcdc91d507a
Showing with 15 additions and 10 deletions.
  1. +15 −10 packages/babel-preset/src/index.js
@@ -59,25 +59,30 @@ module.exports = () => ({
// Polyfills the runtime needed for async/await, generators, and friends
// https://babeljs.io/docs/en/babel-plugin-transform-runtime
[
require("@babel/plugin-transform-runtime").default,
require("@babel/plugin-transform-runtime"),
{
corejs: false,
helpers: false,
regenerator: true,
useESModules: process.env.PHENOMIC_ENV === "static",
},
],
process.env.NODE_ENV === "production" && [
// Remove PropTypes from production build
require("babel-plugin-transform-react-remove-prop-types").default,
{
removeImport: true,
},
],
...(process.env.NODE_ENV === "production"
? [
[
// Remove PropTypes from production build
require("babel-plugin-transform-react-remove-prop-types"),
{
removeImport: true,
},
],
]
: []),
// Adds syntax support for import()
require("@babel/plugin-syntax-dynamic-import"),
// Transform dynamic import to require
process.env.PHENOMIC_ENV === "static" &&
require("babel-plugin-dynamic-import-node"),
...(process.env.PHENOMIC_ENV === "static"
? [require("babel-plugin-dynamic-import-node")]
: []),
],
});

0 comments on commit c3d1687

Please sign in to comment.