@navigate-ai/vite 0.1.26 → 0.1.28

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.
@@ -15,23 +15,38 @@ function generatePolicyFromFiles(files) {
15
15
  }
16
16
  // Resolve imports and link routes to component files
17
17
  linkCrossReferences(graph);
18
+ // Debug: Check files before pruning
19
+ console.log(`[Clippy Debug] Files before pruning: ${[...graph.getAllFiles()].length}`);
20
+ for (const file of graph.getAllFiles()) {
21
+ console.log(`[Clippy Debug] Before prune - ${file.filePath}: components=${file.components.length}, routes=${file.routes.length}`);
22
+ }
18
23
  // Free memory: drop components/jsxTree from files that are not
19
24
  // route-defining files or route component targets — we only need
20
25
  // those for element extraction in PolicyGenerator.
26
+ // Walk to MAX_GRAPH_DEPTH (3) to match PolicyGenerator expansion depth.
27
+ const MAX_GRAPH_DEPTH = 3;
21
28
  const routeFiles = new Set();
29
+ function addFilesAtDepth(sourceFile, depth) {
30
+ if (depth > MAX_GRAPH_DEPTH)
31
+ return;
32
+ if (!sourceFile || routeFiles.has(sourceFile.filePath))
33
+ return;
34
+ routeFiles.add(sourceFile.filePath);
35
+ // Recurse into imports
36
+ for (const candidates of (sourceFile.imports?.values() ?? [])) {
37
+ for (const candidate of candidates) {
38
+ if (candidate.components.length > 0) {
39
+ addFilesAtDepth(candidate, depth + 1);
40
+ }
41
+ }
42
+ }
43
+ }
22
44
  for (const sf of graph.getAllFiles()) {
23
45
  if (sf.routes.length > 0)
24
46
  routeFiles.add(sf.filePath);
25
47
  for (const route of sf.routes) {
26
48
  if (route.resolvedComponent) {
27
- routeFiles.add(route.resolvedComponent.filePath);
28
- // Also keep files imported by the component (one-level expansion targets)
29
- for (const candidates of (route.resolvedComponent.imports?.values() ?? [])) {
30
- for (const candidate of candidates) {
31
- if (candidate.components.length > 0)
32
- routeFiles.add(candidate.filePath);
33
- }
34
- }
49
+ addFilesAtDepth(route.resolvedComponent, 1);
35
50
  }
36
51
  }
37
52
  }
@@ -40,6 +55,11 @@ function generatePolicyFromFiles(files) {
40
55
  sf.components = [];
41
56
  }
42
57
  }
58
+ // Debug: Check files after pruning
59
+ console.log(`[Clippy Debug] Files after pruning (routeFiles: ${routeFiles.size}):`);
60
+ for (const file of graph.getAllFiles()) {
61
+ console.log(`[Clippy Debug] After prune - ${file.filePath}: components=${file.components.length}`);
62
+ }
43
63
  return new PolicyGenerator(graph).generate();
44
64
  }
45
65
  export function clippyVitePlugin(options) {
@@ -74,6 +94,8 @@ export function clippyVitePlugin(options) {
74
94
  const result = processFile(source, cleanId);
75
95
  // Accumulate metadata for policy generation
76
96
  if (result.sourceFile) {
97
+ // Memory optimization: clear source string, keep metadata
98
+ result.sourceFile.source = '';
77
99
  accumulatedFiles.set(cleanId, result.sourceFile);
78
100
  }
79
101
  // Return modified source if IDs were injected
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navigate-ai/vite",
3
- "version": "0.1.26",
3
+ "version": "0.1.28",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -18,7 +18,7 @@
18
18
  }
19
19
  },
20
20
  "dependencies": {
21
- "@navigate_ai/plugin-shared": "^0.1.25"
21
+ "@navigate_ai/plugin-shared": "^0.1.27"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "@babel/parser": "^7.0.0",