Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

Commit

Permalink
babel-preset: fix config to work even in non-static or non production…
Browse files Browse the repository at this point in the history
… env
  • Loading branch information
MoOx committed Dec 9, 2018
1 parent cd190c3 commit c3d1687
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions packages/babel-preset/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.