Skip to content

Commit 6941288

Browse files
adambrgmnswashata
authored andcommitted
fix(babel): Make transform runtime optional
By setting the flag "noRuntime" in a babel config file one can now disable @babel/plugin-transform-runtime.
1 parent 7cbc745 commit 6941288

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ describe('preset in module', () => {
7171
noImportMeta: true,
7272
noClassProperties: true,
7373
noJsonStrings: true,
74+
noRuntime: true,
7475
});
75-
expect(plugins).toHaveLength(1);
76+
expect(plugins).toHaveLength(0);
7677
});
7778

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

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ export const preset = (opts: PresetOptions | null = {}) => {
7474
{ loose: false },
7575
],
7676
noJsonStrings: '@babel/plugin-proposal-json-strings',
77+
noRuntime: [
78+
'@babel/plugin-transform-runtime',
79+
{
80+
corejs: false,
81+
helpers: true,
82+
regenerator: true,
83+
useESModules: true,
84+
},
85+
],
7786
};
7887
// Add them, only if user hasn't explicitly disabled it
7988
Object.keys(wannabePlugins).forEach((pKey: string) => {
@@ -82,18 +91,6 @@ export const preset = (opts: PresetOptions | null = {}) => {
8291
}
8392
});
8493

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: true,
92-
regenerator: true,
93-
useESModules: true,
94-
},
95-
]);
96-
9794
// Return the preset and some of stage-3 plugins
9895
// We will remove them, once it becomes stage-4, i.e included in preset-env
9996
return {

0 commit comments

Comments
 (0)