phantom-build 0.1.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.
Files changed (94) hide show
  1. package/README.md +378 -0
  2. package/dist/analyzer.d.ts +11 -0
  3. package/dist/analyzer.d.ts.map +1 -0
  4. package/dist/analyzer.js +330 -0
  5. package/dist/analyzer.js.map +1 -0
  6. package/dist/ast-compat.d.ts +11 -0
  7. package/dist/ast-compat.d.ts.map +1 -0
  8. package/dist/ast-compat.js +84 -0
  9. package/dist/ast-compat.js.map +1 -0
  10. package/dist/classify/boundary.d.ts +30 -0
  11. package/dist/classify/boundary.d.ts.map +1 -0
  12. package/dist/classify/boundary.js +145 -0
  13. package/dist/classify/boundary.js.map +1 -0
  14. package/dist/classify/browser-globals.d.ts +29 -0
  15. package/dist/classify/browser-globals.d.ts.map +1 -0
  16. package/dist/classify/browser-globals.js +197 -0
  17. package/dist/classify/browser-globals.js.map +1 -0
  18. package/dist/classify/index.d.ts +14 -0
  19. package/dist/classify/index.d.ts.map +1 -0
  20. package/dist/classify/index.js +294 -0
  21. package/dist/classify/index.js.map +1 -0
  22. package/dist/classify/lazy-llm.d.ts +122 -0
  23. package/dist/classify/lazy-llm.d.ts.map +1 -0
  24. package/dist/classify/lazy-llm.js +142 -0
  25. package/dist/classify/lazy-llm.js.map +1 -0
  26. package/dist/classify/lazy.d.ts +23 -0
  27. package/dist/classify/lazy.d.ts.map +1 -0
  28. package/dist/classify/lazy.js +686 -0
  29. package/dist/classify/lazy.js.map +1 -0
  30. package/dist/classify/llm-client.d.ts +59 -0
  31. package/dist/classify/llm-client.d.ts.map +1 -0
  32. package/dist/classify/llm-client.js +193 -0
  33. package/dist/classify/llm-client.js.map +1 -0
  34. package/dist/classify/purity.d.ts +21 -0
  35. package/dist/classify/purity.d.ts.map +1 -0
  36. package/dist/classify/purity.js +47 -0
  37. package/dist/classify/purity.js.map +1 -0
  38. package/dist/classify/react-patterns.d.ts +15 -0
  39. package/dist/classify/react-patterns.d.ts.map +1 -0
  40. package/dist/classify/react-patterns.js +82 -0
  41. package/dist/classify/react-patterns.js.map +1 -0
  42. package/dist/classify/taint.d.ts +32 -0
  43. package/dist/classify/taint.d.ts.map +1 -0
  44. package/dist/classify/taint.js +68 -0
  45. package/dist/classify/taint.js.map +1 -0
  46. package/dist/cli.d.ts +3 -0
  47. package/dist/cli.d.ts.map +1 -0
  48. package/dist/cli.js +109 -0
  49. package/dist/cli.js.map +1 -0
  50. package/dist/extract/chunk-module.d.ts +20 -0
  51. package/dist/extract/chunk-module.d.ts.map +1 -0
  52. package/dist/extract/chunk-module.js +163 -0
  53. package/dist/extract/chunk-module.js.map +1 -0
  54. package/dist/extract/client-stub.d.ts +25 -0
  55. package/dist/extract/client-stub.d.ts.map +1 -0
  56. package/dist/extract/client-stub.js +233 -0
  57. package/dist/extract/client-stub.js.map +1 -0
  58. package/dist/extract/import-resolver.d.ts +20 -0
  59. package/dist/extract/import-resolver.d.ts.map +1 -0
  60. package/dist/extract/import-resolver.js +51 -0
  61. package/dist/extract/import-resolver.js.map +1 -0
  62. package/dist/extract/index.d.ts +20 -0
  63. package/dist/extract/index.d.ts.map +1 -0
  64. package/dist/extract/index.js +105 -0
  65. package/dist/extract/index.js.map +1 -0
  66. package/dist/extract/lazy-transform.d.ts +14 -0
  67. package/dist/extract/lazy-transform.d.ts.map +1 -0
  68. package/dist/extract/lazy-transform.js +473 -0
  69. package/dist/extract/lazy-transform.js.map +1 -0
  70. package/dist/index.d.ts +4 -0
  71. package/dist/index.d.ts.map +1 -0
  72. package/dist/index.js +3 -0
  73. package/dist/index.js.map +1 -0
  74. package/dist/plugin.d.ts +7 -0
  75. package/dist/plugin.d.ts.map +1 -0
  76. package/dist/plugin.js +535 -0
  77. package/dist/plugin.js.map +1 -0
  78. package/dist/runtime/index.d.ts +28 -0
  79. package/dist/runtime/index.d.ts.map +1 -0
  80. package/dist/runtime/index.js +73 -0
  81. package/dist/runtime/index.js.map +1 -0
  82. package/dist/types.d.ts +219 -0
  83. package/dist/types.d.ts.map +1 -0
  84. package/dist/types.js +2 -0
  85. package/dist/types.js.map +1 -0
  86. package/dist/vite.d.ts +3 -0
  87. package/dist/vite.d.ts.map +1 -0
  88. package/dist/vite.js +3 -0
  89. package/dist/vite.js.map +1 -0
  90. package/dist/webpack.d.ts +3 -0
  91. package/dist/webpack.d.ts.map +1 -0
  92. package/dist/webpack.js +3 -0
  93. package/dist/webpack.js.map +1 -0
  94. package/package.json +79 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,sEAAsE;AACtE,MAAM,KAAK,GAAG,IAAI,GAAG,EAAoB,CAAC;AAC1C,sEAAsE;AACtE,MAAM,OAAO,GAAG,IAAI,GAAG,EAA6B,CAAC;AAErD;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc;AAC5B,8DAA8D;AAC9D,OAA2B,EAC3B,SAAiB,EACjB,GAAG,IAAe;IAElB,+CAA+C;IAC/C,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACpC,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;QAChB,OAAO;IACT,CAAC;IAED,iFAAiF;IACjF,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACxC,IAAI,QAAQ,EAAE,CAAC;QACb,QAAQ;aACL,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;aACzB,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC;QACjC,OAAO;IACT,CAAC;IAED,iEAAiE;IACjE,MAAM,OAAO,GAAG,OAAO,EAAE;SACtB,IAAI,CAAC,CAAC,GAA4B,EAAE,EAAE;QACrC,sEAAsE;QACtE,MAAM,EAAE,GAAG,GAAG,CAAC,SAAS,CAAa,CAAC;QACtC,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QACzB,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC1B,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;IAEL,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAEhC,yDAAyD;IACzD,OAAO;SACJ,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;SACzB,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC;AACnC,CAAC;AAED;;;GAGG;AACH,SAAS,WAAW,CAAC,SAAiB;IACpC,OAAO,CAAC,GAAY,EAAE,EAAE;QACtB,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC1B,OAAO,CAAC,KAAK,CAAC,2CAA2C,SAAS,IAAI,EAAE,GAAG,CAAC,CAAC;IAC/E,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,219 @@
