@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.
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * Consumer-side JSX scanner.
3
3
  *
4
- * Walks a consumer's source tree, finds component imports from @pathscale/ui,
5
- * collects prop values, and cross-references with the purge manifest to build
6
- * Level 1 (class) and Level 2 (attribute) safelists.
4
+ * Walks a consumer source tree, resolves @pathscale/ui imports with SWC, and
5
+ * records canonical component/part usage plus prop facts for database-first CSS
6
+ * purge decisions.
7
7
  *
8
8
  * Usage: bun run src/scan-consumer.ts <consumer-src-dir> <purge-manifest.json>
9
9
  */
10
- interface ComponentManifest {
10
+ interface LegacyComponentManifest {
11
11
  classes: {
12
12
  always: string[];
13
13
  byProp: Record<string, string[] | Record<string, string[]>>;
@@ -15,23 +15,50 @@ interface ComponentManifest {
15
15
  attrs?: Record<string, Record<string, string>>;
16
16
  deps?: string[];
17
17
  }
18
- type PurgeManifest = Record<string, ComponentManifest>;
18
+ interface ComponentPurgeRecord extends LegacyComponentManifest {
19
+ key?: string;
20
+ component?: string;
21
+ part?: string;
22
+ selectors?: string[];
23
+ attributeSelectors?: string[];
24
+ cssVars?: {
25
+ declared?: string[];
26
+ referenced?: string[];
27
+ };
28
+ keyframes?: {
29
+ declared?: string[];
30
+ referenced?: string[];
31
+ };
32
+ }
33
+ interface PurgeDatabaseV2 {
34
+ version: 2;
35
+ components: Record<string, ComponentPurgeRecord>;
36
+ shared?: {
37
+ selectors?: unknown[];
38
+ cssVars?: Record<string, unknown>;
39
+ keyframes?: Record<string, unknown>;
40
+ };
41
+ }
42
+ type PurgeManifest = Record<string, LegacyComponentManifest> | PurgeDatabaseV2;
19
43
  /** What we collect per component usage from JSX */
20
44
  interface PropUsage {
21
45
  component: string;
22
46
  props: Map<string, string | "DYNAMIC">;
23
47
  booleanProps: Set<string>;
24
48
  hasSpread: boolean;
49
+ source?: string;
25
50
  }
26
- /** Extract @pathscale/ui imports from a parsed module */
27
- declare function extractUIImports(ast: any): Map<string, string>;
28
- /** Extract JSX usages of UI components */
29
- declare function extractJSXUsages(ast: any, uiComponents: Map<string, string>): PropUsage[];
30
51
  interface Safelists {
31
52
  classSafelist: Set<string>;
32
53
  attrSafelist: Set<string>;
54
+ usedComponents: Set<string>;
55
+ dynamicComponents: Set<string>;
33
56
  }
57
+ /** Back-compatible import extraction API: local binding -> canonical component. */
58
+ declare function extractUIImports(ast: unknown): Map<string, string>;
59
+ /** Extract JSX usages of UI components. */
60
+ declare function extractJSXUsages(ast: unknown, uiComponents: Map<string, string>): PropUsage[];
34
61
  declare function buildSafelists(allUsages: PropUsage[], manifest: PurgeManifest): Safelists;
35
62
  declare function scanConsumerSource(srcDir: string): Promise<PropUsage[]>;
36
- export { extractUIImports, extractJSXUsages, buildSafelists, scanConsumerSource };
37
- export type { PropUsage, PurgeManifest, ComponentManifest, Safelists };
63
+ export { extractUIImports, extractJSXUsages, buildSafelists, scanConsumerSource, };
64
+ export type { LegacyComponentManifest, PropUsage, PurgeManifest, PurgeDatabaseV2, ComponentPurgeRecord, LegacyComponentManifest as ComponentManifest, Safelists, };
package/package.json CHANGED
@@ -1,34 +1,33 @@
1
1
  {
2
- "name": "@pathscale/rsbuild-plugin-ui-css-purge",
3
- "version": "0.9.2",
4
- "type": "module",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "exports": {
8
- ".": {
9
- "types": "./dist/index.d.ts",
10
- "import": "./dist/index.js"
11
- }
12
- },
13
- "bin": {
14
- "rsbuild-plugin-ui-css-purge": "dist/postbuild-purge.js",
15
- "generate-manifest": "src/generate-manifest.ts"
16
- },
17
- "files": [
18
- "dist",
19
- "src/generate-manifest.ts"
20
- ],
21
- "dependencies": {
22
- "@swc/core": "^1.15.24",
23
- "lightningcss": "^1.32.0",
24
- "postcss": "^8.5.9"
25
- },
26
- "scripts": {
27
- "build": "bun run build.ts",
28
- "lint": "biome check .",
29
- "format": "biome format . --write"
30
- },
31
- "devDependencies": {
32
- "bun-types": "^1.3.12"
33
- }
2
+ "name": "@pathscale/rsbuild-plugin-ui-css-purge",
3
+ "version": "0.9.4",
4
+ "type": "module",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js"
11
+ }
12
+ },
13
+ "bin": {
14
+ "rsbuild-plugin-ui-css-purge": "dist/postbuild-purge.js",
15
+ "generate-manifest": "src/generate-manifest.ts"
16
+ },
17
+ "files": ["dist", "src/generate-manifest.ts"],
18
+ "dependencies": {
19
+ "@swc/core": "^1.15.24",
20
+ "lightningcss": "^1.32.0",
21
+ "postcss": "^8.5.9"
22
+ },
23
+ "scripts": {
24
+ "build": "bun run build.ts",
25
+ "test": "bun test",
26
+ "lint": "biome check .",
27
+ "format": "biome format . --write"
28
+ },
29
+ "devDependencies": {
30
+ "@biomejs/biome": "1.9.4",
31
+ "bun-types": "^1.3.12"
32
+ }
34
33
  }