Skip to content

Commit

Permalink
Added common babel config
Browse files Browse the repository at this point in the history
  • Loading branch information
ajmaln committed Nov 29, 2023
1 parent 62e11ff commit af3d25c
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 50 deletions.
47 changes: 1 addition & 46 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,46 +1 @@
const VALID_ENVIRONMENTS = ["development", "test", "production"];

module.exports = function (api) {
const currentEnv = api.env();
const isDevelopmentEnv = api.env("development");
const isProductionEnv = api.env("production");
const isTestEnv = api.env("test");

if (!VALID_ENVIRONMENTS.includes(currentEnv)) {
throw new Error(
"Please specify a valid `NODE_ENV` or `BABEL_ENV` environment variables. " +
'Valid values are "development", "test", and "production". ' +
`Instead, received: ${JSON.stringify(currentEnv)}.`
);
}

return {
presets: [
isTestEnv
? [
"@babel/preset-env",
{ targets: { node: "current" }, modules: "commonjs" },
]
: [
"@babel/preset-env",
{
forceAllTransforms: isProductionEnv,
useBuiltIns: "entry",
corejs: "3.27.0",
modules: false,
},
],
].filter(Boolean),
plugins: [
"babel-plugin-macros",
"@babel/plugin-transform-runtime",
isTestEnv
? "babel-plugin-dynamic-import-node" // tests run in node environment
: "@babel/plugin-syntax-dynamic-import",
isProductionEnv && [
"babel-plugin-transform-react-remove-prop-types",
{ removeImport: true },
],
].filter(Boolean),
};
};
module.exports = require("@bigbinary/neeto-commons-frontend/configs/babel.js");
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@
"@babel/generator": "^7.20.7",
"@babel/plugin-transform-runtime": "^7.19.1",
"@babel/preset-env": "7.17.10",
"@babel/preset-react": "^7.23.3",
"@babel/preset-typescript": "^7.18.6",
"@babel/runtime": "^7.19.0",
"@babel/types": "^7.20.7",
"@bigbinary/babel-preset-neeto": "^1.0.7",
"@bigbinary/eslint-plugin-neeto": "^1.1.35",
"@bigbinary/neeto-cist": "^1.0.5",
"@bigbinary/neeto-commons-frontend": "^3.0.6",
Expand All @@ -64,6 +66,7 @@
"babel-plugin-istanbul": "^6.1.1",
"babel-plugin-js-logger": "1.0.17",
"babel-plugin-macros": "3.1.0",
"babel-plugin-preval": "^5.1.0",
"babel-plugin-transform-react-remove-prop-types": "0.4.24",
"babel-preset-react": "6.24.1",
"babel-preset-typescript": "^7.0.0-alpha.19",
Expand Down
82 changes: 78 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,39 @@
dependencies:
"@babel/helper-plugin-utils" "^7.22.5"

"@babel/plugin-transform-react-display-name@^7.23.3":
version "7.23.3"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-display-name/-/plugin-transform-react-display-name-7.23.3.tgz#70529f034dd1e561045ad3c8152a267f0d7b6200"
integrity sha512-GnvhtVfA2OAtzdX58FJxU19rhoGeQzyVndw3GgtdECQvQFXPEZIOVULHVZGAYmOgmqjXpVpfocAbSjh99V/Fqw==
dependencies:
"@babel/helper-plugin-utils" "^7.22.5"

"@babel/plugin-transform-react-jsx-development@^7.22.5":
version "7.22.5"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx-development/-/plugin-transform-react-jsx-development-7.22.5.tgz#e716b6edbef972a92165cd69d92f1255f7e73e87"
integrity sha512-bDhuzwWMuInwCYeDeMzyi7TaBgRQei6DqxhbyniL7/VG4RSS7HtSL2QbY4eESy1KJqlWt8g3xeEBGPuo+XqC8A==
dependencies:
"@babel/plugin-transform-react-jsx" "^7.22.5"

"@babel/plugin-transform-react-jsx@^7.22.15", "@babel/plugin-transform-react-jsx@^7.22.5":
version "7.23.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.23.4.tgz#393f99185110cea87184ea47bcb4a7b0c2e39312"
integrity sha512-5xOpoPguCZCRbo/JeHlloSkTA8Bld1J/E1/kLfD1nsuiW1m8tduTA1ERCgIZokDflX/IBzKcqR3l7VlRgiIfHA==
dependencies:
"@babel/helper-annotate-as-pure" "^7.22.5"
"@babel/helper-module-imports" "^7.22.15"
"@babel/helper-plugin-utils" "^7.22.5"
"@babel/plugin-syntax-jsx" "^7.23.3"
"@babel/types" "^7.23.4"

