From 88f79eeeb4c44bf2f87b51d9b065ecd7e765db07 Mon Sep 17 00:00:00 2001 From: Devin Alexander Torres Date: Sat, 8 Jun 2019 21:07:24 -0400 Subject: [PATCH] docs(transform-runtime): document overriding corejs definitions Documents the proposed feature babel/babel#10069. --- docs/plugin-transform-runtime.md | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/docs/plugin-transform-runtime.md b/docs/plugin-transform-runtime.md index 75c0da3c62..23768068d0 100644 --- a/docs/plugin-transform-runtime.md +++ b/docs/plugin-transform-runtime.md @@ -89,7 +89,7 @@ require("@babel/core").transform("code", { ### `corejs` -`false`, `2`, `3` or `{ version: 2 | 3, proposals: boolean }`, defaults to `false`. +`false`, `2`, `3` or `{ version: 2 | 3, proposals: boolean, definitions?: Object }`, defaults to `false`. e.g. `['@babel/plugin-transform-runtime', { corejs: 3 }],` @@ -106,6 +106,36 @@ This option requires changing the dependency used to provide the necessary runti | `2` | `npm install --save @babel/runtime-corejs2` | | `3` | `npm install --save @babel/runtime-corejs3` | +If needed, you can customize the `core-js` polyfill definitions that `@babel/plugin-transform-runtime` uses during transformations by specifying the `definitions` key to override [the defaults](https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-runtime/src/runtime-corejs3-definitions.js). + +For example, to disable polyfilling the `Symbol` built-in, all Array static methods and `String.prototype.repeat` instance method: + +```json +{ + "plugins": [ + [ + "@babel/plugin-transform-runtime", + { + "corejs": { + "version": 3, + "definitions": { + "BuiltIns": { + "Symbol": false + }, + "StaticProperties": { + "Array": false + }, + "InstanceProperties": { + "repeat": false + } + } + } + } + ] + ] +} +``` + ### `helpers` `boolean`, defaults to `true`.