diff --git a/docs/register.md b/docs/register.md index a739682d88..39c560507a 100644 --- a/docs/register.md +++ b/docs/register.md @@ -143,4 +143,15 @@ Because it is your own code that triggered the load, and not the logic within `@babel/register` itself, this should successfully compile any plugin/preset that loads synchronously. +## Experimental Babel 8 implementation + +You can also test the new experimental implementation that will be enabled by default in Babel 8, using +```js +require("@babel/register/experimental-worker"); +``` + +It internally runs Babel asynchronously, so it's compatible with [`.mjs` configuration files](config-files.md#configuration-file-types). You can already use it as a replacement of `@babel/register` with a few caveats: +- If you programmatically specify `@babel/register` options (using `require("@babel/register")({ /* ... options */ })`), you must make sure that they are serializable. This means that you cannot pass plugin functions defined inline, but you must move them to a separate `./my-plugin.js` file or to a `babel.config.js` file. +- The new implementation is still experimental: it _should_ have the same features as the existing one, but there may be some new bugs and regressions. + **Note:** `@babel/register` does _not_ support compiling native Node.js ES modules on the fly, since currently there is no stable API for intercepting ES modules loading.