From c3d16873daec4349ddc76d8a688affcdc91d507a Mon Sep 17 00:00:00 2001 From: Maxime Thirouin Date: Sun, 9 Dec 2018 08:11:47 +0100 Subject: [PATCH] babel-preset: fix config to work even in non-static or non production env --- packages/babel-preset/src/index.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/packages/babel-preset/src/index.js b/packages/babel-preset/src/index.js index 2f003e672..2d00b0a06 100644 --- a/packages/babel-preset/src/index.js +++ b/packages/babel-preset/src/index.js @@ -59,7 +59,7 @@ 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, @@ -67,17 +67,22 @@ module.exports = () => ({ 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")] + : []), ], });