"@babel/plugin-transform-react-pure-annotations@^7.23.3":
version "7.23.3"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-pure-annotations/-/plugin-transform-react-pure-annotations-7.23.3.tgz#fabedbdb8ee40edf5da96f3ecfc6958e3783b93c"
integrity sha512-qMFdSS+TUhB7Q/3HVPnEdYJDQIk57jkntAwSuz9xfSE4n+3I+vHYCli3HoHawN1Z3RfCz/y1zXA/JXjG6cVImQ==
dependencies:
"@babel/helper-annotate-as-pure" "^7.22.5"
"@babel/helper-plugin-utils" "^7.22.5"

"@babel/plugin-transform-regenerator@^7.17.9":
version "7.23.3"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.23.3.tgz#141afd4a2057298602069fce7f2dc5173e6c561c"
Expand Down Expand Up @@ -927,6 +960,18 @@
"@babel/types" "^7.4.4"
esutils "^2.0.2"

"@babel/preset-react@^7.23.3":
version "7.23.3"
resolved "https://registry.yarnpkg.com/@babel/preset-react/-/preset-react-7.23.3.tgz#f73ca07e7590f977db07eb54dbe46538cc015709"
integrity sha512-tbkHOS9axH6Ysf2OUEqoSZ6T3Fa2SrNH6WTWSPBboxKzdxNc9qOICeLXkNG0ZEwbQ1HY8liwOce4aN/Ceyuq6w==
dependencies:
"@babel/helper-plugin-utils" "^7.22.5"
"@babel/helper-validator-option" "^7.22.15"
"@babel/plugin-transform-react-display-name" "^7.23.3"
"@babel/plugin-transform-react-jsx" "^7.22.15"
"@babel/plugin-transform-react-jsx-development" "^7.22.5"
"@babel/plugin-transform-react-pure-annotations" "^7.23.3"

"@babel/preset-typescript@^7.18.6":
version "7.23.3"
resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.23.3.tgz#14534b34ed5b6d435aa05f1ae1c5e7adcc01d913"
Expand Down Expand Up @@ -975,7 +1020,7 @@
debug "^4.1.0"
globals "^11.1.0"

"@babel/types@^7.0.0", "@babel/types@^7.17.10", "@babel/types@^7.20.7", "@babel/types@^7.22.15", "@babel/types@^7.22.19", "@babel/types@^7.22.5", "@babel/types@^7.23.0", "@babel/types@^7.23.5", "@babel/types@^7.3.3", "@babel/types@^7.4.4":
"@babel/types@^7.0.0", "@babel/types@^7.17.10", "@babel/types@^7.20.7", "@babel/types@^7.22.15", "@babel/types@^7.22.19", "@babel/types@^7.22.5", "@babel/types@^7.23.0", "@babel/types@^7.23.4", "@babel/types@^7.23.5", "@babel/types@^7.3.3", "@babel/types@^7.4.4":
version "7.23.5"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.23.5.tgz#48d730a00c95109fa4393352705954d74fb5b602"
integrity sha512-ON5kSOJwVO6xXVRTvOI0eOnWe7VdUcIpsovGo9U/Br4Ie4UVFQTboO2cYnDhAGU6Fp+UxSiT+pMft0SMHfuq6w==
Expand All @@ -989,16 +1034,30 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==

"@bigbinary/babel-preset-neeto@^1.0.7":
version "1.0.7"
resolved "https://registry.yarnpkg.com/@bigbinary/babel-preset-neeto/-/babel-preset-neeto-1.0.7.tgz#1150c650459631704d3c910b5124a909a1c1813b"
integrity sha512-DnlfTcxG+0eskCkSxVqgtp9SRYmV1v4EmDUYzTWzSrCrGcrV3UsOAtMOQVT6NwHwEZudjkzsVofLiZKSYjYZCA==
dependencies:
"@bigbinary/neeto-cist" "^1.0.4"
"@bigbinary/neeto-commons-frontend" "^2.0.63"
ramda "^0.29.0"

"@bigbinary/eslint-plugin-neeto@^1.1.35":
version "1.1.35"
resolved "https://registry.yarnpkg.com/@bigbinary/eslint-plugin-neeto/-/eslint-plugin-neeto-1.1.35.tgz#9cb41c8a2b9f31b0bea24a17c41f4b0038075b69"
integrity sha512-b4o3CriRAmUlfLooe8bJFg0z7JL4iT9W8CyHr9EqQxkvougJaVOh8SQFtRFxxByUdhQ9ZQzYTxuR7qHjzvmymA==

