Skip to content

Commit bcaa3aa

Browse files
Add migration docs for the global regeneratorRuntime transform (#3086)
Co-authored-by: Brian Ng <[email protected]>
1 parent 8c45218 commit bcaa3aa

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

docs/v8-migration.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,25 @@ The following plugins are discontinued and their functionality is not available
571571

572572
**Migration**: You will probably be fine with the new behaviour as Babel now tries to compile the broken syntax to the closest _non-broken modern syntax_ supported by your target browsers. If anyhow you want to restore the Babel 7 behaviour, you can specify `bugfixes: false`.
573573

574+
### `@babel/plugin-transform-regenerator`
575+
576+
![low](https://img.shields.io/badge/risk%20of%20breakage%3F-low-yellowgreen.svg)
577+
578+
- Do not replace global `regeneratorRuntime` references ([#17237](https://github.com/babel/babel/pull/17237))
579+
580+
Babel 7 used to replace references to a `regeneratorRuntime` global with Babel's `regeneratorRuntime` helper:
581+
```js title="input.js"
582+
console.log(regeneratorRuntime.isGeneratorFunction(fn));
583+
```
584+
```js title="output.js"
585+
import _regeneratorRuntime from "@babel/runtime/regenerator";
586+
console.log(_regeneratorRuntime.isGeneratorFunction(fn));
587+
```
588+
589+
This doesn't happen anymore in Babel 8.
590+
591+
**Migration**: The recommended approach is to update your code to not rely on a non-existent `regeneratorRuntime` global. If that's not possible, you can either import the unmaintained [`regenerator-runtime`](https://www.npmjs.com/package/regenerator-runtime) package in your application entrypoint, which will define the `regeneratorRuntime` global, or use [`babel-plugin-polyfill-regenerator`](https://github.com/babel/babel-polyfills/blob/main/packages/babel-plugin-polyfill-regenerator/README.md) to automatically inject that import for you.
592+
574593
### JSX {#compilation-change-jsx}
575594

576595
![high](https://img.shields.io/badge/risk%20of%20breakage%3F-high-red.svg)

0 commit comments

Comments
 (0)