@1-/minify_size 0.1.5 → 0.1.6

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 (3) hide show
  1. package/README.md +55 -51
  2. package/_.js +1 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -6,64 +6,66 @@
6
6
  # @1-/minify_size : Minify JavaScript and report Brotli-compressed size
7
7
 
8
8
  - [@1-/minify_size : Minify JavaScript and report Brotli-compressed size](#1-minify_size-minify-javascript-and-report-brotli-compressed-size)
9
- - [1. Introduction](#1-introduction)
10
- - [2. Usage Demo](#2-usage-demo)
11
- - [3. Design Concept](#3-design-concept)
12
- - [4. Tech Stack](#4-tech-stack)
9
+ - [1. Functionality](#1-functionality)
10
+ - [2. Usage](#2-usage)
11
+ - [3. Design](#3-design)
12
+ - [4. Technology Stack](#4-technology-stack)
13
13
  - [5. Code Structure](#5-code-structure)
14
14
  - [6. History](#6-history)
15
15
  - [About](#about)
16
16
 
17
- ## 1. Introduction
17
+ ## 1. Functionality
18
18
 
19
- Evaluates JavaScript library size under modern network transmission environments supporting Brotli. For all `.js` files in the specified directory, performs:
19
+ Measure JavaScript library transmission size under Brotli-enabled network environments. Processes all `.js` files in a specified directory by:
20
20
 
21
- - Bundling using `@1-/rolldown` (Rust-based JavaScript bundler)
22
- - UTF-8 encoding of the bundled code
23
- - Brotli compression via Node.js built-in `node:zlib.brotliCompress` to compute final byte length
24
- - Returns total bundled compressed size (bytes)
21
+ - Bundling with `@1-/rolldown` (Rust-based JavaScript bundler)
22
+ - UTF-8 encoding using `@3-/utf8` TextEncoder
23
+ - Brotli compression via Node.js built-in `node:zlib.brotliCompress`
24
+ - Returning total compressed byte count of bundled output
25
25
 
26
- ## 2. Usage Demo
26
+ Excludes test files matching `/^(|\/)tests?(\/|$)/` and `node_modules` directories.
27
27
 
28
- Install dependency:
28
+ ## 2. Usage
29
+
30
+ Install locally:
29
31
 
30
32
  ```bash
31
33
  npm install @1-/minify_size
32
34
  ```
33
35
 
34
- or install globally:
36
+ Install globally:
35
37
 
36
38
  ```bash
37
39
  npm install -g @1-/minify_size
38
40
  ```
39
41
 
40
- Run command (specify the directory to analyze):
42
+ Execute with target directory:
41
43
 
42
44
  ```bash
43
45
  minify_size ./src
44
46
  ```
45
47
 
46
- Example output:
48
+ Output example:
47
49
 
48
50
  ```
49
51
  650
50
52
  ```
51
53
 
52
- ## 3. Design Concept
54
+ ## 3. Design
53
55
 
54
56
  Execution flow (vertical Mermaid diagram):
55
57
 
56
- ![](https://fastly.jsdelivr.net/gh/webc-fs/-@D7/nQLapVbeR_9qMiOldgug.svg)
58
+ ![](https://fastly.jsdelivr.net/gh/webc-fs/-@al/eo5PAnMMwP9cRbLWbHQg.svg)
57
59
 
58
- ## 4. Tech Stack
60
+ ## 4. Technology Stack
59
61
 
60
- - **Runtime**: Node.js / Bun
62
+ - **Runtime**: Bun / Node.js
61
63
  - **Bundler**: `@1-/rolldown` v0.1.7 (Rust-based JavaScript bundler)
62
- - **Brotli Engine**: Built-in `node:zlib` (Brotli compression)
63
- - **Arg Parser**: `yargs` v18.0.0
64
- - **Encoding**: `@3-/utf8` v0.1.1 (TextEncoder-based UTF-8 encoding)
65
- - **File Walking**: `@1-/walk` v0.1.2 (Directory traversal utility)
66
- - **Dependency Management**: npm
64
+ - **Compression**: `node:zlib.brotliCompress` (built-in Brotli)
65
+ - **Argument parsing**: `yargs` v18.0.0
66
+ - **Encoding**: `@3-/utf8` v0.1.1 (TextEncoder-based UTF-8)
67
+ - **File traversal**: `@1-/walk` v0.1.2 (directory traversal utility)
68
+ - **Package management**: npm
67
69
  - **Testing**: bun:test
68
70
 
69
71
  ## 5. Code Structure
@@ -76,7 +78,7 @@ src/
76
78
 
77
79
  ## 6. History
78
80
 
79
- Brotli was developed by Jyrki Alakuijala and Zoltán Szabadka at Google in 2013. It was initially designed for compression of web fonts, and was later extended to become a general-purpose compression algorithm optimized for web transmission, becoming an industry standard (RFC 7932). Modern JavaScript bundlers like rolldown leverage Rust's performance to achieve sub-second builds while maintaining compatibility with existing JavaScript tooling ecosystems.
81
+ Brotli was developed by Jyrki Alakuijala and Zoltán Szabadka at Google in 2013. Initially designed for web font compression, it evolved into a general-purpose algorithm optimized for web transmission and became an industry standard (RFC 7932). Modern JavaScript bundlers like rolldown leverage Rust's performance for sub-second builds while maintaining compatibility with existing JavaScript tooling ecosystems.
80
82
 
81
83
  ## About
82
84
 
@@ -91,38 +93,40 @@ This library is developed by [WebC.site](https://webc.site).
91
93
  # @1-/minify_size : Minify JavaScript and report Brotli-compressed size
92
94
 
93
95
  - [@1-/minify_size : Minify JavaScript and report Brotli-compressed size](#1-minify_size-minify-javascript-and-report-brotli-compressed-size)
94
- - [1. 功能介绍](#1-功能介绍)
95
- - [2. 使用演示](#2-使用演示)
96
+ - [1. 功能性](#1-功能性)
97
+ - [2. 使用方法](#2-使用方法)
96
98
  - [3. 设计思路](#3-设计思路)
97
99
  - [4. 技术栈](#4-技术栈)
98
100
  - [5. 代码结构](#5-代码结构)
99
- - [6. 历史故事](#6-历史故事)
101
+ - [6. 历史背景](#6-历史背景)
100
102
  - [关于](#关于)
101
103
 
102
- ## 1. 功能介绍
104
+ ## 1. 功能性
103
105
 
104
- 评估 JavaScript 库在支持 Brotli 的网络传输环境下的实际传输体积。对指定目录中所有 `.js` 文件执行以下操作:
106
+ 测量 JavaScript 库在支持 Brotli 的网络环境中的传输体积。对指定目录中所有 `.js` 文件执行以下操作:
105
107
 
106
108
  - 使用 `@1-/rolldown`(Rust 实现的 JavaScript 打包器)进行打包
107
- - 将打包后代码编码为 UTF-8 字节流
108
- - 使用 Node.js 内置 `node:zlib.brotliCompress` 计算 Brotli 压缩后字节长度
109
- - 返回整体打包压缩后大小(字节)
109
+ - 使用 `@3-/utf8` TextEncoder 进行 UTF-8 编码
110
+ - 使用 Node.js 内置 `node:zlib.brotliCompress` 进行 Brotli 压缩
111
+ - 返回整体打包输出的压缩后字节长度
112
+
113
+ 排除匹配 `/^(|\/)tests?(\/|$)/` 的测试文件和 `node_modules` 目录。
110
114
 
111
- ## 2. 使用演示
115
+ ## 2. 使用方法
112
116
 
113
- 安装依赖:
117
+ 本地安装:
114
118
 
115
119
  ```bash
116
120
  npm install @1-/minify_size
117
121
  ```
118
122
 
119
- 或全局安装:
123
+ 全局安装:
120
124
 
121
125
  ```bash
122
126
  npm install -g @1-/minify_size
123
127
  ```
124
128
 
125
- 运行命令(指定待分析的目录):
129
+ 执行命令并指定目标目录:
126
130
 
127
131
  ```bash
128
132
  minify_size ./src
@@ -136,32 +140,32 @@ minify_size ./src
136
140
 
137
141
  ## 3. 设计思路
138
142
 
139
- 系统执行流程如下(垂直 Mermaid 流程图):
143
+ 执行流程(垂直 Mermaid 流程图):
140
144
 
141
- ![](https://fastly.jsdelivr.net/gh/webc-fs/-@Qx/di2QsMfRjPdfYr2IasNQ.svg)
145
+ ![](https://fastly.jsdelivr.net/gh/webc-fs/-@yh/rGQ5Y3ZbsLqLF6zENpxQ.svg)
142
146
 
143
147
  ## 4. 技术栈
144
148
 
145
- - **Runtime**: Node.js / Bun
146
- - **Bundler**: `@1-/rolldown` v0.1.7 (Rust-based JavaScript bundler)
147
- - **Brotli Engine**: 内置 `node:zlib` (Brotli compression)
148
- - **Arg Parser**: `yargs` v18.0.0
149
- - **Encoding**: `@3-/utf8` v0.1.1 (TextEncoder-based UTF-8 encoding)
150
- - **File Walking**: `@1-/walk` v0.1.2 (Directory traversal utility)
151
- - **Dependency Management**: npm
152
- - **Testing**: bun:test
149
+ - **运行时**: Bun / Node.js
150
+ - **打包器**: `@1-/rolldown` v0.1.7 (Rust 实现的 JavaScript 打包器)
151
+ - **压缩算法**: `node:zlib.brotliCompress` (内置 Brotli)
152
+ - **参数解析**: `yargs` v18.0.0
153
+ - **编码**: `@3-/utf8` v0.1.1 (TextEncoder 实现的 UTF-8)
154
+ - **文件遍历**: `@1-/walk` v0.1.2 (目录遍历工具)
155
+ - **包管理**: npm
156
+ - **测试**: bun:test
153
157
 
154
158
  ## 5. 代码结构
155
159
 
156
160
  ```
157
161
  src/
158
- ├── cli.js # CLI 命令行入口,解析目录参数并调用主函数
159
- └── _.js # 目录遍历、打包处理、Brotli压缩计算
162
+ ├── cli.js # CLI 入口,解析目录参数并调用主函数
163
+ └── _.js # 目录遍历、打包处理、Brotli 压缩计算
160
164
  ```
161
165
 
162
- ## 6. 历史故事
166
+ ## 6. 历史背景
163
167
 
164
- Brotli 由 Google 的 Jyrki Alakuijala 和 Zoltán Szabadka 于 2013 年开发。它最初被设计用于压缩网页字体,后来发展为通用压缩算法,用于优化网页传输,并成为行业标准(RFC 7932)。现代 JavaScript bundlers like rolldown leverage Rust's performance to achieve sub-second builds while maintaining compatibility with existing JavaScript tooling ecosystems.
168
+ Brotli 由 Google 的 Jyrki Alakuijala 和 Zoltán Szabadka 于 2013 年开发。最初专为网页字体压缩设计,后发展为通用压缩算法,针对网页传输优化,并成为行业标准(RFC 7932)。现代 JavaScript 打包器如 rolldown 利用 Rust 的性能优势实现亚秒级构建,同时保持与现有 JavaScript 工具生态的兼容性。
165
169
 
166
170
  ## 关于
167
171
 
package/_.js CHANGED
@@ -48,7 +48,7 @@ export default async (dir) => {
48
48
  external: (id) => !id.startsWith(".") && !isAbsolute(id),
49
49
  },
50
50
  true,
51
- undefined,
51
+ real_dir,
52
52
  out_map,
53
53
  ),
54
54
  total_size = await br(chunks.map(([, code]) => code).join(""));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1-/minify_size",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Minify JS and output brotli compressed size | 压缩 JS 并输出 brotli 压缩后大小",
5
5
  "keywords": [
6
6
  "br",