1 | # babel-plugin-polyfill-corejs3
|
---|
2 |
|
---|
3 | ## Install
|
---|
4 |
|
---|
5 | Using npm:
|
---|
6 |
|
---|
7 | ```sh
|
---|
8 | npm install --save-dev babel-plugin-polyfill-corejs3
|
---|
9 | ```
|
---|
10 |
|
---|
11 | or using yarn:
|
---|
12 |
|
---|
13 | ```sh
|
---|
14 | yarn add babel-plugin-polyfill-corejs3 --dev
|
---|
15 | ```
|
---|
16 |
|
---|
17 | ## Usage
|
---|
18 |
|
---|
19 | Add this plugin to your Babel configuration:
|
---|
20 |
|
---|
21 | ```json
|
---|
22 | {
|
---|
23 | "plugins": [["polyfill-corejs3", { "method": "usage-global", "version": "3.20" }]]
|
---|
24 | }
|
---|
25 | ```
|
---|
26 |
|
---|
27 | This package supports the `usage-pure`, `usage-global`, and `entry-global` methods.
|
---|
28 | When `entry-global` is used, it replaces imports to `core-js`.
|
---|
29 |
|
---|
30 | ## Options
|
---|
31 |
|
---|
32 | See [here](../../docs/usage.md#options) for a list of options supported by every polyfill provider.
|
---|
33 |
|
---|
34 | ### `version`
|
---|
35 |
|
---|
36 | `string`, defaults to `"3.0"`.
|
---|
37 |
|
---|
38 | This option only has an effect when used alongside `"method": "usage-global"` or `"method": "usage-pure"`. It is recommended to specify the minor version you are using as `core-js@3.0` may not include polyfills for the latest features. If you are bundling an app, you can provide the version directly from your node modules:
|
---|
39 |
|
---|
40 | ```js
|
---|
41 | {
|
---|
42 | plugins: [
|
---|
43 | ["polyfill-corejs3", {
|
---|
44 | "method": "usage-pure",
|
---|
45 | // use `core-js/package.json` if you are using `usage-global`
|
---|
46 | "version": require("core-js-pure/package.json").version
|
---|
47 | }]
|
---|
48 | ]
|
---|
49 | }
|
---|
50 | ```
|
---|
51 |
|
---|
52 | If you are a library author, specify a reasonably modern `core-js` version in your
|
---|
53 | `package.json` and provide the plugin the minimal supported version.
|
---|
54 |
|
---|
55 | ```json
|
---|
56 | {
|
---|
57 | "dependencies": {
|
---|
58 | "core-js": "^3.20.0"
|
---|
59 | }
|
---|
60 | }
|
---|
61 | ```
|
---|
62 | ```js
|
---|
63 | {
|
---|
64 | plugins: [
|
---|
65 | ["polyfill-corejs3", {
|
---|
66 | "method": "usage-global",
|
---|
67 | // improvise if you have more complicated version spec, e.g. > 3.1.4
|
---|
68 | "version": require("./package.json").dependencies["core-js"]
|
---|
69 | }]
|
---|
70 | ]
|
---|
71 | }
|
---|
72 | ```
|
---|
73 |
|
---|
74 | ### `proposals`
|
---|
75 |
|
---|
76 | `boolean`, defaults to `false`.
|
---|
77 |
|
---|
78 | This option only has an effect when used alongside `"method": "usage-global"` or `"method": "usage-pure"`. When `proposals` are `true`, any ES proposal supported by core-js will be polyfilled as well. |
---|