@tbela99/css-parser 1.6.4 → 1.6.5

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,48 @@
1
1
  # Changelog
2
2
 
3
+ # v1.6.5
4
+
5
+ ## New
6
+
7
+ - [x] Added fine-grained minification parameters:
8
+ - [x] RenderOptions#minifyValues: minify CSS values such as numbers and dimension tokens
9
+ - [x] ParseOptions#minifyAST: minify the AST.
10
+
11
+ ## Improvement
12
+
13
+ ```css
14
+ .footer{
15
+ grid-row:4;
16
+ grid-column:1;
17
+ grid-column-end:2;
18
+ }
19
+ ```
20
+
21
+ is now computed as
22
+
23
+ ```css
24
+ .footer {
25
+ grid-area: 4/1/auto/2
26
+ }
27
+ ```
28
+
29
+ ## Fixes
30
+
31
+ - [x] fix a98-rgb, hwb color color space handling in color-mix()
32
+ - [x] fix percentage handling in relative rgb color
33
+
34
+ ```css
35
+ .c {
36
+ color: rgb(from rgb(20% 40% 60% / 80%) r g b / calc(alpha / 2));
37
+ ```
38
+ is now computed as
39
+
40
+ ```css
41
+ .c {
42
+ color: #3696
43
+ }
44
+ ```
45
+
3
46
  # v1.6.4
4
47
 
5
48
  ## New
package/README.md CHANGED
@@ -68,6 +68,49 @@ A sample result:
68
68
  On the [complete benchmark suite](https://tbela99.github.io/css-parser/benchmark/index.html), css-parser generated a total output size of 2,158,698 bytes, compared to 2,494,113 bytes for Lightning CSS and larger outputs for all other tested minifiers.
69
69
  While some tools prioritize raw execution speed, css-parser focuses on maximizing compression while preserving stylesheet semantics, resulting in consistently smaller production bundles.
70
70
 
71
+ ## Minification performance vs execution speed
72
+
73
+ `css-parser` is designed for maximum minification performance, but the optimal configuration depends on what matters most for your workload.
74
+
75
+ The parser provides settings that let you choose the balance between minification performance and execution speed:
76
+
77
+ - Minification performance: prioritize the quality and efficiency of the minification process, allowing the parser to perform additional work when generating the minimized output.
78
+
79
+ - Execution speed: minimize the amount of work performed during parsing and minification to achieve the fastest possible execution time.
80
+
81
+ However, the available settings allow you to shift the balance toward execution speed when minimizing runtime is more important than performing every available minification optimization.
82
+
83
+ The example below demonstrates a balanced configuration that improves execution speed by disabling advanced minification features.
84
+
85
+ ```ts
86
+
87
+ import {transformSync} from "@tbela99/css-parser";
88
+
89
+ const css = `...`;
90
+
91
+ const result = transformSync({
92
+ input: css,
93
+ minify: false,
94
+ beautify: false,
95
+ removeEmpty: true,
96
+ removeComments: true,
97
+ convertColor: true,
98
+ minifyValues: true,
99
+ });
100
+
101
+ console.debug(result.code);
102
+ console.debug(result.stats);
103
+ ```
104
+
105
+ Performance vs execution speed comparison
106
+
107
+
108
+ | File: tailwind.css | Speed optimization | Minification optimization |
109
+ | --------------------- | ------------------ | ------------------------- |
110
+ | Size: 2,380,419 bytes | 1,890,728 bytes | 1,633,188 bytes |
111
+ | Time | 205.91 ms | 471.89 ms |
112
+ | Size reduction | -20.6% | -31.4% |
113
+
71
114
  ## Playground
72
115
 
73
116
  Try it [online](https://tbela99.github.io/css-parser/playground/)
@@ -196,3 +239,64 @@ Try it [online](https://tbela99.github.io/css-parser/playground/)
196
239
  ## Performance
197
240
 
198
241
  - [x] Bundle file referenced by the @import statement.
242
+
243
+ # Architecture
244
+
245
+ ```mermaid
246
+ flowchart TD
247
+ %% --- Transform ---
248
+ Input(["CSS input"])
249
+
250
+
251
+ %% The Grouped Container
252
+ subgraph Group10["Transform step"]
253
+
254
+ transform["transform()/transformSync()"]
255
+
256
+
257
+ %% The Grouped Container
258
+ subgraph Group1 ["Parse step"]
259
+
260
+ %% --- Parse step ---
261
+ parse["parse()/parseSync()"]
262
+ tokenize(["tokenize()"])
263
+ parseNode(["parse and validate token stream"])
264
+ visitors(["visitors"])
265
+ minify(["minify AST"])
266
+ cssModules(["generate CSS module"])
267
+ parseResult["Parse result"]
268
+ end
269
+
270
+ %% The Grouped Container
271
+ subgraph Group2 ["Render step"]
272
+
273
+ %% --- Render step ---
274
+ renderAst(["Render AST"])
275
+ sourcemap([Sourcemap generation])
276
+
277
+ end
278
+
279
+ %% --- Result step ---
280
+ transformResult["Transform result"]
281
+ end
282
+
283
+ %% --- Routing step ---
284
+ Input --> transform
285
+ transform --> parse
286
+ parse --> tokenize
287
+ tokenize --> parseNode
288
+ parseNode -- "Visitors set?" --> visitors
289
+ visitors -- "Minify AST?" --> minify
290
+ minify -- "CSS module?" --> cssModules
291
+ visitors -- "CSS module?" --> cssModules
292
+ cssModules --> parseResult
293
+ parseNode -- "CSS module?" --> cssModules
294
+ parseNode -- "Minify AST?" --> minify
295
+ parseNode --> parseResult
296
+ visitors --> parseResult
297
+ minify --> parseResult
298
+ parseResult --> renderAst
299
+ renderAst -- "Sourcemap?" --> sourcemap
300
+ renderAst --> transformResult
301
+ sourcemap --> transformResult
302
+ ```