This repository has been archived by the owner on Sep 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixup Babel 7 migration (hard because: monorepo with lerna)
Ref bb0ce41
- Loading branch information
Showing
8 changed files
with
108 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,83 @@ | ||
// @flow | ||
|
||
// most of this has been inspired by | ||
// https://github.com/facebook/create-react-app/tree/master/packages/babel-preset-react-app | ||
|
||
module.exports = () => ({ | ||
presets: [ | ||
require("@babel/preset-flow"), | ||
require("@babel/preset-react"), | ||
[ | ||
require("@babel/preset-env"), | ||
process.env.PHENOMIC_ENV === "static" | ||
? { | ||
targets: { | ||
node: "current", | ||
}, | ||
} | ||
: {}, | ||
{ | ||
...(process.env.PHENOMIC_ENV === "static" | ||
? { | ||
targets: { | ||
node: "current", | ||
}, | ||
} | ||
: { | ||
// Do not transform modules to CJS since bundler like webpack handle it | ||
modules: false, | ||
}), | ||
// If users import all core-js they're probably not concerned with | ||
// bundle size. We shouldn't rely on magic to try and shrink it. | ||
useBuiltIns: false, | ||
// Exclude transforms that make all code slower | ||
exclude: ["transform-typeof-symbol"], | ||
}, | ||
], | ||
[ | ||
require("@babel/preset-react"), | ||
{ | ||
// Adds component stack to warning messages | ||
// Adds __self attribute to JSX which React will use for some warnings | ||
development: process.env.PHENOMIC_ENV !== "static", | ||
// Will use the native built-in instead of trying to polyfill | ||
// behavior for any plugins that require one. | ||
useBuiltIns: true, | ||
}, | ||
], | ||
require("@babel/preset-flow"), | ||
], | ||
plugins: [ | ||
require("@babel/plugin-proposal-class-properties"), | ||
require("@babel/plugin-proposal-export-default-from"), | ||
require("@babel/plugin-proposal-export-namespace-from"), | ||
// Enable loose mode to use assignment instead of defineProperty | ||
// See discussion in https://github.com/facebook/create-react-app/issues/4263 | ||
[ | ||
require("@babel/plugin-proposal-class-properties"), | ||
{ | ||
loose: true, | ||
}, | ||
], | ||
// The following two plugins use Object.assign directly, instead of Babel's | ||
// extends helper. Note that this assumes `Object.assign` is available. | ||
// { ...todo, completed: true } | ||
[ | ||
require("@babel/plugin-proposal-object-rest-spread"), | ||
{ | ||
useBuiltIns: true, | ||
}, | ||
], | ||
// 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, | ||
{ | ||
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, | ||
}, | ||
], | ||
// Adds syntax support for import() | ||
require("@babel/plugin-syntax-dynamic-import"), | ||
require("@babel/plugin-syntax-object-rest-spread"), | ||
require("@babel/plugin-transform-runtime"), | ||
// Transform dynamic import to require | ||
process.env.PHENOMIC_ENV === "static" && | ||
require("babel-plugin-dynamic-import-node"), | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters