@pathscale/rsbuild-plugin-ui-css-purge 0.9.2 → 0.9.4
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/README.md +80 -70
- package/dist/generate-manifest.d.ts +4 -4
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1435 -73
- package/dist/postbuild-purge.d.ts +51 -39
- package/dist/postbuild-purge.js +444 -320
- package/dist/scan-consumer.d.ts +38 -11
- package/package.json +31 -32
- package/src/generate-manifest.ts +428 -183
|
@@ -2,45 +2,57 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Postbuild CSS purge — standalone Bun script.
|
|
4
4
|
*
|
|
5
|
-
* Runs after rsbuild build, purges CSS files in dist/ using
|
|
6
|
-
* and consumer JSX analysis.
|
|
5
|
+
* Runs after rsbuild build, purges CSS files in dist/ using a database-first
|
|
6
|
+
* component manifest and consumer JSX usage analysis.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* Usage:
|
|
15
|
-
* bunx @pathscale/rsbuild-plugin-ui-css-purge \
|
|
16
|
-
* --dist dist --src src --manifest node_modules/@pathscale/ui/dist/purge-manifest.json
|
|
8
|
+
* Conservative rules:
|
|
9
|
+
* - selectors owned only by unused known components can be removed
|
|
10
|
+
* - selectors owned by used components but unused known prop variants can be removed
|
|
11
|
+
* - selectors with unknown ownership are kept
|
|
12
|
+
* - data/aria runtime state is kept when the owning component selector is kept
|
|
13
|
+
* - vars/keyframes are removed only after selector purge proves them unreferenced
|
|
17
14
|
*/
|
|
18
|
-
import type { PurgeManifest } from "./scan-consumer";
|
|
19
|
-
interface
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
import type { LegacyComponentManifest, PurgeManifest, Safelists } from "./scan-consumer";
|
|
16
|
+
interface NormalizedComponentRecord extends LegacyComponentManifest {
|
|
17
|
+
key: string;
|
|
18
|
+
component: string;
|
|
19
|
+
part?: string;
|
|
20
|
+
selectors: string[];
|
|
21
|
+
attributeSelectors: string[];
|
|
22
|
+
cssVars: {
|
|
23
|
+
declared: string[];
|
|
24
|
+
referenced: string[];
|
|
25
|
+
};
|
|
26
|
+
keyframes: {
|
|
27
|
+
declared: string[];
|
|
28
|
+
referenced: string[];
|
|
29
|
+
};
|
|
28
30
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
31
|
+
interface NormalizedPurgeDatabase {
|
|
32
|
+
version: 2;
|
|
33
|
+
components: Record<string, NormalizedComponentRecord>;
|
|
34
|
+
}
|
|
35
|
+
declare function normalizePurgeDatabase(manifest: PurgeManifest): NormalizedPurgeDatabase;
|
|
36
|
+
interface SelectorPurgeReport {
|
|
37
|
+
selectorsKeptKnown: number;
|
|
38
|
+
selectorsKeptUnknown: number;
|
|
39
|
+
selectorsRemoved: number;
|
|
40
|
+
selectorsRemovedUnusedComponent: number;
|
|
41
|
+
selectorsRemovedUnusedVariant: number;
|
|
42
|
+
attrSelectorsSeen: number;
|
|
43
|
+
keyframesRemoved: number;
|
|
44
|
+
fontFacesRemoved: number;
|
|
45
|
+
}
|
|
46
|
+
interface PurgeResult {
|
|
47
|
+
css: string;
|
|
48
|
+
report: SelectorPurgeReport;
|
|
49
|
+
}
|
|
50
|
+
declare function purgeCssWithDatabase(css: string, manifest: PurgeManifest | NormalizedPurgeDatabase, safelists: Safelists): PurgeResult;
|
|
51
|
+
interface VarCleanupResult {
|
|
52
|
+
css: string;
|
|
53
|
+
removed: number;
|
|
54
|
+
}
|
|
55
|
+
declare function cleanUnusedVarsWithReport(css: string, externallyReferencedVars: Set<string>): VarCleanupResult;
|
|
56
|
+
declare function cleanUnusedVars(css: string, externallyReferencedVars: Set<string>): string;
|
|
57
|
+
export { cleanUnusedVars, cleanUnusedVarsWithReport, normalizePurgeDatabase, purgeCssWithDatabase, };
|
|
58
|
+
export type { NormalizedPurgeDatabase, PurgeResult, SelectorPurgeReport, VarCleanupResult, };
|