jinbi-utils 1.0.20 → 1.0.22

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 (83) hide show
  1. package/.babelrc +19 -0
  2. package/.cz-config.js +55 -0
  3. package/.dockerignore +3 -0
  4. package/.editorconfig +12 -0
  5. package/.eslintignore +15 -0
  6. package/.eslintrc.js +54 -0
  7. package/.versionrc.json +9 -0
  8. package/CHANGELOG.md +49 -49
  9. package/CHUNK_OPTIMIZER_USAGE.md +132 -0
  10. package/Dockerfile +3 -0
  11. package/QUICK_RELEASE.md +85 -0
  12. package/README.md +189 -189
  13. package/RELEASE_GUIDE.md +243 -0
  14. package/api-extractor.json +15 -0
  15. package/commitlint.config.js +3 -0
  16. package/dist/index.esm.js +385 -97
  17. package/dist/index.esm.min.js +2 -2
  18. package/dist/index.umd.js +392 -99
  19. package/dist/index.umd.min.js +2 -2
  20. package/jest.config.js +15 -0
  21. package/package.json +82 -109
  22. package/rollup.config.chunk-optimizer.js +32 -0
  23. package/rollup.config.js +73 -0
  24. package/src/array/index.ts +85 -0
  25. package/src/build/chunk-optimizer/ARCHITECTURE.md +347 -0
  26. package/src/build/chunk-optimizer/QUICK_START.md +370 -0
  27. package/src/build/chunk-optimizer/README.md +240 -0
  28. package/src/build/chunk-optimizer/core/chunk-generator.ts +166 -0
  29. package/src/build/chunk-optimizer/core/classifier.ts +148 -0
  30. package/src/build/chunk-optimizer/core/dependency-reader.ts +138 -0
  31. package/src/build/chunk-optimizer/examples/basic-usage.ts +234 -0
  32. package/src/build/chunk-optimizer/index.ts +166 -0
  33. package/src/build/chunk-optimizer/rules/common-rules.ts +131 -0
  34. package/src/build/chunk-optimizer/rules/framework-rules.ts +93 -0
  35. package/src/build/chunk-optimizer/rules/index.ts +27 -0
  36. package/src/build/chunk-optimizer/test.ts +94 -0
  37. package/src/build/chunk-optimizer/types.ts +128 -0
  38. package/src/color/index.ts +58 -0
  39. package/src/common/index.ts +353 -0
  40. package/src/constant/common.constant.ts +13 -0
  41. package/src/date/index.ts +143 -0
  42. package/src/dom/index.ts +198 -0
  43. package/src/file/index.ts +319 -0
  44. package/src/http/apiBuilder/README.md +648 -0
  45. package/src/http/apiBuilder/api-builder.ts +502 -0
  46. package/src/http/apiBuilder/example.ts +243 -0
  47. package/src/http/apiBuilder/index.ts +1 -0
  48. package/src/http/apiBuilder//345/277/253/351/200/237/345/217/202/350/200/203.md +199 -0
  49. package/src/http/http.ts +79 -0
  50. package/src/http/httpEnums.ts +61 -0
  51. package/src/iam/index.ts +46 -0
  52. package/src/index.ts +20 -0
  53. package/src/middleware/requestLogger.middware.ts +385 -0
  54. package/src/middleware/requestLoggerUnified.ts +385 -0
  55. package/src/number/index.ts +362 -0
  56. package/src/object/index.ts +54 -0
  57. package/src/print/index.ts +102 -0
  58. package/src/string/index.ts +189 -0
  59. package/src/utils/curl.ts +99 -0
  60. package/src/validate/index.ts +100 -0
  61. package/src/websocket/emitter.ts +39 -0
  62. package/src/websocket/index.ts +6 -0
  63. package/src/websocket/manager.ts +151 -0
  64. package/src/websocket/pinia-store.ts +91 -0
  65. package/src/websocket/service.ts +34 -0
  66. package/src/websocket/types.ts +45 -0
  67. package/test/common/index.test.ts +19 -0
  68. package/test/date/index.test.ts +107 -0
  69. package/test/file/index.test.ts +104 -0
  70. package/test/number/index.test.ts +108 -0
  71. package/test/object/index.test.ts +20 -0
  72. package/test/string/index.test.ts +82 -0
  73. package/tsconfig.json +39 -0
  74. package/typedoc.json +12 -0
  75. package/types/file/index.d.ts +7 -0
  76. package/types/index.d.ts +1 -0
  77. package/types/websocket/emitter.d.ts +16 -0
  78. package/types/websocket/index.d.ts +6 -0
  79. package/types/websocket/manager.d.ts +36 -0
  80. package/types/websocket/pinia-store.d.ts +25 -0
  81. package/types/websocket/service.d.ts +13 -0
  82. package/types/websocket/types.d.ts +34 -0
  83. package/dist/chunk-optimizer.cjs +0 -703
