Skip to content

Commit 5224cfe

Browse files
adambrgmnswashata
authored andcommitted
feat(babel): Add transform-runtime to preset
1 parent a0fc92a commit 5224cfe

File tree

4 files changed

+47
-3
lines changed

4 files changed

+47
-3
lines changed

packages/babel-preset-base/__tests__/preset.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ describe('preset in module', () => {
5151
'@babel/plugin-syntax-import-meta',
5252
['@babel/plugin-proposal-class-properties'],
5353
'@babel/plugin-proposal-json-strings',
54+
['@babel/plugin-transform-runtime'],
5455
];
5556
activePlugins.forEach(plugin => {
5657
if (Array.isArray(plugin)) {
@@ -71,7 +72,7 @@ describe('preset in module', () => {
7172
noClassProperties: true,
7273
noJsonStrings: true,
7374
});
74-
expect(plugins).toHaveLength(0);
75+
expect(plugins).toHaveLength(1);
7576
});
7677

7778
describe('for @babel/preset-env', () => {

packages/babel-preset-base/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222
"@babel/plugin-proposal-json-strings": "^7.2.0",
2323
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
2424
"@babel/plugin-syntax-import-meta": "^7.2.0",
25+
"@babel/plugin-transform-runtime": "^7.4.4",
2526
"@babel/preset-env": "^7.4.4",
26-
"@babel/preset-react": "^7.0.0"
27+
"@babel/preset-react": "^7.0.0",
28+
"@babel/runtime": "^7.4.4"
2729
},
2830
"peerDependencies": {
2931
"@babel/core": ">=7.0.0"

packages/babel-preset-base/src/preset.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,18 @@ export const preset = (opts: PresetOptions | null = {}) => {
8282
}
8383
});
8484

85+
// We include @babel/plugin-transform-runtime by default in order to
86+
// properly transform e.g. async/await
87+
plugins.push([
88+
'@babel/plugin-transform-runtime',
89+
{
90+
corejs: false,
91+
helpers: false,
92+
regenerator: true,
93+
useESModules: false,
94+
},
95+
]);
96+
8597
// Return the preset and some of stage-3 plugins
8698
// We will remove them, once it becomes stage-4, i.e included in preset-env
8799
return {

yarn.lock

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,16 @@
698698
dependencies:
699699
"@babel/helper-plugin-utils" "^7.0.0"
700700

701+
"@babel/plugin-transform-runtime@^7.4.4":
702+
version "7.4.4"
703+
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.4.4.tgz#a50f5d16e9c3a4ac18a1a9f9803c107c380bce08"
704+
integrity sha512-aMVojEjPszvau3NRg+TIH14ynZLvPewH4xhlCW1w6A3rkxTS1m4uwzRclYR9oS+rl/dr+kT+pzbfHuAWP/lc7Q==
705+
dependencies:
706+
"@babel/helper-module-imports" "^7.0.0"
707+
"@babel/helper-plugin-utils" "^7.0.0"
708+
resolve "^1.8.1"
709+
semver "^5.5.1"
710+
701711
"@babel/plugin-transform-shorthand-properties@^7.2.0":
702712
version "7.2.0"
703713
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.2.0.tgz#6333aee2f8d6ee7e28615457298934a3b46198f0"
@@ -833,6 +843,13 @@
833843
"@babel/helper-plugin-utils" "^7.0.0"
834844
"@babel/plugin-transform-typescript" "^7.3.2"
835845

846+
"@babel/runtime@^7.4.4":
847+
version "7.4.4"
848+
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.4.4.tgz#dc2e34982eb236803aa27a07fea6857af1b9171d"
849+
integrity sha512-w0+uT71b6Yi7i5SE0co4NioIpSYS6lLiXvCzWzGSKvpK5vdQtCbICHMj+gbAKAOtxiV6HsVh/MBdaF9EQ6faSg==
850+
dependencies:
851+
regenerator-runtime "^0.13.2"
852+
836853
"@babel/template@^7.0.0":
837854
version "7.2.2"
838855
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.2.2.tgz#005b3fdf0ed96e88041330379e0da9a708eb2907"
@@ -2036,7 +2053,7 @@
20362053
"@types/connect" "*"
20372054
"@types/webpack" "*"
20382055

2039-
"@types/webpack@*", "@types/webpack@^4.4.24", "@types/webpack@^4.4.27":
2056+
"@types/webpack@*", "@types/webpack@^4.4.27":
20402057
version "4.4.29"
20412058
resolved "https://registry.yarnpkg.com/@types/webpack/-/webpack-4.4.29.tgz#d2a1c1d8c071b06521d32cee1c6b33d704b54b2c"
20422059
integrity sha512-8KVp+cNy9OPYsa4jU6vWsBemn5ixJ0Durh95Cw/YpEKm5ks2ODhdXc4FG3Xc46KIbPrJolwY7mSZFNn1aU3hKg==
@@ -10605,6 +10622,11 @@ regenerate@^1.4.0:
1060510622
resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.0.tgz#4a856ec4b56e4077c557589cae85e7a4c8869a11"
1060610623
integrity sha512-1G6jJVDWrt0rK99kBjvEtziZNCICAuvIPkSiUFIQxVP06RCVpq3dmDo2oi6ABpYaDYaTRr67BEhL8r1wgEZZKg==
1060710624

10625+
regenerator-runtime@^0.13.2:
10626+
version "0.13.2"
10627+
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.2.tgz#32e59c9a6fb9b1a4aff09b4930ca2d4477343447"
10628+
integrity sha512-S/TQAZJO+D3m9xeN1WTI8dLKBBiRgXBlTJvbWjCThHWZj9EvHK70Ff50/tYj2J/fvBY6JtFVwRuazHN2E7M9BA==
10629+
1060810630
regenerator-transform@^0.13.4:
1060910631
version "0.13.4"
1061010632
resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.13.4.tgz#18f6763cf1382c69c36df76c6ce122cc694284fb"
@@ -10822,6 +10844,13 @@ resolve@^1.10.0, resolve@^1.4.0, resolve@^1.9.0:
1082210844
dependencies:
1082310845
path-parse "^1.0.6"
1082410846

10847+
resolve@^1.8.1:
10848+
version "1.10.1"
10849+
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.10.1.tgz#664842ac960795bbe758221cdccda61fb64b5f18"
10850+
integrity sha512-KuIe4mf++td/eFb6wkaPbMDnP6kObCaEtIDuHOUED6MNUo4K670KZUHuuvYPZDxNF0WVLw49n06M2m2dXphEzA==
10851+
dependencies:
10852+
path-parse "^1.0.6"
10853+
1082510854
resp-modifier@6.0.2:
1082610855
version "6.0.2"
1082710856
resolved "https://registry.yarnpkg.com/resp-modifier/-/resp-modifier-6.0.2.tgz#b124de5c4fbafcba541f48ffa73970f4aa456b4f"

0 commit comments

Comments
 (0)