@base-web-kits/base-tools-ts 1.3.8 → 1.3.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +23 -37
  2. package/package.json +39 -39
package/README.md CHANGED
@@ -128,40 +128,32 @@ npx skills add gancao-web/base-tools
128
128
 
129
129
  本工具库和相关依赖可能涉及的新特性及其最低兼容版本:
130
130
 
131
- | 特性 | ES 版本 | 最低兼容版本 (Browser/OS) |
132
- | :---------------------------------------- | :------ | :---------------------------------- |
133
- | **Array.prototype.includes** | ES2016 | Chrome 47+, iOS 9+, Android 6.0+ |
134
- | **Object.values / entries** | ES2017 | Chrome 54+, iOS 10.3+, Android 7.0+ |
135
- | **String.prototype.padStart / padEnd** | ES2017 | Chrome 57+, iOS 10.3+, Android 8.0+ |
136
- | **Object.getOwnPropertyDescriptors** | ES2017 | Chrome 54+, iOS 10.3+, Android 7.0+ |
137
- | **Promise.prototype.finally** | ES2018 | Chrome 63+, iOS 11.3+, Android 9.0+ |
138
- | **Async Iterator (Symbol.asyncIterator)** | ES2018 | Chrome 63+, iOS 12.0+, Android 9.0+ |
139
- | **Object.fromEntries** | ES2019 | Chrome 73+, iOS 12.2+, Android 10+ |
140
- | **Array.prototype.flat / flatMap** | ES2019 | Chrome 69+, iOS 12.0+, Android 9.0+ |
141
- | **String.prototype.trimStart / trimEnd** | ES2019 | Chrome 66+, iOS 12.0+, Android 9.0+ |
142
- | **Promise.allSettled** | ES2020 | Chrome 76+, iOS 13.0+, Android 10+ |
143
- | **String.prototype.matchAll** | ES2020 | Chrome 80+, iOS 13.0+, Android 10+ |
144
- | **BigInt** | ES2020 | Chrome 67+, iOS 14.0+, Android 11+ |
145
- | **globalThis** | ES2020 | Chrome 71+, iOS 12.2+, Android 9.0+ |
146
- | **String.prototype.replaceAll** | ES2021 | Chrome 85+, iOS 13.4+, Android 11+ |
147
- | **Promise.any** | ES2021 | Chrome 85+, iOS 14.0+, Android 11+ |
148
- | **WeakRef / FinalizationRegistry** | ES2021 | Chrome 84+, iOS 14.5+, Android 11+ |
149
- | **Array/String.prototype.at** | ES2022 | Chrome 92+, iOS 15.4+, Android 12+ |
150
- | **Error.prototype.cause** | ES2022 | Chrome 93+, iOS 15.0+, Android 12+ |
151
- | **Object.hasOwn** | ES2022 | Chrome 93+, iOS 15.4+, Android 12+ |
131
+ | 特性 | ES 版本 | 最低兼容版本 (Browser/OS) |
132
+ | :--------------------------------------- | :------ | :---------------------------------- |
133
+ | **Object.values / entries** | ES2017 | Chrome 54+, iOS 10.3+, Android 7.0+ |
134
+ | **String.prototype.padStart / padEnd** | ES2017 | Chrome 57+, iOS 10.3+, Android 8.0+ |
135
+ | **Object.getOwnPropertyDescriptors** | ES2017 | Chrome 54+, iOS 10.3+, Android 7.0+ |
136
+ | **Promise.prototype.finally** | ES2018 | Chrome 63+, iOS 11.3+, Android 9.0+ |
137
+ | **Symbol.asyncIterator** | ES2018 | Chrome 63+, iOS 12.0+, Android 9.0+ |
138
+ | **Object.fromEntries** | ES2019 | Chrome 73+, iOS 12.2+, Android 10+ |
139
+ | **Array.prototype.flat / flatMap** | ES2019 | Chrome 69+, iOS 12.0+, Android 9.0+ |
140
+ | **String.prototype.trimStart / trimEnd** | ES2019 | Chrome 66+, iOS 12.0+, Android 9.0+ |
141
+ | **Promise.allSettled** | ES2020 | Chrome 76+, iOS 13.0+, Android 10+ |
142
+ | **String.prototype.matchAll** | ES2020 | Chrome 80+, iOS 13.0+, Android 10+ |
143
+ | **BigInt** | ES2020 | Chrome 67+, iOS 14.0+, Android 11+ |
144
+ | **globalThis** | ES2020 | Chrome 71+, iOS 12.2+, Android 9.0+ |
145
+ | **String.prototype.replaceAll** | ES2021 | Chrome 85+, iOS 13.4+, Android 11+ |
146
+ | **Promise.any** | ES2021 | Chrome 85+, iOS 14.0+, Android 11+ |
147
+ | **WeakRef / FinalizationRegistry** | ES2021 | Chrome 84+, iOS 14.5+, Android 11+ |
148
+ | **Array/String.prototype.at** | ES2022 | Chrome 92+, iOS 15.4+, Android 12+ |
149
+ | **Error.prototype.cause** | ES2022 | Chrome 93+, iOS 15.0+, Android 12+ |
150
+ | **Object.hasOwn** | ES2022 | Chrome 93+, iOS 15.4+, Android 12+ |
152
151
 
