optiprune 1.8.16 → 2.0.0
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/dist/ast-utils.d.ts +149 -0
- package/dist/ast-utils.js +36 -0
- package/dist/ast-utils.js.map +1 -0
- package/dist/engine.js +11 -13
- package/dist/engine.js.map +1 -1
- package/dist/framework-plugins.js +33 -14
- package/dist/framework-plugins.js.map +1 -1
- package/dist/index.js +54 -57
- package/dist/index.js.map +1 -1
- package/dist/instrument.d.ts +4 -0
- package/dist/instrument.js +105 -17
- package/dist/instrument.js.map +1 -1
- package/dist/layer2.js +13 -16
- package/dist/layer2.js.map +1 -1
- package/dist/layer6.d.ts +2 -1
- package/dist/layer6.js +28 -16
- package/dist/layer6.js.map +1 -1
- package/dist/layer7.js +59 -42
- package/dist/layer7.js.map +1 -1
- package/dist/parser.d.ts +1 -1
- package/dist/parser.js +84 -35
- package/dist/parser.js.map +1 -1
- package/dist/plugins/angular-plugin.js +1 -1
- package/dist/plugins/angular-plugin.js.map +1 -1
- package/dist/plugins/astro-plugin.js +1 -1
- package/dist/plugins/astro-plugin.js.map +1 -1
- package/dist/plugins/babel-plugin.js +1 -1
- package/dist/plugins/babel-plugin.js.map +1 -1
- package/dist/plugins/esbuild-plugin.js +1 -1
- package/dist/plugins/esbuild-plugin.js.map +1 -1
- package/dist/plugins/nestjs-plugin.js +1 -1
- package/dist/plugins/nestjs-plugin.js.map +1 -1
- package/dist/plugins/nextjs-plugin.js +1 -1
- package/dist/plugins/nextjs-plugin.js.map +1 -1
- package/dist/plugins/nuxtjs-plugin.js +1 -1
- package/dist/plugins/nuxtjs-plugin.js.map +1 -1
- package/dist/plugins/svelte-plugin.js +1 -1
- package/dist/plugins/svelte-plugin.js.map +1 -1
- package/dist/plugins/vuejs-plugin.js +1 -1
- package/dist/plugins/vuejs-plugin.js.map +1 -1
- package/package.json +4 -11
- package/dist/instrumentation-plugin.d.ts +0 -6
- package/dist/instrumentation-plugin.js +0 -84
- package/dist/instrumentation-plugin.js.map +0 -1
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared AST Utilities for Yuku-compatible ESTree ASTs.
|
|
3
|
+
* Replaces @babel/types for common type-guarding tasks.
|
|
4
|
+
*/
|
|
5
|
+
export declare const t: {
|
|
6
|
+
isStringLiteral: (n: unknown) => n is {
|
|
7
|
+
type: "Literal";
|
|
8
|
+
value: string;
|
|
9
|
+
};
|
|
10
|
+
isNumericLiteral: (n: unknown) => n is {
|
|
11
|
+
type: "Literal";
|
|
12
|
+
value: number;
|
|
13
|
+
};
|
|
14
|
+
isBooleanLiteral: (n: unknown) => n is {
|
|
15
|
+
type: "Literal";
|
|
16
|
+
value: boolean;
|
|
17
|
+
};
|
|
18
|
+
isIdentifier: (n: unknown) => n is {
|
|
19
|
+
type: "Identifier";
|
|
20
|
+
name: string;
|
|
21
|
+
};
|
|
22
|
+
isCallExpression: (n: unknown) => n is {
|
|
23
|
+
type: "CallExpression";
|
|
24
|
+
callee: any;
|
|
25
|
+
arguments: any[];
|
|
26
|
+
};
|
|
27
|
+
isMemberExpression: (n: unknown) => n is {
|
|
28
|
+
type: "MemberExpression";
|
|
29
|
+
object: any;
|
|
30
|
+
property: any;
|
|
31
|
+
computed: boolean;
|
|
32
|
+
};
|
|
33
|
+
isVariableDeclarator: (n: unknown) => n is {
|
|
34
|
+
type: "VariableDeclarator";
|
|
35
|
+
id: any;
|
|
36
|
+
init: any;
|
|
37
|
+
};
|
|
38
|
+
isFunctionDeclaration: (n: unknown) => n is {
|
|
39
|
+
type: "FunctionDeclaration";
|
|
40
|
+
id: {
|
|
41
|
+
name: string;
|
|
42
|
+
} | null;
|
|
43
|
+
};
|
|
44
|
+
isExportNamedDeclaration: (n: unknown) => n is {
|
|
45
|
+
type: "ExportNamedDeclaration";
|
|
46
|
+
declaration: any;
|
|
47
|
+
specifiers: any[];
|
|
48
|
+
};
|
|
49
|
+
isImportDeclaration: (n: unknown) => n is {
|
|
50
|
+
type: "ImportDeclaration";
|
|
51
|
+
source: {
|
|
52
|
+
value: string;
|
|
53
|
+
};
|
|
54
|
+
specifiers: any[];
|
|
55
|
+
};
|
|
56
|
+
isObjectProperty: (n: unknown) => n is {
|
|
57
|
+
type: "Property";
|
|
58
|
+
key: any;
|
|
59
|
+
value: any;
|
|
60
|
+
computed: boolean;
|
|
61
|
+
};
|
|
62
|
+
isObjectMethod: (n: unknown) => n is {
|
|
63
|
+
type: "ObjectMethod";
|
|
64
|
+
key: any;
|
|
65
|
+
};
|
|
66
|
+
isTSInterfaceDeclaration: (n: unknown) => n is {
|
|
67
|
+
type: "TSInterfaceDeclaration";
|
|
68
|
+
id: {
|
|
69
|
+
name: string;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
isTSTypeAliasDeclaration: (n: unknown) => n is {
|
|
73
|
+
type: "TSTypeAliasDeclaration";
|
|
74
|
+
id: {
|
|
75
|
+
name: string;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
isTSEnumDeclaration: (n: unknown) => n is {
|
|
79
|
+
type: "TSEnumDeclaration";
|
|
80
|
+
id: {
|
|
81
|
+
name: string;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
isClassDeclaration: (n: unknown) => n is {
|
|
85
|
+
type: "ClassDeclaration";
|
|
86
|
+
id: {
|
|
87
|
+
name: string;
|
|
88
|
+
} | null;
|
|
89
|
+
};
|
|
90
|
+
isClassExpression: (n: unknown) => n is {
|
|
91
|
+
type: "ClassExpression";
|
|
92
|
+
id: {
|
|
93
|
+
name: string;
|
|
94
|
+
} | null;
|
|
95
|
+
};
|
|
96
|
+
isClassMethod: (n: unknown) => n is {
|
|
97
|
+
type: "ClassMethod";
|
|
98
|
+
key: any;
|
|
99
|
+
};
|
|
100
|
+
isClassProperty: (n: unknown) => n is {
|
|
101
|
+
type: "ClassProperty";
|
|
102
|
+
key: any;
|
|
103
|
+
};
|
|
104
|
+
isExportDefaultDeclaration: (n: unknown) => n is {
|
|
105
|
+
type: "ExportDefaultDeclaration";
|
|
106
|
+
declaration: any;
|
|
107
|
+
};
|
|
108
|
+
isFunctionExpression: (n: unknown) => n is {
|
|
109
|
+
type: "FunctionExpression";
|
|
110
|
+
id: {
|
|
111
|
+
name: string;
|
|
112
|
+
} | null;
|
|
113
|
+
};
|
|
114
|
+
isJSXElement: (n: unknown) => n is {
|
|
115
|
+
type: "JSXElement";
|
|
116
|
+
openingElement: any;
|
|
117
|
+
};
|
|
118
|
+
isJSXIdentifier: (n: unknown) => n is {
|
|
119
|
+
type: "JSXIdentifier";
|
|
120
|
+
name: string;
|
|
121
|
+
};
|
|
122
|
+
isObjectExpression: (n: unknown) => n is {
|
|
123
|
+
type: "ObjectExpression";
|
|
124
|
+
properties: any[];
|
|
125
|
+
};
|
|
126
|
+
isLiteral: (n: unknown) => n is {
|
|
127
|
+
type: "Literal";
|
|
128
|
+
value: any;
|
|
129
|
+
};
|
|
130
|
+
isJSXAttribute: (n: unknown) => n is {
|
|
131
|
+
type: "JSXAttribute";
|
|
132
|
+
name: any;
|
|
133
|
+
value: any;
|
|
134
|
+
};
|
|
135
|
+
isNewExpression: (n: unknown) => n is {
|
|
136
|
+
type: "NewExpression";
|
|
137
|
+
callee: any;
|
|
138
|
+
arguments: any[];
|
|
139
|
+
};
|
|
140
|
+
isTemplateLiteral: (n: unknown) => n is {
|
|
141
|
+
type: "TemplateLiteral";
|
|
142
|
+
quasis: any[];
|
|
143
|
+
expressions: any[];
|
|
144
|
+
};
|
|
145
|
+
isDecorator: (n: unknown) => n is {
|
|
146
|
+
type: "Decorator";
|
|
147
|
+
expression: any;
|
|
148
|
+
};
|
|
149
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared AST Utilities for Yuku-compatible ESTree ASTs.
|
|
3
|
+
* Replaces @babel/types for common type-guarding tasks.
|
|
4
|
+
*/
|
|
5
|
+
export const t = {
|
|
6
|
+
isStringLiteral: (n) => !!n && typeof n === 'object' && n.type === 'Literal' && typeof n.value === 'string',
|
|
7
|
+
isNumericLiteral: (n) => !!n && typeof n === 'object' && n.type === 'Literal' && typeof n.value === 'number',
|
|
8
|
+
isBooleanLiteral: (n) => !!n && typeof n === 'object' && n.type === 'Literal' && typeof n.value === 'boolean',
|
|
9
|
+
isIdentifier: (n) => !!n && typeof n === 'object' && n.type === 'Identifier',
|
|
10
|
+
isCallExpression: (n) => !!n && typeof n === 'object' && n.type === 'CallExpression',
|
|
11
|
+
isMemberExpression: (n) => !!n && typeof n === 'object' && n.type === 'MemberExpression',
|
|
12
|
+
isVariableDeclarator: (n) => !!n && typeof n === 'object' && n.type === 'VariableDeclarator',
|
|
13
|
+
isFunctionDeclaration: (n) => !!n && typeof n === 'object' && n.type === 'FunctionDeclaration',
|
|
14
|
+
isExportNamedDeclaration: (n) => !!n && typeof n === 'object' && n.type === 'ExportNamedDeclaration',
|
|
15
|
+
isImportDeclaration: (n) => !!n && typeof n === 'object' && n.type === 'ImportDeclaration',
|
|
16
|
+
isObjectProperty: (n) => !!n && typeof n === 'object' && (n.type === 'Property' || n.type === 'ObjectProperty'),
|
|
17
|
+
isObjectMethod: (n) => !!n && typeof n === 'object' && n.type === 'ObjectMethod',
|
|
18
|
+
isTSInterfaceDeclaration: (n) => !!n && typeof n === 'object' && n.type === 'TSInterfaceDeclaration',
|
|
19
|
+
isTSTypeAliasDeclaration: (n) => !!n && typeof n === 'object' && n.type === 'TSTypeAliasDeclaration',
|
|
20
|
+
isTSEnumDeclaration: (n) => !!n && typeof n === 'object' && n.type === 'TSEnumDeclaration',
|
|
21
|
+
isClassDeclaration: (n) => !!n && typeof n === 'object' && n.type === 'ClassDeclaration',
|
|
22
|
+
isClassExpression: (n) => !!n && typeof n === 'object' && n.type === 'ClassExpression',
|
|
23
|
+
isClassMethod: (n) => !!n && typeof n === 'object' && n.type === 'ClassMethod',
|
|
24
|
+
isClassProperty: (n) => !!n && typeof n === 'object' && (n.type === 'ClassProperty' || n.type === 'PropertyDefinition'),
|
|
25
|
+
isExportDefaultDeclaration: (n) => !!n && typeof n === 'object' && n.type === 'ExportDefaultDeclaration',
|
|
26
|
+
isFunctionExpression: (n) => !!n && typeof n === 'object' && n.type === 'FunctionExpression',
|
|
27
|
+
isJSXElement: (n) => !!n && typeof n === 'object' && n.type === 'JSXElement',
|
|
28
|
+
isJSXIdentifier: (n) => !!n && typeof n === 'object' && n.type === 'JSXIdentifier',
|
|
29
|
+
isObjectExpression: (n) => !!n && typeof n === 'object' && n.type === 'ObjectExpression',
|
|
30
|
+
isLiteral: (n) => !!n && typeof n === 'object' && n.type === 'Literal',
|
|
31
|
+
isJSXAttribute: (n) => !!n && typeof n === 'object' && n.type === 'JSXAttribute',
|
|
32
|
+
isNewExpression: (n) => !!n && typeof n === 'object' && n.type === 'NewExpression',
|
|
33
|
+
isTemplateLiteral: (n) => !!n && typeof n === 'object' && n.type === 'TemplateLiteral',
|
|
34
|
+
isDecorator: (n) => !!n && typeof n === 'object' && n.type === 'Decorator',
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=ast-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast-utils.js","sourceRoot":"","sources":["../src/ast-utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,MAAM,CAAC,GAAG;IACf,eAAe,EAAE,CAAC,CAAU,EAA2C,EAAE,CACvE,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAK,CAAS,CAAC,IAAI,KAAK,SAAS,IAAI,OAAQ,CAAS,CAAC,KAAK,KAAK,QAAQ;IAEvG,gBAAgB,EAAE,CAAC,CAAU,EAA2C,EAAE,CACxE,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAK,CAAS,CAAC,IAAI,KAAK,SAAS,IAAI,OAAQ,CAAS,CAAC,KAAK,KAAK,QAAQ;IAEvG,gBAAgB,EAAE,C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AAK,CAAS,CAAC,IAAI,KAAK,iBAAiB;IAEvE,WAAW,EAAE,CAAC,CAAU,EAA+C,EAAE,CACvE,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAK,CAAS,CAAC,IAAI,KAAK,WAAW;CAClE,CAAC"}
|
package/dist/engine.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { walkAst as yukuWalk } from "./parser.js";
|
|
2
|
+
import { t } from "./ast-utils.js";
|
|
3
3
|
import fs from "node:fs/promises";
|
|
4
4
|
import path from "pathe";
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
@@ -93,18 +93,16 @@ export class PluginEngine {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
// onASTNode (Traversal)
|
|
96
|
-
|
|
96
|
+
// Use yuku-parser's walk instead of @babel/traverse
|
|
97
97
|
try {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
// Suppress per-node errors to avoid flooding logs, but ensure isolation
|
|
107
|
-
}
|
|
98
|
+
yukuWalk(module.ast, (node) => {
|
|
99
|
+
for (const plugin of this.plugins) {
|
|
100
|
+
if (plugin.enabled && plugin.lifecycle.onASTNode) {
|
|
101
|
+
try {
|
|
102
|
+
plugin.lifecycle.onASTNode(node, module.id, adapter);
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
// Suppress per-node errors to avoid flooding logs, but ensure isolation
|
|
108
106
|
}
|
|
109
107
|
}
|
|
110
108
|
}
|
package/dist/engine.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.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H,CAAC;YAED,gDAAgD;YAChD,IAAI,CAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAChD,IAAI,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;oBACrC,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;gBAClD,CAAC;YACH,CAAC;QACH,CAAC;KACF;CACF,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as t from "@babel/types";
|
|
2
1
|
/**
|
|
3
2
|
* Utility to check for dependencies in package.json
|
|
4
3
|
*/
|
|
@@ -20,12 +19,35 @@ export const ReactPlugin = {
|
|
|
20
19
|
},
|
|
21
20
|
lifecycle: {
|
|
22
21
|
onASTNode: (node, fileId, adapter) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
let targetNode = node;
|
|
23
|
+
// Unwrap export declarations
|
|
24
|
+
if ((node.type === 'ExportNamedDeclaration' || node.type === 'ExportDefaultDeclaration') &&
|
|
25
|
+
node.declaration) {
|
|
26
|
+
targetNode = node.declaration;
|
|
26
27
|
}
|
|
27
|
-
//
|
|
28
|
-
if (
|
|
28
|
+
// 1. Function Declarations: function MyComponent() {}
|
|
29
|
+
if (targetNode.type === 'FunctionDeclaration' && targetNode.id && /^[A-Z]/.test(targetNode.id.name)) {
|
|
30
|
+
adapter.markAsUsed(fileId, targetNode.id.name);
|
|
31
|
+
}
|
|
32
|
+
// 2. Variable Declarations: const MyComponent = () => ... or function expression / JSX
|
|
33
|
+
if (targetNode.type === 'VariableDeclaration' && Array.isArray(targetNode.declarations)) {
|
|
34
|
+
for (const decl of targetNode.declarations) {
|
|
35
|
+
if (decl.id?.type === 'Identifier' && /^[A-Z]/.test(decl.id.name)) {
|
|
36
|
+
const init = decl.init;
|
|
37
|
+
if (init &&
|
|
38
|
+
(init.type === 'ArrowFunctionExpression' ||
|
|
39
|
+
init.type === 'FunctionExpression' ||
|
|
40
|
+
init.type === 'JSXElement')) {
|
|
41
|
+
adapter.markAsUsed(fileId, decl.id.name);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// 3. Hooks: useFoo() call expressions
|
|
47
|
+
if (node.type === 'CallExpression' &&
|
|
48
|
+
node.callee?.type === 'Identifier' &&
|
|
49
|
+
typeof node.callee.name === 'string' &&
|
|
50
|
+
node.callee.name.startsWith('use')) {
|
|
29
51
|
adapter.markAsUsed(fileId);
|
|
30
52
|
}
|
|
31
53
|
}
|
|
@@ -43,11 +65,9 @@ export const NextjsPlugin = {
|
|
|
43
65
|
},
|
|
44
66
|
lifecycle: {
|
|
45
67
|
onProjectInit: async (adapter) => {
|
|
46
|
-
// Read next.config.js to look for custom entry points or redirects
|
|
47
68
|
const nextConfig = await adapter.readFile('next.config.js') || await adapter.readFile('next.config.mjs');
|
|
48
69
|
if (nextConfig) {
|
|
49
|
-
//
|
|
50
|
-
// For now, we just log that we found it
|
|
70
|
+
// Logged/handled if present
|
|
51
71
|
}
|
|
52
72
|
},
|
|
53
73
|
onFileStart: (fileId, adapter) => {
|
|
@@ -60,9 +80,9 @@ export const NextjsPlugin = {
|
|
|
60
80
|
}
|
|
61
81
|
},
|
|
62
82
|
onASTNode: (node, fileId, adapter) => {
|
|
63
|
-
if (
|
|
83
|
+
if (node.type === 'ExportNamedDeclaration' && node.declaration) {
|
|
64
84
|
const decl = node.declaration;
|
|
65
|
-
if (
|
|
85
|
+
if (decl.type === 'FunctionDeclaration' && decl.id) {
|
|
66
86
|
const name = decl.id.name;
|
|
67
87
|
if (['getStaticProps', 'getServerSideProps', 'getStaticPaths', 'generateMetadata', 'generateStaticParams'].includes(name)) {
|
|
68
88
|
adapter.markAsUsed(fileId, name);
|
|
@@ -84,10 +104,9 @@ export const NuxtPlugin = {
|
|
|
84
104
|
},
|
|
85
105
|
lifecycle: {
|
|
86
106
|
onProjectInit: async (adapter) => {
|
|
87
|
-
// Read nuxt.config.ts to look for custom modules or dir overrides
|
|
88
107
|
const nuxtConfig = await adapter.readFile('nuxt.config.ts') || await adapter.readFile('nuxt.config.js');
|
|
89
108
|
if (nuxtConfig) {
|
|
90
|
-
//
|
|
109
|
+
// Custom directory configs
|
|
91
110
|
}
|
|
92
111
|
},
|
|
93
112
|
onFileStart: (fileId, adapter) => {
|
|
@@ -97,7 +116,7 @@ export const NuxtPlugin = {
|
|
|
97
116
|
}
|
|
98
117
|
},
|
|
99
118
|
onASTNode: (node, fileId, adapter) => {
|
|
100
|
-
if (
|
|
119
|
+
if (node.type === 'CallExpression' && node.callee?.type === 'Identifier') {
|
|
101
120
|
if (['definePageMeta', 'defineNuxtComponent', 'useNuxtApp', 'useFetch', 'defineEventHandler'].includes(node.callee.name)) {
|
|
102
121
|
adapter.markAsUsed(fileId);
|
|
103
122
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framework-plugins.js","sourceRoot":"","sources":["../src/framework-plugins.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"framework-plugins.js","sourceRoot":"","sources":["../src/framework-plugins.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,KAAK,UAAU,aAAa,CAAC,OAAY,EAAE,IAAY;IACrD,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IACnD,IAAI,CAAC,GAAG;QAAE,OAAO,KAAK,CAAC;IACvB,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,eAAe,EAAE,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,gBAAgB,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;AACrG,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAmB;IACzC,IAAI,EAAE,cAAc;IACpB,OAAO,EAA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,CAAC,CAAC;YACxG,IAAI,UAAU,EAAE,CAAC;gBACf,2BAA2B;YAC7B,CAAC;QACH,CAAC;QACD,WAAW,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;YAC/B,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACpC,IAAI,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;gBAC1K,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;QACD,SAAS,EAAE,CAAC,IAAS,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;YACxC,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAgB,IAAI,IAAI,CAAC,MAAM,EAAE,IAAI,KAAK,YAAY,EAAE,CAAC;gBACzE,IAAI,CAAC,gBAAgB,EAAE,qBAAqB,EAAE,YAAY,EAAE,UAAU,EAAE,oBAAoB,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;oBACzH,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;gBAC7B,CAAC;YACH,CAAC;QACH,CAAC;KACF;CACF,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -103,7 +103,6 @@ export async function analyze(options) {
|
|
|
103
103
|
if (moduleRecord.parseStatus === "parsed") {
|
|
104
104
|
filesParsed += 1;
|
|
105
105
|
// Quick framework detection for Layer 5 gating
|
|
106
|
-
// ✅ FIXED FRAMEWORK DETECTION
|
|
107
106
|
if (!hasFrameworkNodes && moduleRecord.ast) {
|
|
108
107
|
walkAst(moduleRecord.ast, (rawNode) => {
|
|
109
108
|
const node = rawNode;
|
|
@@ -126,6 +125,8 @@ export async function analyze(options) {
|
|
|
126
125
|
}
|
|
127
126
|
saveCache(resolvedOptions.rootDir, newCache);
|
|
128
127
|
let entryPoints = new Set();
|
|
128
|
+
const publicEntryPoints = new Set();
|
|
129
|
+
// 1. Explicit Entry Points
|
|
129
130
|
if (entry.length > 0) {
|
|
130
131
|
for (const pattern of entry) {
|
|
131
132
|
const expanded = expandEntryPatterns(allSourceFiles, rootDir, [pattern]);
|
|
@@ -134,30 +135,40 @@ export async function analyze(options) {
|
|
|
134
135
|
}
|
|
135
136
|
}
|
|
136
137
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
138
|
+
// 2. Conventional Entry Points (Public)
|
|
139
|
+
// Helper to add patterns relative to a base directory
|
|
140
|
+
const addPatterns = async (baseDir, relativeToRoot = "", isRoot = false) => {
|
|
141
|
+
const rawEntries = await discoverPackageEntryPatterns(baseDir);
|
|
142
|
+
const entries = rawEntries.flatMap(e => {
|
|
143
|
+
if (e.startsWith('dist/')) {
|
|
144
|
+
const srcEntry = e.replace('dist/', 'src/').replace(/\.js$/, '.ts').replace(/\.jsx$/, '.tsx');
|
|
145
|
+
return [e, srcEntry];
|
|
143
146
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
// Only add to publicEntryPoints, NOT to reachability entryPoints
|
|
156
|
-
publicEntryPoints.add(path.normalize(expanded));
|
|
157
|
-
}
|
|
147
|
+
return [e];
|
|
148
|
+
});
|
|
149
|
+
for (const pattern of [...entries, ...conventionalEntryPatterns()]) {
|
|
150
|
+
const adjustedPattern = (relativeToRoot && !pattern.startsWith('/'))
|
|
151
|
+
? path.posix.join(relativeToRoot, pattern)
|
|
152
|
+
: pattern;
|
|
153
|
+
const expanded = expandEntryPatterns(allSourceFiles, rootDir, [adjustedPattern]);
|
|
154
|
+
for (const e of expanded) {
|
|
155
|
+
const normalized = path.normalize(e);
|
|
156
|
+
if (isRoot && includeConventionalEntries) {
|
|
157
|
+
entryPoints.add(normalized);
|
|
158
158
|
}
|
|
159
|
+
// Monorepo package entries are ALWAYS publicEntryPoints to protect their API
|
|
160
|
+
publicEntryPoints.add(normalized);
|
|
159
161
|
}
|
|
160
162
|
}
|
|
163
|
+
};
|
|
164
|
+
// Root entries
|
|
165
|
+
await addPatterns(rootDir, "", true);
|
|
166
|
+
// Monorepo sub-package entries
|
|
167
|
+
if (resolvedOptions.monorepo) {
|
|
168
|
+
for (const pkg of resolvedOptions.monorepo.packageMap.values()) {
|
|
169
|
+
const relativeToRoot = path.posix.relative(rootDir, pkg.location);
|
|
170
|
+
await addPatterns(pkg.location, relativeToRoot, false);
|
|
171
|
+
}
|
|
161
172
|
}
|
|
162
173
|
const findings = [];
|
|
163
174
|
if (entryPoints.size === 0) {
|
|
@@ -170,23 +181,6 @@ export async function analyze(options) {
|
|
|
170
181
|
evidence: {},
|
|
171
182
|
});
|
|
172
183
|
}
|
|
173
|
-
if (includeConventionalEntries) {
|
|
174
|
-
const rawPackageEntries = await discoverPackageEntryPatterns(rootDir);
|
|
175
|
-
const rootPackageEntries = rawPackageEntries.flatMap(entry => {
|
|
176
|
-
// If the entry points to dist/, also look for the corresponding src/ file
|
|
177
|
-
if (entry.startsWith('dist/')) {
|
|
178
|
-
const srcEntry = entry.replace('dist/', 'src/').replace(/\.js$/, '.ts').replace(/\.jsx$/, '.tsx');
|
|
179
|
-
return [entry, srcEntry];
|
|
180
|
-
}
|
|
181
|
-
return [entry];
|
|
182
|
-
});
|
|
183
|
-
// Include both package.json entries and conventional entries (index, main, cli, etc.)
|
|
184
|
-
for (const pattern of [...rootPackageEntries, ...conventionalEntryPatterns()]) {
|
|
185
|
-
for (const expanded of expandEntryPatterns(allSourceFiles, rootDir, [pattern])) {
|
|
186
|
-
publicEntryPoints.add(path.normalize(expanded));
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
184
|
const context = contextWithGraph(modules, entryPoints, resolvedOptions);
|
|
191
185
|
context.publicEntryPoints = publicEntryPoints;
|
|
192
186
|
context.semanticGraph = semanticGraph;
|
|
@@ -201,8 +195,6 @@ export async function analyze(options) {
|
|
|
201
195
|
findings.push(...pluginFindings);
|
|
202
196
|
// Headless Living Graph Engine: Initial Ingestion
|
|
203
197
|
for (const module of modules.values()) {
|
|
204
|
-
// In a full implementation, we would extract semantic nodes from the AST here.
|
|
205
|
-
// For now, we create a representative FileNode.
|
|
206
198
|
const fileNode = {
|
|
207
199
|
id: SemanticGraph.generateLei(module.id, 'File'),
|
|
208
200
|
contentHash: SemanticGraph.generateContentHash(module.sourceText),
|
|
@@ -282,7 +274,6 @@ export async function analyze(options) {
|
|
|
282
274
|
}
|
|
283
275
|
}
|
|
284
276
|
// Final Reporting Phase: Unused Exports & Unreachable Files
|
|
285
|
-
// We do this at the end so all layers (Layer 4, 7, etc.) have a chance to refine reachability and usage.
|
|
286
277
|
if (resolvedOptions.reportUnusedExports) {
|
|
287
278
|
const importUsage = buildImportUsage(modules);
|
|
288
279
|
for (const module of modules.values()) {
|
|
@@ -290,8 +281,6 @@ export async function analyze(options) {
|
|
|
290
281
|
for (const exp of module.exports) {
|
|
291
282
|
if (exp.isExternalContract)
|
|
292
283
|
continue;
|
|
293
|
-
if (context.publicEntryPoints?.has(module.id))
|
|
294
|
-
continue;
|
|
295
284
|
const isExportUsed = context.usedExports.has(`${module.id}:${exp.exportedAs}`);
|
|
296
285
|
let confidence = "high";
|
|
297
286
|
if (context.maybeReachable.has(module.id))
|
|
@@ -301,26 +290,40 @@ export async function analyze(options) {
|
|
|
301
290
|
if (context.hasReachableUnknownDynamicBoundary && isExportUsed)
|
|
302
291
|
continue;
|
|
303
292
|
let isEffectivelyUsed = isExportUsed;
|
|
304
|
-
|
|
293
|
+
// PUBLIC ENTRY POINT & BARREL PROTECTION
|
|
294
|
+
const visited = new Set();
|
|
295
|
+
const checkPublicReachability = (moduleId) => {
|
|
296
|
+
if (visited.has(moduleId))
|
|
297
|
+
return false;
|
|
298
|
+
visited.add(moduleId);
|
|
299
|
+
if (publicEntryPoints.has(moduleId))
|
|
300
|
+
return true;
|
|
301
|
+
const usage = importUsage.get(moduleId);
|
|
302
|
+
if (!usage || !usage.reExportOnly)
|
|
303
|
+
return false;
|
|
304
|
+
// If this module is only a re-exporter (Barrel), check if its consumers are public
|
|
305
|
+
return Array.from(usage.consumers).some(c => checkPublicReachability(c));
|
|
306
|
+
};
|
|
307
|
+
if (checkPublicReachability(module.id)) {
|
|
308
|
+
isEffectivelyUsed = true;
|
|
309
|
+
}
|
|
310
|
+
else if (isExportUsed) {
|
|
305
311
|
const usage = importUsage.get(module.id);
|
|
306
312
|
if (usage && usage.reExportOnly) {
|
|
307
|
-
|
|
308
|
-
// for long chains of re-export-only modules (Barrels).
|
|
309
|
-
const visited = new Set();
|
|
313
|
+
const deepVisited = new Set();
|
|
310
314
|
const checkConsumer = (consumerId) => {
|
|
311
|
-
if (
|
|
315
|
+
if (deepVisited.has(consumerId))
|
|
312
316
|
return false;
|
|
313
|
-
|
|
317
|
+
deepVisited.add(consumerId);
|
|
314
318
|
if (context.entryPoints.has(consumerId))
|
|
315
319
|
return true;
|
|
316
|
-
if (
|
|
320
|
+
if (publicEntryPoints.has(consumerId))
|
|
317
321
|
return true;
|
|
318
322
|
const consumerUsage = importUsage.get(consumerId);
|
|
319
323
|
if (!consumerUsage)
|
|
320
324
|
return false;
|
|
321
325
|
if (!consumerUsage.reExportOnly)
|
|
322
326
|
return true;
|
|
323
|
-
// If the consumer is itself re-export only, check ITS consumers
|
|
324
327
|
return Array.from(consumerUsage.consumers).some(c => checkConsumer(c));
|
|
325
328
|
};
|
|
326
329
|
const hasRealConsumer = Array.from(usage.consumers).some(c => checkConsumer(c));
|
|
@@ -329,9 +332,6 @@ export async function analyze(options) {
|
|
|
329
332
|
}
|
|
330
333
|
}
|
|
331
334
|
}
|
|
332
|
-
// Fix 3: We now track local references to types, so we can safely report
|
|
333
|
-
// unused type-only exports if they are truly not referenced anywhere.
|
|
334
|
-
// (Previously skipped to avoid false positives).
|
|
335
335
|
if (!isEffectivelyUsed && exp.exportedAs !== "default") {
|
|
336
336
|
findings.push({
|
|
337
337
|
rule: "unused-export",
|
|
@@ -350,9 +350,6 @@ export async function analyze(options) {
|
|
|
350
350
|
for (const module of modules.values()) {
|
|
351
351
|
if (!context.reachable.has(module.id) && !context.maybeReachable.has(module.id)) {
|
|
352
352
|
const fileComponent = context.components.find((c) => c.modules.includes(module.id));
|
|
353
|
-
// Enhanced SCC Reachability Check:
|
|
354
|
-
// If the file is part of a component that was explicitly marked as unreachable,
|
|
355
|
-
// we provide a more descriptive message.
|
|
356
353
|
const isIsolatedComponent = fileComponent && !fileComponent.isReachable && !fileComponent.isMaybeReachable;
|
|
357
354
|
findings.push({
|
|
358
355
|
rule: "unreachable-file",
|