"@bigbinary/neeto-cist@^1.0.5":
"@bigbinary/neeto-cist@^1.0.4", "@bigbinary/neeto-cist@^1.0.5":
version "1.0.5"
resolved "https://registry.yarnpkg.com/@bigbinary/neeto-cist/-/neeto-cist-1.0.5.tgz#726e13f9bacb67d407532be51469dadf05bcf55a"
integrity sha512-XCpCLhu7lw2A978YlkgWs32gGISmRT039WPYlLSbOe1fmIecyQetS1VijE4fOfvhYbMzIvD2dsMRO2XsZ7xoUQ==

"@bigbinary/neeto-commons-frontend@^2.0.63":
version "2.1.39"
resolved "https://registry.yarnpkg.com/@bigbinary/neeto-commons-frontend/-/neeto-commons-frontend-2.1.39.tgz#47e99d4c9330f5de7db59d68e2697b6be167b36b"
integrity sha512-L2x2K4Nk2VLWV5exgjWUR9gtY/ZQdcvBfDGtfH15YPvRjba4xR/ITy2RUYxIibzOzj/gI2W44GYX7FbF5u3uuA==

"@bigbinary/neeto-commons-frontend@^3.0.6":
version "3.0.6"
resolved "https://registry.yarnpkg.com/@bigbinary/neeto-commons-frontend/-/neeto-commons-frontend-3.0.6.tgz#09675db6083e5721a1cfc45d6071e1a2f4fd20db"
Expand Down Expand Up @@ -1429,7 +1488,7 @@
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82"
integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==

"@types/babel__core@^7.0.0", "@types/babel__core@^7.1.14":
"@types/babel__core@^7.0.0", "@types/babel__core@^7.1.12", "@types/babel__core@^7.1.14":
version "7.20.5"
resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.20.5.tgz#3df15f27ba85319caa07ba08d0721889bb39c017"
integrity sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==
Expand Down Expand Up @@ -2043,7 +2102,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/babel-plugin-js-logger/-/babel-plugin-js-logger-1.0.17.tgz#56d2ec6ab1de4593a1923b3a79fcc160ed0e21c4"
integrity sha512-PVA9QbK/e5Pkq4U+ZvMcan7cItqRBw2F6hpJvzowjNfVV48dJpCUaYYwXQnfZHpJe+hknZKM7hWnNDhVy4OBsg==

[email protected]:
[email protected], babel-plugin-macros@^3.0.1:
version "3.1.0"
resolved "https://registry.yarnpkg.com/babel-plugin-macros/-/babel-plugin-macros-3.1.0.tgz#9ef6dc74deb934b4db344dc973ee851d148c50c1"
integrity sha512-Cg7TFGpIr01vOQNODXOOaGz2NpCU5gl8x1qJFbb6hbZxR7XrcE2vtbAsTAbJ7/xwJtUuJEw8K8Zr/AE0LHlesg==
Expand Down Expand Up @@ -2100,6 +2159,16 @@ babel-plugin-polyfill-regenerator@^0.5.3:
dependencies:
"@babel/helper-define-polyfill-provider" "^0.4.3"

babel-plugin-preval@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/babel-plugin-preval/-/babel-plugin-preval-5.1.0.tgz#6efb89bf6b97af592cd1400c6df49c0e9e6ab027"
integrity sha512-G5R+xmo5LS41A4UyZjOjV0mp9AvkuCyUOAJ6TOv/jTZS+VKh7L7HUDRcCSOb0YCM/u0fFarh7Diz0wjY8rFNFg==
dependencies:
"@babel/runtime" "^7.12.5"
"@types/babel__core" "^7.1.12"
babel-plugin-macros "^3.0.1"
require-from-string "^2.0.2"

babel-plugin-syntax-flow@^6.18.0:
version "6.18.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-flow/-/babel-plugin-syntax-flow-6.18.0.tgz#4c3ab20a2af26aa20cd25995c398c4eb70310c8d"
Expand Down Expand Up @@ -5601,6 +5670,11 @@ require-directory@^2.1.1:
resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==

require-from-string@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.2.tgz#89a7fdd938261267318eafe14f9c32e598c36909"
integrity sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==

requireindex@^1.1.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/requireindex/-/requireindex-1.2.0.tgz#3463cdb22ee151902635aa6c9535d4de9c2ef1ef"
Expand Down

0 comments on commit af3d25c

Please sign in to comment.