153
152
  本工具库构建目标为 **ES2015+**。但不内置 Polyfill, 如需支持低版本浏览器, 请务必在项目中配置 Polyfill。
154
153
 
155
154
  ### 配置 Polyfill
156
155
 
157
- 需经过两步:
158
-
159
- 1. 配置打包工具, 将ES6+代码转换为ES5。
160
- 2. 在入口文件顶部引入 `core-js` 进行 Polyfill。
161
-
162
- 以 Vite 项目为例:
163
-
164
- 1. 使用 `@vitejs/plugin-legacy` 插件,将ES6+代码转换为ES5。
156
+ 以 Vite 项目为例, 使用 `@vitejs/plugin-legacy` 插件自动按需注入 Polyfill。
165
157
 
166
158
  ```ts
167
159
  // vite.config.ts
@@ -179,15 +171,9 @@ export default {
179
171
  // 与Element对齐: https://element-plus.org/zh-CN/guide/installation
180
172
  targets: ['Chrome >= 64', 'Edge >= 79', 'Firefox >= 78', 'Safari >= 12', 'not IE 11'],
181
173
 
182
- renderLegacyChunks: true, // 必须开启, 确保生成 ES5 兼容包
183
- modernPolyfills: false, // 关闭按需注入polyfill, 因为legacy无法全量分析项目代码间接依赖了哪些新API, 需在入口文件 main.ts 全量引入 'core-js/stable'
174
+ // 按需自动引入polyfill (需使用vite3以上版本,因为vite2.x缺少新的ES特性,如Object.hasOwn)
175
+ modernPolyfills: true,
184
176
  }),
185
177
  ],
186
178
  };
187
179
  ```
188
-
189
- 2. 入口文件 main.ts 顶部引入 core-js/stable 进行 Polyfill
190
-
191
- ```ts
192
- import 'core-js/stable'; // 安装命令: npm install core-js
193
- ```
package/package.json CHANGED
@@ -1,39 +1,39 @@
1
- {
2
- "name": "@base-web-kits/base-tools-ts",
3
- "version": "1.3.8",
4
- "sideEffects": false,
5
- "description": "Independent TS utilities package built from src/ts.",
6
- "keywords": [
7
- "base-tools",
8
- "ts",
9
- "utilities"
10
- ],
11
- "license": "MIT",
12
- "main": "./dist/index.cjs",
13
- "module": "./dist/index.mjs",
14
- "types": "./dist/index.d.ts",
15
- "exports": {
16
- ".": {
17
- "types": "./dist/index.d.ts",
18
- "import": "./dist/index.mjs",
19
- "require": "./dist/index.cjs"
20
- }
21
- },
22
- "files": [
23
- "dist",
24
- "README.md",
25
- "src"
26
- ],
27
- "dependencies": {
28
- "es-toolkit": "^1.44.0",
29
- "bignumber.js": "^9.1.2",
30
- "dayjs": "^1.11.19",
31
- "mitt": "^3.0.1"
32
- },
33
- "peerDependencies": {
34
- "dayjs": "^1.0.0"
35
- },
36
- "publishConfig": {
37
- "registry": "https://registry.npmjs.org"
38
- }
39
- }
1
+ {
2
+ "name": "@base-web-kits/base-tools-ts",
3
+ "version": "1.3.10",
4
+ "sideEffects": false,
5
+ "description": "Independent TS utilities package built from src/ts.",
6
+ "keywords": [
7
+ "base-tools",
8
+ "ts",
9
+ "utilities"
10
+ ],
11
+ "license": "MIT",
12
+ "main": "./dist/index.cjs",
13
+ "module": "./dist/index.mjs",
14
+ "types": "./dist/index.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.mjs",
19
+ "require": "./dist/index.cjs"
20
+ }
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "README.md",
25
+ "src"
26
+ ],
27
+ "dependencies": {
28
+ "es-toolkit": "^1.44.0",
29
+ "bignumber.js": "^9.1.2",
30
+ "dayjs": "^1.11.19",
31
+ "mitt": "^3.0.1"
32
+ },
33
+ "peerDependencies": {
34
+ "dayjs": "^1.0.0"
35
+ },
36
+ "publishConfig": {
37
+ "registry": "https://registry.npmjs.org"
38
+ }
39
+ }