Skip to content

Commit

Permalink
Babel Preset Default: Avoid disabling regenerator option
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Feb 26, 2019
1 parent ff7c746 commit e7c2a7b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
8 changes: 6 additions & 2 deletions packages/babel-preset-default/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
## 4.0.0 (Unreleased)

## Breaking Change
### Breaking Change

- Removed `babel-core` dependency acting as Babel 7 bridge ([#13922](https://github.com/WordPress/gutenberg/pull/13922). Ensure all references to `babel-core` are replaced with `@babel/core` .
- Preset updated to include `@wordpress/babel-plugin-import-jsx-pragma` plugin integration ([#13540](https://github.com/WordPress/gutenberg/pull/13540)).

### Bug Fix

- The runtime transform no longer disables [the `regenerator` option](https://babeljs.io/docs/en/babel-plugin-transform-runtime#regenerator). This should resolve issues where a file generated using the preset would assume the presence of a `regeneratorRuntime` object in the global scope. While this is not considered a breaking change, you may be mindful to consider that with transformed output now explicitly importing the runtime regenerator, bundle sizes may increase if you do not otherwise mitigate the additional import by either (a) overriding the option in your own Babel configuration extensions or (b) redefining the resolved value of `@babel/runtime/regenerator` using a feature like [Webpack's `externals` option](https://webpack.js.org/configuration/externals/).

## 3.0.0 (2018-09-30)

## Breaking Change
### Breaking Change

- The configured `@babel/preset-env` preset will no longer pass `useBuiltIns: 'usage'` as an option. It is therefore expected that a polyfill serve in its place, if necessary.

Expand Down
1 change: 0 additions & 1 deletion packages/babel-preset-default/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ module.exports = function( api ) {
'@babel/plugin-proposal-async-generator-functions',
! isTestEnv && [ '@babel/plugin-transform-runtime', {
helpers: true,
regenerator: false, // We polyfill so we don't need regenerator.
useESModules: false,
} ],
].filter( Boolean ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

exports[`Babel preset default transpilation works properly 1`] = `
"import _asyncToGenerator from \\"@babel/runtime/helpers/asyncToGenerator\\";
import _regeneratorRuntime from \\"@babel/runtime/regenerator\\";
import _awaitAsyncGenerator from \\"@babel/runtime/helpers/awaitAsyncGenerator\\";
import _wrapAsyncGenerator from \\"@babel/runtime/helpers/wrapAsyncGenerator\\";
describe('Babel preset default', function () {
Expand All @@ -12,8 +13,8 @@ describe('Babel preset default', function () {
function _foo() {
_foo = _wrapAsyncGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee() {
return regeneratorRuntime.wrap(function _callee$(_context) {
_regeneratorRuntime.mark(function _callee() {
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
Expand All @@ -38,9 +39,9 @@ describe('Babel preset default', function () {
/*#__PURE__*/
_asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee2() {
_regeneratorRuntime.mark(function _callee2() {
var generator;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
Expand Down

0 comments on commit e7c2a7b

Please sign in to comment.