package/.babelrc ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "presets": [
3
+ [
4
+ "@babel/preset-env",
5
+ {
6
+ "modules": false,
7
+ "targets": {
8
+ "node": "current"
9
+ }
10
+ }
11
+ ],
12
+ "@babel/preset-typescript"
13
+ ],
14
+ "env": {
15
+ "test": {
16
+ "plugins": ["@babel/plugin-transform-modules-commonjs"]
17
+ }
18
+ }
19
+ }
package/.cz-config.js ADDED
@@ -0,0 +1,55 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+
5
+ types: [
6
+ {value: 'feat', name: 'feat: 新特性或功能'},
7
+ {value: 'fix', name: 'fix: 修复Bug'},
8
+ {value: 'docs', name: 'docs: 文档的变更'},
9
+ {value: 'style', name: 'style: 不影响代码运行的风格更改(空白、格式、缺少分号等)'},
10
+ {value: 'refactor', name: 'refactor: 代码重构, 注意和feat、fix区分'},
11
+ {value: 'perf', name: 'perf: 提高性能'},
12
+ {value: 'test', name: 'test: 添加测试'},
13
+ {value: 'chore', name: 'chore: 开发工具(构建、脚手架工具等)和库(如文档生成)的更改'},
14
+ {value: 'revert', name: 'revert: 代码回滚'},
15
+ {value: 'WIP', name: 'WIP: 进行中开发'}
16
+ ],
17
+
18
+ // list of Function Modules
19
+ scopes: [
20
+ {name: '模块1'},
21
+ {name: '模块2'},
22
+ ],
23
+
24
+ // it needs to match the value for field type. Eg.: 'fix'
25
+ /*
26
+ scopeOverrides: {
27
+ fix: [
28
+ {name: 'merge'},
29
+ {name: 'style'},
30
+ {name: 'e2eTest'},
31
+ {name: 'unitTest'}
32
+ ]
33
+ },
34
+ */
35
+ // override the messages, defaults are as follows
36
+ messages: {
37
+ type: '选择一种提交类型:',
38
+ scope: '选择一个scope (可选):',
39
+ // used if allowCustomScopes is true
40
+ customScope: 'Denote the SCOPE of this change:',
41
+ subject: '简短说明:\n',
42
+ body: '长说明,使用"|"换行(可选):\n',
43
+ breaking: '非兼容性说明 (可选):\n',
44
+ footer: '关联关闭的issue,例如:#31, #34(可选):\n',
45
+ confirmCommit: '确定提交说明?'
46
+ },
47
+
48
+
49
+ allowCustomScopes: true,
50
+ allowBreakingChanges: ['feat', 'fix'],
51
+
52
+ // limit subject length
53
+ subjectLimit: 100
54
+
55
+ };
package/.dockerignore ADDED
@@ -0,0 +1,3 @@
1
+ .git
2
+ node_modules
3
+ npm-debug.log
package/.editorconfig ADDED
@@ -0,0 +1,12 @@
1
+ # http://editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ indent_style = space
6
+ indent_size = 2
7
+ charset = utf-8
8
+ trim_trailing_whitespace = true
9
+ insert_final_newline = true
10
+
11
+ [*.md]
12
+ trim_trailing_whitespace = false
package/.eslintignore ADDED
@@ -0,0 +1,15 @@
1
+ /.git
2
+ /.vscode
3
+ node_modules
4
+ dist
5
+ test
6
+ rollup.config.js
7
+ types
8
+ docs
9
+ *
10
+ !src/
11
+ !src/utils/
12
+ !src/utils/curl.ts
13
+ !src/middleware/
14
+ !src/middleware/requestLoggerUnified.ts
15
+ !src/middleware/requestLogger.middware.ts
package/.eslintrc.js ADDED
@@ -0,0 +1,54 @@
1
+ module.exports = {
2
+ "env": {
3
+ "browser": true,
4
+ "commonjs": true,
5
+ "es6": true,
6
+ "node": true
7
+ },
8
+ "extends": [
9
+ "eslint:recommended",
10
+ "plugin:@typescript-eslint/recommended"
11
+ ],
12
+ "parser": "@typescript-eslint/parser",
13
+ "plugins": ["@typescript-eslint"],
14
+ "parserOptions": {
15
+ "ecmaVersion": 2015,
16
+ "sourceType": "module",
17
+ "project": "./tsconfig.json"
18
+ },
19
+ "rules": {
20
+ 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
21
+ 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
22
+ 'prefer-promise-reject-errors': 'off', // 要求使用 Error 对象作为 Promise 拒绝的原因
23
+ 'linebreak-style': 'off', // 回车换行风格
24
+ 'no-trailing-spaces': 1, // 允许在空行、在注释块中使用空白符
25
+ 'import/prefer-default-export': 'off', //
26
+ 'object-curly-newline': 'off', // 不强制花括号内换行
27
+ 'import/named': 'off', // 停用 import/named 校验
28
+ 'no-underscore-dangle': 'off', // 禁止标识符中有悬空下划线
29
+ 'import/order': 'off',
30
+ 'prefer-object-spread': 1, // 禁止使用以对象字面量作为第一个参数的 Object.assign,优先使用对象扩展。
31
+ 'arrow-parens': [2, "as-needed", { "requireForBlockBody": true }], // 要求箭头函数的参数使用圆括号
32
+ "comma-dangle": ["error", "always-multiline"], // 要求或禁止使用拖尾逗号
33
+ "semi": 2, // 要求或禁止使用分号代替 ASI
34
+ "keyword-spacing": 2, // 强制关键字周围空格的一致性
35
+ "@typescript-eslint/explicit-function-return-type": "off",
36
+ "@typescript-eslint/interface-name-prefix": "off",
37
+ "@typescript-eslint/no-empty-function": "off",
38
+ "@typescript-eslint/no-inferrable-types": "off",
39
+ "@typescript-eslint/no-empty-interface": "off",
40
+ "@typescript-eslint/no-non-null-assertion": "off",
41
+ "@typescript-eslint/no-explicit-any": "off",
42
+ "@typescript-eslint/explicit-module-boundary-types": "off",
43
+ "@typescript-eslint/member-delimiter-style": ["error", {
44
+ "multiline": {
45
+ "delimiter": "semi",
46
+ "requireLast": true
47
+ },
48
+ "singleline": {
49
+ "delimiter": "semi",
50
+ "requireLast": true
51
+ }
52
+ }]
53
+ }
54
+ };
@@ -0,0 +1,9 @@
1
+ {
2
+ "types": [
3
+ { "type": "feat", "section": "✨ Features" },
4
+ { "type": "fix", "section": "🐞 Bug Fixes" },
5
+ { "type": "docs", "section": "📖 Documentation" },
6
+ { "type": "style", "section": "🎨 Style" }
7
+ ],
8
+ "releaseCommitMessageFormat": "chore(release): 发布版本 v{{currentTag}}"
9
+ }
package/CHANGELOG.md CHANGED
@@ -1,49 +1,49 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
-
5
- ### [1.0.15](https://cnb.jinbizhihui.com/jinbizhihui/frontend/jbwy-utils/compare/v1.0.14...v1.0.15) (2025-12-04)
6
-
7
- ### [1.0.14](https://cnb.jinbizhihui.com/jinbizhihui/frontend/jbwy-utils/compare/v1.0.13...v1.0.14) (2025-12-04)
8
-
9
- ### [1.0.13](https://cnb.jinbizhihui.com/jinbizhihui/frontend/jbwy-utils/compare/v1.0.12...v1.0.13) (2025-12-04)
10
-
11
-
12
- ### ✨ Features
13
-
14
- * 更新-apiBuilder ([5f09e35](https://cnb.jinbizhihui.com/jinbizhihui/frontend/jbwy-utils/commit/5f09e357cc8e306daacdd0f33599472cf2375b14))
15
- * upateAPIbuilder ([482f2e1](https://cnb.jinbizhihui.com/jinbizhihui/frontend/jbwy-utils/commit/482f2e100a49d167e4c5129cacd496fc85223567))
16
- * upateAPIbuilder ([42a1f40](https://cnb.jinbizhihui.com/jinbizhihui/frontend/jbwy-utils/commit/42a1f40a0606a3240726b4227155758950b4f722))
17
-
18
- ### [1.0.12](https://cnb.jinbizhihui.com/jinbizhihui/frontend/jbwy-utils/compare/v1.0.11...v1.0.12) (2025-11-17)
19
-
20
- ### [1.0.11](https://cnb.jinbizhihui.com/jinbizhihui/frontend/jbwy-utils/compare/v1.0.10...v1.0.11) (2025-11-11)
21
-
22
- ### [1.0.10](https://cnb.jinbizhihui.com/jinbizhihui/frontend/jbwy-utils/compare/v1.0.9...v1.0.10) (2025-11-11)
23
-
24
- ### [1.0.9](https://cnb.jinbizhihui.com/jinbizhihui/frontend/jbwy-utils/compare/v1.0.2...v1.0.9) (2025-11-11)
25
-
26
-
27
- ### ✨ Features
28
-
29
- * **build:** 新增依赖分类与分块优化功能(Chunk Optimizer) ([21c2d1a](https://cnb.jinbizhihui.com/jinbizhihui/frontend/jbwy-utils/commit/21c2d1abb41c62b73bb2820a6132b3ffe027c086))
30
- * **build:** 新增依赖分类与分块优化功能(Chunk Optimizer) ([1a3113d](https://cnb.jinbizhihui.com/jinbizhihui/frontend/jbwy-utils/commit/1a3113dee7d8e7f67a7e48d9c6976514fbfd5297))
31
- * 提交 saas平台项目需要的方法 ([e9bdefd](https://cnb.jinbizhihui.com/jinbizhihui/frontend/jbwy-utils/commit/e9bdefd14d8d3006df3ff0e144321b2abf858444))
32
- * 新增 `ApiBuilder` 工具类 ([62bc47e](https://cnb.jinbizhihui.com/jinbizhihui/frontend/jbwy-utils/commit/62bc47eb18f3f54495239ecd0cb40e0a78c3899a))
33
-
34
- ### [1.0.2](https://e.coding.net/jinbicloud/P8/jbwy-utils/compare/v1.0.1...v1.0.2) (2025-07-31)
35
-
36
- ### [1.0.1](https://e.coding.net/jinbicloud/P8/jbwy-utils/compare/v1.0.0...v1.0.1) (2025-07-25)
37
-
38
- ## 1.0.0 (2025-07-25)
39
-
40
-
41
- ### ✨ Features
42
-
43
- * 1.调整日志中间件 接入的服务地址 ([5bf17c3](https://e.coding.net/jinbicloud/P8/jbwy-utils/commit/5bf17c3ada3ec825c7dc8ac1f1cae74e1ea54e76))
44
- * 1.新增 nodejs 日志中间件工具库 2. 新增iam工具库 ([07a48c8](https://e.coding.net/jinbicloud/P8/jbwy-utils/commit/07a48c87cb061401aadca3026a7821ee6f0b8069))
45
- * 更新版本和依赖项 ([1bcc026](https://e.coding.net/jinbicloud/P8/jbwy-utils/commit/1bcc026a8d2c8019180e0418bde7bef485ade566))
46
- * 删除 wecom 模块及相关文档 ([6ef1215](https://e.coding.net/jinbicloud/P8/jbwy-utils/commit/6ef12157d1b7ff4b4bd1217a34fcca5af49bc3e2))
47
- * 添加版本控制配置和更新依赖项 ([cfecef1](https://e.coding.net/jinbicloud/P8/jbwy-utils/commit/cfecef19fff25fb167ae251246ee268d9caaaa22))
48
- * 添加新模块和配置更新 ([bba4a67](https://e.coding.net/jinbicloud/P8/jbwy-utils/commit/bba4a67f1f5094dd89f6e51708aa50f8e1b00b65))
49
- * 新增分转元方法 ([cc9d640](https://e.coding.net/jinbicloud/P8/jbwy-utils/commit/cc9d640d53497c4c7784606538d9a0bf49bd15cb))
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
+
5
+ ### [1.0.15](https://cnb.jinbizhihui.com/jinbizhihui/frontend/jbwy-utils/compare/v1.0.14...v1.0.15) (2025-12-04)
6
+
7
+ ### [1.0.14](https://cnb.jinbizhihui.com/jinbizhihui/frontend/jbwy-utils/compare/v1.0.13...v1.0.14) (2025-12-04)
8
+
9
+ ### [1.0.13](https://cnb.jinbizhihui.com/jinbizhihui/frontend/jbwy-utils/compare/v1.0.12...v1.0.13) (2025-12-04)
10
+
11
+
12
+ ### ✨ Features
13
+
14
+ * 更新-apiBuilder ([5f09e35](https://cnb.jinbizhihui.com/jinbizhihui/frontend/jbwy-utils/commit/5f09e357cc8e306daacdd0f33599472cf2375b14))
15
+ * upateAPIbuilder ([482f2e1](https://cnb.jinbizhihui.com/jinbizhihui/frontend/jbwy-utils/commit/482f2e100a49d167e4c5129cacd496fc85223567))
16
+ * upateAPIbuilder ([42a1f40](https://cnb.jinbizhihui.com/jinbizhihui/frontend/jbwy-utils/commit/42a1f40a0606a3240726b4227155758950b4f722))
17
+
18
+ ### [1.0.12](https://cnb.jinbizhihui.com/jinbizhihui/frontend/jbwy-utils/compare/v1.0.11...v1.0.12) (2025-11-17)
19
+
20
+ ### [1.0.11](https://cnb.jinbizhihui.com/jinbizhihui/frontend/jbwy-utils/compare/v1.0.10...v1.0.11) (2025-11-11)
21
+
22
+ ### [1.0.10](https://cnb.jinbizhihui.com/jinbizhihui/frontend/jbwy-utils/compare/v1.0.9...v1.0.10) (2025-11-11)
23
+
24
+ ### [1.0.9](https://cnb.jinbizhihui.com/jinbizhihui/frontend/jbwy-utils/compare/v1.0.2...v1.0.9) (2025-11-11)
25
+
26
+
27
+ ### ✨ Features
28
+
29
+ * **build:** 新增依赖分类与分块优化功能(Chunk Optimizer) ([21c2d1a](https://cnb.jinbizhihui.com/jinbizhihui/frontend/jbwy-utils/commit/21c2d1abb41c62b73bb2820a6132b3ffe027c086))
30
+ * **build:** 新增依赖分类与分块优化功能(Chunk Optimizer) ([1a3113d](https://cnb.jinbizhihui.com/jinbizhihui/frontend/jbwy-utils/commit/1a3113dee7d8e7f67a7e48d9c6976514fbfd5297))
31
+ * 提交 saas平台项目需要的方法 ([e9bdefd](https://cnb.jinbizhihui.com/jinbizhihui/frontend/jbwy-utils/commit/e9bdefd14d8d3006df3ff0e144321b2abf858444))
32
+ * 新增 `ApiBuilder` 工具类 ([62bc47e](https://cnb.jinbizhihui.com/jinbizhihui/frontend/jbwy-utils/commit/62bc47eb18f3f54495239ecd0cb40e0a78c3899a))
33
+
34
+ ### [1.0.2](https://e.coding.net/jinbicloud/P8/jbwy-utils/compare/v1.0.1...v1.0.2) (2025-07-31)
35
+
36
+ ### [1.0.1](https://e.coding.net/jinbicloud/P8/jbwy-utils/compare/v1.0.0...v1.0.1) (2025-07-25)
37
+
38
+ ## 1.0.0 (2025-07-25)
39
+
40
+
41
+ ### ✨ Features
42
+
43
+ * 1.调整日志中间件 接入的服务地址 ([5bf17c3](https://e.coding.net/jinbicloud/P8/jbwy-utils/commit/5bf17c3ada3ec825c7dc8ac1f1cae74e1ea54e76))
44
+ * 1.新增 nodejs 日志中间件工具库 2. 新增iam工具库 ([07a48c8](https://e.coding.net/jinbicloud/P8/jbwy-utils/commit/07a48c87cb061401aadca3026a7821ee6f0b8069))
45
+ * 更新版本和依赖项 ([1bcc026](https://e.coding.net/jinbicloud/P8/jbwy-utils/commit/1bcc026a8d2c8019180e0418bde7bef485ade566))
46
+ * 删除 wecom 模块及相关文档 ([6ef1215](https://e.coding.net/jinbicloud/P8/jbwy-utils/commit/6ef12157d1b7ff4b4bd1217a34fcca5af49bc3e2))
47
+ * 添加版本控制配置和更新依赖项 ([cfecef1](https://e.coding.net/jinbicloud/P8/jbwy-utils/commit/cfecef19fff25fb167ae251246ee268d9caaaa22))
48
+ * 添加新模块和配置更新 ([bba4a67](https://e.coding.net/jinbicloud/P8/jbwy-utils/commit/bba4a67f1f5094dd89f6e51708aa50f8e1b00b65))
49
+ * 新增分转元方法 ([cc9d640](https://e.coding.net/jinbicloud/P8/jbwy-utils/commit/cc9d640d53497c4c7784606538d9a0bf49bd15cb))
@@ -0,0 +1,132 @@
1
+ # Chunk Optimizer 使用说明
2
+
3
+ ## 问题说明
4
+
5
+ `chunk-optimizer` 是一个**构建时工具**,它依赖 Node.js 内置模块(`fs` 和 `path`),只能在 Node.js 环境中运行(如 `vite.config.ts`)。
6
+
7
+ 从 v1.0.9 版本开始,`chunk-optimizer` 已从主入口文件中移除,以避免将 Node.js 模块打包到浏览器端的 bundle 中。
8
+
9
+ ## 正确的使用方式
10
+
11
+ ### 在消费项目中使用
12
+
13
+ **方式一:通过单独的导出路径(推荐)**
14
+
15
+ ```typescript
16
+ // vite.config.ts
17
+ import { defineConfig } from 'vite'
18
+ import { createChunkOptimizer } from 'jinbi-utils/chunk-optimizer'
19
+
20
+ const optimizer = createChunkOptimizer({
21
+ framework: 'vue',
22
+ debug: true
23
+ })
24
+
25
+ export default defineConfig({
26
+ build: {
27
+ rollupOptions: {
28
+ output: {
29
+ manualChunks: optimizer.generate()
30
+ }
31
+ }
32
+ }
33
+ })
34
+ ```
35
+
36
+ **方式二:直接从源码导入**
37
+
38
+ ```typescript
39
+ // vite.config.ts
40
+ import { defineConfig } from 'vite'
41
+ import { createChunkOptimizer } from 'jinbi-utils/src/build/chunk-optimizer'
42
+
43
+ // 使用方式同上
44
+ ```
45
+
46
+ ### 在浏览器代码中使用其他工具函数
47
+
48
+ 浏览器代码中可以正常导入其他工具函数,不会受到影响:
49
+
50
+ ```typescript
51
+ // 在 .vue 或 .ts 文件中
52
+ import { formatTime, formatPhone, isEmpty } from 'jinbi-utils'
53
+
54
+ // 正常使用
55
+ const time = formatTime(Date.now())
56
+ ```
57
+
58
+ ## 版本升级指南
59
+
60
+ 如果你的项目之前使用的是 v1.0.8 或更早版本,并且遇到了以下错误:
61
+
62
+ ```
63
+ error during build:
64
+ "resolve" is not exported by "__vite-browser-external"
65
+ ```
66
+
67
+ 请按照以下步骤升级:
68
+
69
+ ### 步骤 1: 更新包版本
70
+
71
+ ```bash
72
+ npm install jinbi-utils@latest
73
+ # 或
74
+ pnpm update jinbi-utils
75
+ ```
76
+
77
+ ### 步骤 2: 修改 vite.config.ts 中的导入
78
+
79
+ **修改前:**
80
+ ```typescript
81
+ import { createChunkOptimizer } from 'jinbi-utils'
82
+ ```
83
+
84
+ **修改后:**
85
+ ```typescript
86
+ import { createChunkOptimizer } from 'jinbi-utils/chunk-optimizer'
87
+ ```
88
+
89
+ ### 步骤 3: 重新构建
90
+
91
+ ```bash
92
+ npm run build
93
+ ```
94
+
95
+ ## 技术细节
96
+
97
+ ### 为什么要这样做?
98
+
99
+ 1. **chunk-optimizer 依赖 Node.js 模块**:它需要读取 `package.json` 文件来分析依赖
100
+ 2. **浏览器环境不支持 Node.js 模块**:`fs` 和 `path` 无法在浏览器中运行
101
+ 3. **Vite 的处理方式**:当浏览器代码导入包含 Node.js 模块的文件时,Vite 会尝试用 polyfill 替换,但这会导致错误
102
+
103
+ ### 解决方案的原理
104
+
105
+ 通过将 `chunk-optimizer` 从主入口移除,并提供单独的导出路径:
106
+
107
+ - **浏览器代码**导入 `jinbi-utils` 时,只会加载不包含 Node.js 模块的代码
108
+ - **构建配置**导入 `jinbi-utils/chunk-optimizer` 时,可以正常使用 Node.js 模块
109
+
110
+ ## 常见问题
111
+
112
+ ### Q: 我的项目没有使用 chunk-optimizer,也遇到了这个错误?
113
+
114
+ A: 如果你的项目代码中导入了 `jinbi-utils`,但没有使用 `chunk-optimizer`,升级到最新版本即可解决。
115
+
116
+ ### Q: 我可以在浏览器代码中使用 chunk-optimizer 吗?
117
+
118
+ A: 不可以。`chunk-optimizer` 是构建时工具,只能在 Node.js 环境(如 `vite.config.ts`)中使用。
119
+
120
+ ### Q: 升级后,其他工具函数还能正常使用吗?
121
+
122
+ A: 可以。其他所有工具函数(如 `formatTime`、`formatPhone` 等)都不受影响,可以在浏览器代码中正常使用。
123
+
124
+ ## 联系支持
125
+
126
+ 如果遇到问题,请提供以下信息:
127
+
128
+ 1. `jinbi-utils` 版本号
129
+ 2. 错误信息截图
130
+ 3. `vite.config.ts` 中的相关配置
131
+ 4. Node.js 和 npm/pnpm 版本
132
+
package/Dockerfile ADDED
@@ -0,0 +1,3 @@
1
+ FROM nginx
2
+
3
+ COPY docs /usr/share/nginx/html/
@@ -0,0 +1,85 @@
1
+ # 🚀 快速发布参考
2
+
3
+ ## 一键发布命令
4
+
5
+ ```bash
6
+ # 🔧 修复 bug(1.0.8 -> 1.0.9)
7
+ npm run release
8
+
9
+ # 或明确指定
10
+ npm run release:patch
11
+
12
+ # ✨ 新功能(1.0.8 -> 1.1.0)
13
+ npm run release:minor
14
+
15
+ # 💥 破坏性更新(1.0.8 -> 2.0.0)
16
+ npm run release:major
17
+
18
+ # 🧪 测试版本(1.0.8 -> 1.0.9-beta.0)
19
+ npm run release:beta
20
+ ```
21
+
22
+ ## 发布前准备
23
+
24
+ 1. **提交所有更改**
25
+ ```bash
26
+ git add .
27
+ git commit -m "feat: 添加新功能"
28
+ ```
29
+
30
+ 2. **确保在正确的分支**
31
+ ```bash
32
+ git checkout main
33
+ ```
34
+
35
+ 3. **拉取最新代码**
36
+ ```bash
37
+ git pull origin main
38
+ ```
39
+
40
+ ## Commit 规范速查
41
+
42
+ | 类型 | 说明 | 示例 |
43
+ |------|------|------|
44
+ | `feat` | 新功能 | `feat: 添加文件上传功能` |
45
+ | `fix` | 修复 bug | `fix: 修复日期格式化问题` |
46
+ | `docs` | 文档 | `docs: 更新 API 文档` |
47
+ | `style` | 格式 | `style: 格式化代码` |
48
+ | `refactor` | 重构 | `refactor: 重构用户模块` |
49
+ | `perf` | 性能 | `perf: 优化列表渲染` |
50
+ | `test` | 测试 | `test: 添加单元测试` |
51
+ | `chore` | 构建 | `chore: 更新依赖` |
52
+
53
+ ## 自动化流程
54
+
55
+ 运行 `npm run release` 会自动:
56
+
57
+ 1. ✅ 运行构建
58
+ 2. 📝 更新版本号
59
+ 3. 📄 生成 CHANGELOG
60
+ 4. 🏷️ 创建 Git Tag
61
+ 5. 💾 提交更改
62
+ 6. 📤 发布到 npm
63
+ 7. ⬆️ 推送到 Git
64
+
65
+ ## 常见问题
66
+
67
+ **Q: 如何撤销发布?**
68
+ ```bash
69
+ npm unpublish jinbi-utils@版本号
70
+ ```
71
+
72
+ **Q: 如何查看当前版本?**
73
+ ```bash
74
+ npm view jinbi-utils version
75
+ ```
76
+
77
+ **Q: 发布失败怎么办?**
78
+ - 检查是否已登录:`npm whoami`
79
+ - 检查网络连接
80
+ - 查看错误信息
81
+
82
+ ## 详细文档
83
+
84
+ 查看 [RELEASE_GUIDE.md](./RELEASE_GUIDE.md) 了解完整的发布流程。
85
+