You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
1.9 KiB

3 months ago
  1. # babel-plugin-polyfill-corejs3
  2. ## Install
  3. Using npm:
  4. ```sh
  5. npm install --save-dev babel-plugin-polyfill-corejs3
  6. ```
  7. or using yarn:
  8. ```sh
  9. yarn add babel-plugin-polyfill-corejs3 --dev
  10. ```
  11. ## Usage
  12. Add this plugin to your Babel configuration:
  13. ```json
  14. {
  15. "plugins": [["polyfill-corejs3", { "method": "usage-global", "version": "3.20" }]]
  16. }
  17. ```
  18. This package supports the `usage-pure`, `usage-global`, and `entry-global` methods.
  19. When `entry-global` is used, it replaces imports to `core-js`.
  20. ## Options
  21. See [here](../../docs/usage.md#options) for a list of options supported by every polyfill provider.
  22. ### `version`
  23. `string`, defaults to `"3.0"`.
  24. 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:
  25. ```js
  26. {
  27. plugins: [
  28. ["polyfill-corejs3", {
  29. "method": "usage-pure",
  30. // use `core-js/package.json` if you are using `usage-global`
  31. "version": require("core-js-pure/package.json").version
  32. }]
  33. ]
  34. }
  35. ```
  36. If you are a library author, specify a reasonably modern `core-js` version in your
  37. `package.json` and provide the plugin the minimal supported version.
  38. ```json
  39. {
  40. "dependencies": {
  41. "core-js": "^3.20.0"
  42. }
  43. }
  44. ```
  45. ```js
  46. {
  47. plugins: [
  48. ["polyfill-corejs3", {
  49. "method": "usage-global",
  50. // improvise if you have more complicated version spec, e.g. > 3.1.4
  51. "version": require("./package.json").dependencies["core-js"]
  52. }]
  53. ]
  54. }
  55. ```
  56. ### `proposals`
  57. `boolean`, defaults to `false`.
  58. 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.