|
19 | 19 | [](https://www.npmjs.com/package/enum-plus) |
20 | 20 |  |
21 | 21 |
|
22 | | -⬇️ [Introduction](#introduction) | [Features](#features) | [Installation](#installation) | [Enum Initialization](#enum-initialization) | [API](#api) | [Usage](#usage) | [Naming Conventions](#naming-convention-best-practices) | [Localization](#localization) | [Extensibility](#extensibility) | [Q&A](#qa) ⬇️ |
| 22 | +⬇️ [Introduction](#introduction) | [Features](#features) | [Installation](#installation) | [Enum Initialization](#enum-initialization) | [API](#api) | [Usage](#usage) | [Naming Conventions](#naming-convention-best-practices) | [Localization](#localization) | [Extensibility](#extensibility) | [Compatibility](#compatibility) | [Q&A](#qa) ⬇️ |
23 | 23 |
|
24 | 24 | ## Introduction |
25 | 25 |
|
@@ -78,19 +78,27 @@ yarn add enum-plus |
78 | 78 | - The specific version: |
79 | 79 |
|
80 | 80 | ```html |
| 81 | +<!-- ES2020 modern version --> |
81 | 82 | <script src="https://cdn.jsdelivr.net/npm/enum-plus@v3.0.0/umd/enum-plus.min.js"></script> |
| 83 | +<!-- ES2015 legacy version --> |
| 84 | +<script src="https://cdn.jsdelivr.net/npm/enum-plus@v3.0.0/umd/enum-plus-legacy.min.js"></script> |
82 | 85 | ``` |
83 | 86 |
|
84 | 87 | - The latest version: |
85 | 88 |
|
86 | 89 | ```html |
| 90 | +<!-- ES2020 modern version --> |
87 | 91 | <script src="https://cdn.jsdelivr.net/npm/enum-plus/umd/enum-plus.min.js"></script> |
| 92 | +<!-- ES2015 legacy version --> |
| 93 | +<script src="https://cdn.jsdelivr.net/npm/enum-plus/umd/enum-plus-legacy.min.js"></script> |
88 | 94 | ``` |
89 | 95 |
|
90 | 96 | ⬇️ **Download**: |
91 | 97 |
|
92 | 98 | - [enum-plus.umd.min.js.gz](https://github.com/shijistar/enum-plus/releases/download/v3.0.0/enum-plus.umd.min.js.gz) (~2kB gzipped) |
93 | 99 | - [enum-plus.umd.tar.gz](https://github.com/shijistar/enum-plus/releases/download/v3.0.0/enum-plus.umd.tar.gz) (Full package with sourcemap) |
| 100 | +- [enum-plus-legacy.umd.min.js.gz](https://github.com/shijistar/enum-plus/releases/download/v3.0.0/enum-plus-legacy.umd.min.js.gz) |
| 101 | +- [enum-plus-legacy.umd.tar.gz](https://github.com/shijistar/enum-plus/releases/download/v3.0.0/enum-plus-legacy.umd.tar.gz) |
94 | 102 |
|
95 | 103 | > You can also download them in [github release](https://github.com/shijistar/enum-plus/releases) assets |
96 | 104 |
|
@@ -912,19 +920,27 @@ If you want to provide more friendly type hints in the extension methods, you ma |
912 | 920 |
|
913 | 921 | ## Compatibility |
914 | 922 |
|
915 | | -- **Browser Environments**: |
| 923 | +enum-plus is designed to be compatible with a wide range of environments, including modern browsers, Node.js, and various build tools. Below are the compatibility details for different environments: |
916 | 924 |
|
917 | | - - **Modern Bundlers**: With bundlers supporting the [exports](https://nodejs.org/api/packages.html#exports-sugar) field (Webpack 5+, Vite, Rollup), enum-plus targets `ES2020`. For broader browser support, transpile to earlier syntax using `@babel/preset-env` during your build process. |
| 925 | +### Browser Environments |
918 | 926 |
|
919 | | - - **Legacy Bundlers**: For tools without `exports` field support (like Webpack 4), enum-plus automatically falls back to the `main` field entry point, which targets `ES2016`. |
| 927 | +- **Modern Bundlers**: For bundlers supporting the [exports](https://nodejs.org/api/packages.html#exports-sugar) field (such as webpack 5+, vite, rollup), `es` directory is imported, which targets `ES2020`. For broader browser support, you can transpile to earlier syntax using `@babel/preset-env` during your build process. |
920 | 928 |
|
921 | | - - **Polyfill Strategy**: enum-plus ships without polyfills to minimize bundle size. For legacy browser support, incorporate: |
| 929 | +- **Legacy Bundlers**: For bundlers without [exports](https://nodejs.org/api/packages.html#exports-sugar) field support (like Webpack 4), this library automatically falls back to the `main` field entry point, and `es-legacy` directory is imported, which targets `ES2015`. |
922 | 930 |
|
923 | | - - `core-js` |
924 | | - - `@babel/preset-env` with appropriate `useBuiltIns` settings |
925 | | - - Alternative polyfill implementations |
| 931 | +- **UMD Version**: For direct browser usage or static projects without bundlers, enum-plus provides UMD version that can be included via a `<script>` tag. The `umd` directory contains two versions: |
| 932 | + - `enum-plus.min.js`: Targets **`ES2020`**, suitable for modern browsers. |
| 933 | + - `enum-plus-legacy.min.js`: Targets **`ES2015`**, suitable for older browsers. |
926 | 934 |
|
927 | | -- **Node.js Compatibility**: enum-plus requires a minimum of `ES2016` features, compatible with Node.js `v7.x` and above. |
| 935 | +> **Polyfill Strategy**: enum-plus ships without polyfills to minimize bundle size. For legacy browser support, you can include the following tools as needed: |
| 936 | +> |
| 937 | +> - `core-js` |
| 938 | +> - `@babel/preset-env` with appropriate `useBuiltIns` settings |
| 939 | +> - Alternative polyfill implementations |
| 940 | +
|
| 941 | +### **Node.js Environments** |
| 942 | +
|
| 943 | +enum-plus requires a minimum of `ES2016` features, compatible with Node.js `v7.x` and above |
928 | 944 |
|
929 | 945 | --- |
930 | 946 |
|
|
0 commit comments