Skip to content

Commit

Permalink
fix: added reset preset as default
Browse files Browse the repository at this point in the history
  • Loading branch information
teclone committed Sep 30, 2020
1 parent 9d59c12 commit 97e7653
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 10 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"@babel/plugin-proposal-optional-chaining": "7.9.0",
"@babel/plugin-transform-runtime": "7.9.6",
"@babel/preset-env": "7.9.6",
"@babel/preset-react": "^7.10.4",
"@babel/preset-typescript": "7.9.0",
"@babel/runtime": "7.9.6",
"@rollup/plugin-babel": "5.0.4",
Expand Down
34 changes: 24 additions & 10 deletions src/modules/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,32 +44,38 @@ export const loadFile = (entryPath: string, file: string) => {
export const getBabelPlugins = (
pluginsConfig: BabelPluginsConfig,
internalNodeModulesDir: string,
useESModules: boolean,
useESModules: boolean
) => {
return [
/**
* all these are now available by default in babel preset env
*/
resolveDependency(internalNodeModulesDir, '@babel/plugin-proposal-class-properties'),
resolveDependency(
internalNodeModulesDir,
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-class-properties'
),
resolveDependency(
internalNodeModulesDir,
'@babel/plugin-proposal-object-rest-spread'
),
[
resolveDependency(
internalNodeModulesDir,
'@babel/plugin-proposal-nullish-coalescing-operator',
'@babel/plugin-proposal-nullish-coalescing-operator'
),
],
[
resolveDependency(
internalNodeModulesDir,
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-proposal-optional-chaining'
),
],
...(pluginsConfig?.plugins || []),
[
resolveDependency(internalNodeModulesDir, '@babel/plugin-transform-runtime'),
resolveDependency(
internalNodeModulesDir,
'@babel/plugin-transform-runtime'
),
{
useESModules,
},
Expand All @@ -79,7 +85,7 @@ export const getBabelPlugins = (

export const getBabelPresets = (
presetsConfig: BabelPresetsConfig,
internalNodeModulesDir: string,
internalNodeModulesDir: string
) => {
return [
// here we are including babel preset env
Expand All @@ -100,6 +106,14 @@ export const getBabelPresets = (
// support for typescript
resolveDependency(internalNodeModulesDir, '@babel/preset-typescript'),

// support for react
[
resolveDependency(internalNodeModulesDir, '@babel/preset-react'),
{
development: process.env.BABEL_ENV === 'development',
},
],

// user defined preset.
...(presetsConfig?.presets || []),
];
Expand All @@ -108,7 +122,7 @@ export const getBabelPresets = (
export const getRollupPlugins = (
mainConfig: Config,
buildConfig: DistConfig | ESMConfig | CJSConfig,
generalConfig: GeneralConfig,
generalConfig: GeneralConfig
) => {
const internalNodeModulesDir = getEntryPath(__dirname);
return [
Expand All @@ -127,12 +141,12 @@ export const getRollupPlugins = (
plugins: getBabelPlugins(
generalConfig?.babelConfig?.pluginsConfig || {},
internalNodeModulesDir,
buildConfig.format === 'esm',
buildConfig.format === 'esm'
),

presets: getBabelPresets(
generalConfig?.babelConfig?.presetsConfig || {},
internalNodeModulesDir,
internalNodeModulesDir
),

// we are using runtime because it is assumed you are building a library
Expand Down
101 changes: 101 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,23 @@
"@babel/helper-explode-assignable-expression" "^7.10.4"
"@babel/types" "^7.10.4"

"@babel/helper-builder-react-jsx-experimental@^7.10.4", "@babel/helper-builder-react-jsx-experimental@^7.11.5":
version "7.11.5"
resolved "https://registry.yarnpkg.com/@babel/helper-builder-react-jsx-experimental/-/helper-builder-react-jsx-experimental-7.11.5.tgz#4ea43dd63857b0a35cd1f1b161dc29b43414e79f"
integrity sha512-Vc4aPJnRZKWfzeCBsqTBnzulVNjABVdahSPhtdMD3Vs80ykx4a87jTHtF/VR+alSrDmNvat7l13yrRHauGcHVw==
dependencies:
"@babel/helper-annotate-as-pure" "^7.10.4"
"@babel/helper-module-imports" "^7.10.4"
"@babel/types" "^7.11.5"

"@babel/helper-builder-react-jsx@^7.10.4":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/helper-builder-react-jsx/-/helper-builder-react-jsx-7.10.4.tgz#8095cddbff858e6fa9c326daee54a2f2732c1d5d"
integrity sha512-5nPcIZ7+KKDxT1427oBivl9V9YTal7qk0diccnh7RrcgrT/pGFOjgGw1dgryyx1GvHEpXVfoDF6Ak3rTiWh8Rg==
dependencies:
"@babel/helper-annotate-as-pure" "^7.10.4"
"@babel/types" "^7.10.4"

"@babel/helper-compilation-targets@^7.9.6":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.10.4.tgz#804ae8e3f04376607cc791b9d47d540276332bd2"
Expand Down Expand Up @@ -435,6 +452,13 @@
dependencies:
"@babel/helper-plugin-utils" "^7.8.0"

"@babel/plugin-syntax-jsx@^7.10.4":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.10.4.tgz#39abaae3cbf710c4373d8429484e6ba21340166c"
integrity sha512-KCg9mio9jwiARCB7WAcQ7Y1q+qicILjoK8LP/VkPkEKaf5dkaZZK1EcTe91a3JJlZ3qy6L5s9X52boEYi8DM9g==
dependencies:
"@babel/helper-plugin-utils" "^7.10.4"

"@babel/plugin-syntax-logical-assignment-operators@^7.8.3":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz#ca91ef46303530448b906652bac2e9fe9941f699"
Expand Down Expand Up @@ -676,6 +700,56 @@
dependencies:
"@babel/helper-plugin-utils" "^7.10.4"

"@babel/plugin-transform-react-display-name@^7.10.4":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-display-name/-/plugin-transform-react-display-name-7.10.4.tgz#b5795f4e3e3140419c3611b7a2a3832b9aef328d"
integrity sha512-Zd4X54Mu9SBfPGnEcaGcOrVAYOtjT2on8QZkLKEq1S/tHexG39d9XXGZv19VfRrDjPJzFmPfTAqOQS1pfFOujw==
dependencies:
"@babel/helper-plugin-utils" "^7.10.4"

"@babel/plugin-transform-react-jsx-development@^7.10.4":
version "7.11.5"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx-development/-/plugin-transform-react-jsx-development-7.11.5.tgz#e1439e6a57ee3d43e9f54ace363fb29cefe5d7b6"
integrity sha512-cImAmIlKJ84sDmpQzm4/0q/2xrXlDezQoixy3qoz1NJeZL/8PRon6xZtluvr4H4FzwlDGI5tCcFupMnXGtr+qw==
dependencies:
"@babel/helper-builder-react-jsx-experimental" "^7.11.5"
"@babel/helper-plugin-utils" "^7.10.4"
"@babel/plugin-syntax-jsx" "^7.10.4"

"@babel/plugin-transform-react-jsx-self@^7.10.4":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx-self/-/plugin-transform-react-jsx-self-7.10.4.tgz#cd301a5fed8988c182ed0b9d55e9bd6db0bd9369"
integrity sha512-yOvxY2pDiVJi0axdTWHSMi5T0DILN+H+SaeJeACHKjQLezEzhLx9nEF9xgpBLPtkZsks9cnb5P9iBEi21En3gg==
dependencies:
"@babel/helper-plugin-utils" "^7.10.4"
"@babel/plugin-syntax-jsx" "^7.10.4"

"@babel/plugin-transform-react-jsx-source@^7.10.4":
version "7.10.5"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx-source/-/plugin-transform-react-jsx-source-7.10.5.tgz#34f1779117520a779c054f2cdd9680435b9222b4"
integrity sha512-wTeqHVkN1lfPLubRiZH3o73f4rfon42HpgxUSs86Nc+8QIcm/B9s8NNVXu/gwGcOyd7yDib9ikxoDLxJP0UiDA==
dependencies:
"@babel/helper-plugin-utils" "^7.10.4"
"@babel/plugin-syntax-jsx" "^7.10.4"

"@babel/plugin-transform-react-jsx@^7.10.4":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.10.4.tgz#673c9f913948764a4421683b2bef2936968fddf2"
integrity sha512-L+MfRhWjX0eI7Js093MM6MacKU4M6dnCRa/QPDwYMxjljzSCzzlzKzj9Pk4P3OtrPcxr2N3znR419nr3Xw+65A==
dependencies:
"@babel/helper-builder-react-jsx" "^7.10.4"
"@babel/helper-builder-react-jsx-experimental" "^7.10.4"
"@babel/helper-plugin-utils" "^7.10.4"
"@babel/plugin-syntax-jsx" "^7.10.4"

"@babel/plugin-transform-react-pure-annotations@^7.10.4":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-pure-annotations/-/plugin-transform-react-pure-annotations-7.10.4.tgz#3eefbb73db94afbc075f097523e445354a1c6501"
integrity sha512-+njZkqcOuS8RaPakrnR9KvxjoG1ASJWpoIv/doyWngId88JoFlPlISenGXjrVacZUIALGUr6eodRs1vmPnF23A==
dependencies:
"@babel/helper-annotate-as-pure" "^7.10.4"
"@babel/helper-plugin-utils" "^7.10.4"

"@babel/plugin-transform-regenerator@^7.8.7":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.10.4.tgz#2015e59d839074e76838de2159db421966fd8b63"
Expand Down Expand Up @@ -841,6 +915,19 @@
"@babel/types" "^7.4.4"
esutils "^2.0.2"

"@babel/preset-react@^7.10.4":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/preset-react/-/preset-react-7.10.4.tgz#92e8a66d816f9911d11d4cc935be67adfc82dbcf"
integrity sha512-BrHp4TgOIy4M19JAfO1LhycVXOPWdDbTRep7eVyatf174Hff+6Uk53sDyajqZPu8W1qXRBiYOfIamek6jA7YVw==
dependencies:
"@babel/helper-plugin-utils" "^7.10.4"
"@babel/plugin-transform-react-display-name" "^7.10.4"
"@babel/plugin-transform-react-jsx" "^7.10.4"
"@babel/plugin-transform-react-jsx-development" "^7.10.4"
"@babel/plugin-transform-react-jsx-self" "^7.10.4"
"@babel/plugin-transform-react-jsx-source" "^7.10.4"
"@babel/plugin-transform-react-pure-annotations" "^7.10.4"

"@babel/[email protected]":
version "7.9.0"
resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.9.0.tgz#87705a72b1f0d59df21c179f7c3d2ef4b16ce192"
Expand Down Expand Up @@ -911,6 +998,15 @@
lodash "^4.17.13"
to-fast-properties "^2.0.0"

"@babel/types@^7.11.5":
version "7.11.5"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.11.5.tgz#d9de577d01252d77c6800cee039ee64faf75662d"
integrity sha512-bvM7Qz6eKnJVFIn+1LPtjlBFPVN5jNDc1XmN15vWe7Q3DPBufWWsLiIvUu7xW87uTG6QoggpIDnUgLQvPheU+Q==
dependencies:
"@babel/helper-validator-identifier" "^7.10.4"
lodash "^4.17.19"
to-fast-properties "^2.0.0"

"@bcoe/v8-coverage@^0.2.3":
version "0.2.3"
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
Expand Down Expand Up @@ -6284,6 +6380,11 @@ lodash@^4.16.4, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.15, lodash@^4.17.
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"
integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==

lodash@^4.17.19:
version "4.17.20"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==

lodash@~1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-1.3.1.tgz#a4663b53686b895ff074e2ba504dfb76a8e2b770"
Expand Down

0 comments on commit 97e7653

Please sign in to comment.