1
+ import type { Program } from 'estree';
2
+ /** Classification of a code segment */
3
+ export type SegmentClassification = 'PureComputation' | 'EventHandler' | 'ClientInteractive' | 'Shared' | 'Ambiguous';
4
+ /** A classified code segment within a module */
5
+ export interface ClassifiedSegment {
6
+ /** Content-hashed unique identifier */
7
+ id: string;
8
+ /** Human-readable name (e.g., "ProductPage_useMemo_0") */
9
+ name: string;
10
+ /** Classification result */
11
+ classification: SegmentClassification;
12
+ /** Confidence score from 0.0 to 1.0 */
13
+ confidence: number;
14
+ /** Human-readable reasons for the classification */
15
+ reasons: string[];
16
+ /** Identifiers this segment depends on */
17
+ dependencies: string[];
18
+ /** Source location */
19
+ span: {
20
+ start: number;
21
+ end: number;
22
+ };
23
+ }
24
+ /** Variable dependency information for a function */
25
+ export interface FunctionDependency {
26
+ /** Function name (or "<anonymous>") */
27
+ name: string;
28
+ /** Variables declared locally in this function */
29
+ locals: string[];
30
+ /** Variables captured from an outer scope */
31
+ captured: string[];
32
+ /** Variables imported from other modules */
33
+ imported: string[];
34
+ /** Global/browser variables referenced */
35
+ globals: string[];
36
+ /** Source location */
37
+ span: {
38
+ start: number;
39
+ end: number;
40
+ };
41
+ }
42
+ /** Result of analyzing a single module */
43
+ export interface AnalyzedModule {
44
+ /** File path */
45
+ path: string;
46
+ /** Parsed AST */
47
+ ast: Program;
48
+ /** All functions/closures found and their dependencies */
49
+ functions: FunctionDependency[];
50
+ /** All import sources */
51
+ imports: ImportInfo[];
52
+ /** Re-exports: `export { X } from './X'` pass-through mappings */
53
+ reExports: ReExportMapping[];
54
+ }
55
+ /** A single re-export mapping: `export { importedName as exportedName } from source` */
56
+ export interface ReExportMapping {
57
+ /** The name exported from this module */
58
+ exportedName: string;
59
+ /** The name imported from the source module (e.g., "default" for `export { default as Foo }`) */
60
+ importedName: string;
61
+ /** The source module specifier */
62
+ source: string;
63
+ }
64
+ /** Import information */
65
+ export interface ImportInfo {
66
+ /** Module specifier (e.g., "react", "./utils") */
67
+ source: string;
68
+ /** Imported bindings */
69
+ specifiers: Array<{
70
+ local: string;
71
+ imported: string | null;
72
+ kind: 'named' | 'default' | 'namespace';
73
+ }>;
74
+ }
75
+ /** Source map output from esrap's print() */
76
+ export interface SourceMapLike {
77
+ version: number;
78
+ sources: string[];
79
+ sourcesContent: string[];
80
+ mappings: string;
81
+ names: string[];
82
+ }
83
+ /** Result of full classification + extraction */
84
+ export interface AnalysisResult {
85
+ /** Original file path */
86
+ path: string;
87
+ /** Classified segments */
88
+ segments: ClassifiedSegment[];
89
+ /** Whether any extractions were made */
90
+ hasExtractions: boolean;
91
+ /** Transformed client code (if extractions were made) */
92
+ clientCode?: string;
93
+ /** Source map for transformed client code */
94
+ clientMap?: SourceMapLike;
95
+ /** Generated lazy-loaded chunk modules */
96
+ chunkModules?: Array<{
97
+ id: string;
98
+ code: string;
99
+ map: SourceMapLike;
100
+ }>;
101
+ /** Lazy component candidates (components that should be React.lazy wrapped) */
102
+ lazyCandidates?: LazyCandidate[];
103
+ /** Components kept static with reasons */
104
+ lazyKeptStatic?: Array<{
105
+ localName: string;
106
+ source: string;
107
+ reason: string;
108
+ }>;
109
+ }
110
+ /** Prefetch strategy for lazy-loaded components */
111
+ export type PrefetchStrategy = 'immediate' | 'viewport' | 'interaction' | 'idle';
112
+ /**
113
+ * A child component import that should be wrapped in React.lazy + Suspense.
114
+ * Produced by the lazy detection pass in classify/lazy.ts.
115
+ */
116
+ export interface LazyCandidate {
117
+ /** Local binding name (e.g., "PaymentForm") */
118
+ localName: string;
119
+ /** Original import source as written in the module (e.g., "./components") */
120
+ source: string;
121
+ /**
122
+ * Resolved import source for the dynamic import, after barrel file resolution.
123
+ * When null/undefined, falls back to `source`.
124
+ * E.g., if `source` is "./components" (barrel) and the barrel re-exports
125
+ * PaymentForm from "./PaymentForm", resolvedSource is "./components/PaymentForm".
126
+ */
127
+ resolvedSource?: string;
128
+ /** Whether the original import was default, named, or namespace */
129
+ importKind: 'default' | 'named' | 'namespace';
130
+ /** For named imports, the exported name from the source module */
131
+ importedName: string | null;
132
+ /** All JSX locations where this component is used */
133
+ jsxUsages: Array<{
134
+ start: number;
135
+ end: number;
136
+ }>;
137
+ /** Recommended loading strategy */
138
+ prefetch: PrefetchStrategy;
139
+ /**
140
+ * Group ID for components that should share a Suspense boundary.
141
+ * null = gets its own boundary.
142
+ */
143
+ suspenseGroup: string | null;
144
+ /** Whether this component is conditionally rendered */
145
+ conditional: boolean;
146
+ /** Render order position in the parent JSX container (0-indexed) */
147
+ jsxPosition: number;
148
+ /** Human-readable reason for the decision */
149
+ reason: string;
150
+ }
151
+ /** Result of lazy candidate detection */
152
+ export interface LazyCandidateResult {
153
+ /** Components that should be lazified */
154
+ lazy: LazyCandidate[];
155
+ /** Components kept static, with reasons */
156
+ keepStatic: Array<{
157
+ localName: string;
158
+ source: string;
159
+ reason: string;
160
+ }>;
161
+ }
162
+ /**
163
+ * Cross-module component profile for informing lazy detection.
164
+ * Built from analyzing the imported component's module.
165
+ */
166
+ export interface ComponentProfile {
167
+ /** Whether the component declares event handlers */
168
+ hasHandlers: boolean;
169
+ /** Whether the component uses useState/useReducer */
170
+ hasState: boolean;
171
+ /** Whether the component uses useEffect/useLayoutEffect */
172
+ hasEffects: boolean;
173
+ /** Number of event handlers in the component */
174
+ handlerCount: number;
175
+ /** Whether the component exports a React context (createContext) */
176
+ providesContext: boolean;
177
+ /** Estimated JS bundle size in bytes (0 if unknown) */
178
+ estimatedSize: number;
179
+ }
180
+ /** Plugin configuration options */
181
+ export interface PhantomPluginOptions {
182
+ /** Confidence threshold — below this, leave on client (default: 0.8) */
183
+ confidenceThreshold?: number;
184
+ /** Output path for manifest (default: "phantom.manifest.json") */
185
+ manifestPath?: string;
186
+ /** Suppress build summary output (default: false) */
187
+ silent?: boolean;
188
+ /** Enable React.lazy + Suspense wrapping for child components (default: true) */
189
+ enableLazy?: boolean;
190
+ /** Component profiles from prior analysis (for cross-module awareness) */
191
+ componentProfiles?: Map<string, ComponentProfile>;
192
+ /** Cerebras API key for LLM-assisted lazy optimization (optional) */
193
+ cerebrasApiKey?: string;
194
+ /** Cerebras model ID (default: "qwen-3-32b") */
195
+ cerebrasModel?: string;
196
+ }
197
+ /** A single entry in the Phantom manifest */
198
+ export interface ManifestEntry {
199
+ /** Content-hashed segment ID */
200
+ segmentId: string;
201
+ /** Original source file */
202
+ sourceFile: string;
203
+ /** Virtual module ID for the chunk module */
204
+ virtualId: string;
205
+ /** Human-readable segment name */
206
+ name: string;
207
+ /** Type of extraction */
208
+ kind: 'handler' | 'lazy';
209
+ }
210
+ /** The full Phantom build manifest */
211
+ export interface PhantomManifest {
212
+ version: 1;
213
+ entries: ManifestEntry[];
214
+ stats: {
215
+ totalModulesProcessed: number;
216
+ totalSegmentsExtracted: number;
217
+ };
218
+ }
219
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file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C;KAChC,CAAC;CACH"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/dist/vite.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ declare const _default: (options: import("./types.js").PhantomPluginOptions) => import("unplugin").VitePlugin<any> | import("unplugin").VitePlugin<any>[];
2
+ export default _default;
3
+ //# sourceMappingURL=vite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":";AACA,wBAA4B"}
package/dist/vite.js ADDED
@@ -0,0 +1,3 @@
1
+ import { phantom } from './plugin.js';
2
+ export default phantom.vite;
3
+ //# sourceMappingURL=vite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.js","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,eAAe,OAAO,CAAC,IAAI,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare const _default: (options: import("./types.js").PhantomPluginOptions) => WebpackPluginInstance;
2
+ export default _default;
3
+ //# sourceMappingURL=webpack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webpack.d.ts","sourceRoot":"","sources":["../src/webpack.ts"],"names":[],"mappings":";AACA,wBAA+B"}
@@ -0,0 +1,3 @@
1
+ import { phantom } from './plugin.js';
2
+ export default phantom.webpack;
3
+ //# sourceMappingURL=webpack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webpack.js","sourceRoot":"","sources":["../src/webpack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,eAAe,OAAO,CAAC,OAAO,CAAC"}
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "phantom-build",
3
+ "version": "0.1.0",
4
+ "description": "Automatic code-splitting for React — extracts event handlers into lazy-loaded chunks and wraps below-fold components in React.lazy + Suspense at build time",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./vite": {
14
+ "types": "./dist/vite.d.ts",
15
+ "import": "./dist/vite.js"
16
+ },
17
+ "./webpack": {
18
+ "types": "./dist/webpack.d.ts",
19
+ "import": "./dist/webpack.js"
20
+ },
21
+ "./runtime": {
22
+ "types": "./dist/runtime/index.d.ts",
23
+ "import": "./dist/runtime/index.js"
24
+ }
25
+ },
26
+ "bin": {
27
+ "phantom": "./dist/cli.js"
28
+ },
29
+ "files": [
30
+ "dist",
31
+ "README.md"
32
+ ],
33
+ "scripts": {
34
+ "build": "tsc",
35
+ "test": "vitest run",
36
+ "test:watch": "vitest",
37
+ "typecheck": "tsc --noEmit",
38
+ "lint": "eslint src/",
39
+ "prepublishOnly": "npm run build"
40
+ },
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "git+https://github.com/Phoenixrr2113/phantom.git"
44
+ },
45
+ "bugs": {
46
+ "url": "https://github.com/Phoenixrr2113/phantom/issues"
47
+ },
48
+ "homepage": "https://github.com/Phoenixrr2113/phantom#readme",
49
+ "keywords": [
50
+ "react",
51
+ "code-splitting",
52
+ "lazy-loading",
53
+ "vite",
54
+ "webpack",
55
+ "build-plugin",
56
+ "event-handlers",
57
+ "performance",
58
+ "suspense",
59
+ "unplugin"
60
+ ],
61
+ "author": "Randy Wilson",
62
+ "dependencies": {
63
+ "eslint-scope": "^8.3.0",
64
+ "esrap": "^2.2.3",
65
+ "oxc-parser": "^0.72.1",
66
+ "unplugin": "^2.3.2"
67
+ },
68
+ "devDependencies": {
69
+ "@types/eslint-scope": "^3.7.7",
70
+ "@types/estree": "^1.0.6",
71
+ "@types/node": "^25.2.3",
72
+ "typescript": "^5.7.0",
73
+ "vitest": "^3.0.0"
74
+ },
75
+ "license": "MIT",
76
+ "engines": {
77
+ "node": ">=18.0.0"
78
+ }
79
+ }