Skip to content

Commit

Permalink
fix(babel): Make transform runtime optional
Browse files Browse the repository at this point in the history
By setting the flag "noRuntime" in a babel config file one can now
disable @babel/plugin-transform-runtime.
  • Loading branch information
adambrgmn authored and swashata committed May 4, 2019
1 parent 7cbc745 commit 6941288
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
3 changes: 2 additions & 1 deletion packages/babel-preset-base/__tests__/preset.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ describe('preset in module', () => {
noImportMeta: true,
noClassProperties: true,
noJsonStrings: true,
noRuntime: true,
});
expect(plugins).toHaveLength(1);
expect(plugins).toHaveLength(0);
});

describe('for @babel/preset-env', () => {
Expand Down
21 changes: 9 additions & 12 deletions packages/babel-preset-base/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ export const preset = (opts: PresetOptions | null = {}) => {
{ loose: false },
],
noJsonStrings: '@babel/plugin-proposal-json-strings',
noRuntime: [
'@babel/plugin-transform-runtime',
{
corejs: false,
helpers: true,
regenerator: true,
useESModules: true,
},
],
};
// Add them, only if user hasn't explicitly disabled it
Object.keys(wannabePlugins).forEach((pKey: string) => {
Expand All @@ -82,18 +91,6 @@ export const preset = (opts: PresetOptions | null = {}) => {
}
});

// We include @babel/plugin-transform-runtime by default in order to
// properly transform e.g. async/await
plugins.push([
'@babel/plugin-transform-runtime',
{
corejs: false,
helpers: true,
regenerator: true,
useESModules: true,
},
]);

// Return the preset and some of stage-3 plugins
// We will remove them, once it becomes stage-4, i.e included in preset-env
return {
Expand Down

0 comments on commit 6941288

Please sign in to comment.