@reckona/mreact-compiler 0.0.160 → 0.0.161
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/boundary-graph.d.ts +13 -0
- package/dist/boundary-graph.d.ts.map +1 -1
- package/dist/boundary-graph.js +1 -0
- package/dist/boundary-graph.js.map +1 -1
- package/dist/compiler-module-context.d.ts +2 -0
- package/dist/compiler-module-context.d.ts.map +1 -1
- package/dist/compiler-module-context.js +1 -0
- package/dist/compiler-module-context.js.map +1 -1
- package/dist/diagnostics.d.ts +1 -0
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/diagnostics.js +1 -0
- package/dist/diagnostics.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +35 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +24 -15
- package/dist/internal.js.map +1 -1
- package/dist/ir.d.ts +21 -0
- package/dist/ir.d.ts.map +1 -1
- package/dist/ir.js.map +1 -1
- package/dist/oxc-transform.d.ts +1 -0
- package/dist/oxc-transform.d.ts.map +1 -1
- package/dist/oxc-transform.js +1 -0
- package/dist/oxc-transform.js.map +1 -1
- package/dist/oxc.d.ts +4 -0
- package/dist/oxc.d.ts.map +1 -1
- package/dist/oxc.js +3 -0
- package/dist/oxc.js.map +1 -1
- package/dist/transform.d.ts +2 -0
- package/dist/transform.d.ts.map +1 -1
- package/dist/transform.js +2 -0
- package/dist/transform.js.map +1 -1
- package/dist/types.d.ts +20 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
- package/src/boundary-graph.ts +13 -0
- package/src/compiler-module-context.ts +2 -0
- package/src/diagnostics.ts +1 -0
- package/src/index.ts +2 -0
- package/src/internal.ts +35 -15
- package/src/ir.ts +21 -0
- package/src/oxc-transform.ts +1 -0
- package/src/oxc.ts +4 -0
- package/src/transform.ts +2 -0
- package/src/types.ts +34 -0
package/dist/internal.d.ts
CHANGED
|
@@ -4,46 +4,55 @@ export { transformCompilerModuleContext } from "./transform.js";
|
|
|
4
4
|
export { stripTypeScriptWithOxc } from "./oxc-transform.js";
|
|
5
5
|
export type { CompilerModuleContext } from "./compiler-module-context.js";
|
|
6
6
|
import type { AnalyzeModuleOptions, CompileTarget, Diagnostic } from "./types.js";
|
|
7
|
+
/** Configures source code, filename, target, and analysis options for IR generation. */
|
|
7
8
|
export interface AnalyzeToIrInput {
|
|
8
9
|
code: string;
|
|
9
10
|
filename: string;
|
|
10
11
|
target: CompileTarget;
|
|
11
12
|
options?: AnalyzeModuleOptions;
|
|
12
13
|
}
|
|
14
|
+
/** Contains the module IR and diagnostics produced by compiler analysis. */
|
|
13
15
|
export interface AnalyzeToIrOutput {
|
|
14
16
|
ir: ModuleIr;
|
|
15
17
|
diagnostics: Diagnostic[];
|
|
16
18
|
usedTypescriptFallback?: boolean;
|
|
17
19
|
}
|
|
20
|
+
/** Describes a static import declaration and the local names it introduces. */
|
|
18
21
|
export interface StaticImportReference {
|
|
19
22
|
localNames: string[];
|
|
20
23
|
sideEffect: boolean;
|
|
21
24
|
source: string;
|
|
22
25
|
}
|
|
26
|
+
/** Describes one specifier inside a static import declaration. */
|
|
23
27
|
export interface StaticImportSpecifierReference {
|
|
24
28
|
importedName: string;
|
|
25
29
|
kind: "default" | "named" | "namespace";
|
|
26
30
|
localName: string;
|
|
27
31
|
}
|
|
32
|
+
/** Describes a static import declaration with its individual specifiers. */
|
|
28
33
|
export interface ClientRouteStaticImportReference extends StaticImportReference {
|
|
29
34
|
specifiers: StaticImportSpecifierReference[];
|
|
30
35
|
}
|
|
36
|
+
/** Describes a static export declaration and the names it exports. */
|
|
31
37
|
export interface StaticExportReference {
|
|
32
38
|
exportedNames: string[];
|
|
33
39
|
exportAll: boolean;
|
|
34
40
|
specifiers: StaticExportSpecifierReference[];
|
|
35
41
|
source: string;
|
|
36
42
|
}
|
|
43
|
+
/** Describes one specifier inside a static export declaration. */
|
|
37
44
|
export interface StaticExportSpecifierReference {
|
|
38
45
|
exportedName: string;
|
|
39
46
|
localName: string;
|
|
40
47
|
}
|
|
48
|
+
/** Describes render and client-runtime reachability for one top-level export. */
|
|
41
49
|
export interface TopLevelExportRenderInfo {
|
|
42
50
|
calledComponentRoots: string[];
|
|
43
51
|
clientRuntime: boolean;
|
|
44
52
|
name: string;
|
|
45
53
|
renderedComponentRoots: string[];
|
|
46
54
|
}
|
|
55
|
+
/** Summarizes route-module imports, exports, directives, references, and reachable render roots. */
|
|
47
56
|
export interface ClientRouteModuleAnalysis {
|
|
48
57
|
clientRuntime: boolean;
|
|
49
58
|
defaultExportIdentifier: string | undefined;
|
|
@@ -60,11 +69,13 @@ export interface ClientRouteModuleAnalysis {
|
|
|
60
69
|
staticImports: ClientRouteStaticImportReference[];
|
|
61
70
|
topLevelExportRenderInfo: TopLevelExportRenderInfo[];
|
|
62
71
|
}
|
|
72
|
+
/** Describes a named form action reference and its source span. */
|
|
63
73
|
export interface FormActionReference {
|
|
64
74
|
end: number;
|
|
65
75
|
name: string;
|
|
66
76
|
start: number;
|
|
67
77
|
}
|
|
78
|
+
/** Describes a form action expression reference and both wrapper and expression source spans. */
|
|
68
79
|
export interface FormActionExpressionReference {
|
|
69
80
|
end: number;
|
|
70
81
|
expression: string;
|
|
@@ -72,91 +83,115 @@ export interface FormActionExpressionReference {
|
|
|
72
83
|
expressionStart: number;
|
|
73
84
|
start: number;
|
|
74
85
|
}
|
|
86
|
+
/** Analyzes source code into compiler IR with diagnostics. */
|
|
75
87
|
export declare function analyzeToIr(input: AnalyzeToIrInput): AnalyzeToIrOutput;
|
|
88
|
+
/** Analyzes a pre-parsed compiler module context into compiler IR with diagnostics. */
|
|
76
89
|
export declare function analyzeCompilerModuleContextToIr(context: CompilerModuleContext, input: Omit<AnalyzeToIrInput, "code" | "filename">): AnalyzeToIrOutput;
|
|
90
|
+
/** Creates a compiler module context from source code and an optional filename. */
|
|
77
91
|
export declare function createCompilerModuleContext(input: {
|
|
78
92
|
code: string;
|
|
79
93
|
filename?: string | undefined;
|
|
80
94
|
}): CompilerModuleContext;
|
|
95
|
+
/** Checks whether a module declares any of the given names as top-level exports. */
|
|
81
96
|
export declare function hasTopLevelExportDeclaration(input: {
|
|
82
97
|
code: string;
|
|
83
98
|
filename?: string | undefined;
|
|
84
99
|
names: readonly string[];
|
|
85
100
|
}): boolean;
|
|
101
|
+
/** Reads a top-level exported boolean literal by name, ignoring comments and non-literal values. */
|
|
86
102
|
export declare function readTopLevelBooleanExport(input: {
|
|
87
103
|
code: string;
|
|
88
104
|
filename?: string | undefined;
|
|
89
105
|
name: string;
|
|
90
106
|
}): boolean | undefined;
|
|
107
|
+
/** Reads a top-level exported boolean literal from a cached compiler module context. */
|
|
91
108
|
export declare function readTopLevelBooleanExportFromContext(context: CompilerModuleContext, name: string): boolean | undefined;
|
|
109
|
+
/** Removes top-level export declarations for selected names while preserving their values where possible. */
|
|
92
110
|
export declare function stripTopLevelExportDeclarations(input: {
|
|
93
111
|
code: string;
|
|
94
112
|
filename?: string | undefined;
|
|
95
113
|
names: readonly string[];
|
|
96
114
|
}): string;
|
|
115
|
+
/** Converts selected top-level export declarations into non-exported declarations. */
|
|
97
116
|
export declare function demoteTopLevelExportDeclarations(input: {
|
|
98
117
|
code: string;
|
|
99
118
|
filename?: string | undefined;
|
|
100
119
|
names: readonly string[];
|
|
101
120
|
}): string;
|
|
121
|
+
/** Removes unused static value imports while preserving side-effect and type-only imports. */
|
|
102
122
|
export declare function stripUnusedStaticValueImports(input: {
|
|
103
123
|
code: string;
|
|
104
124
|
filename?: string | undefined;
|
|
105
125
|
}): string;
|
|
126
|
+
/** Collects module specifier strings from static import and export declarations. */
|
|
106
127
|
export declare function collectStaticModuleSpecifiers(input: {
|
|
107
128
|
code: string;
|
|
108
129
|
filename?: string | undefined;
|
|
109
130
|
}): string[];
|
|
131
|
+
/** Collects static import declarations and their local binding names. */
|
|
110
132
|
export declare function collectStaticImportReferences(input: {
|
|
111
133
|
code: string;
|
|
112
134
|
filename?: string | undefined;
|
|
113
135
|
}): StaticImportReference[];
|
|
136
|
+
/** Collects static export declarations and their exported names. */
|
|
114
137
|
export declare function collectStaticExportReferences(input: {
|
|
115
138
|
code: string;
|
|
116
139
|
filename?: string | undefined;
|
|
117
140
|
}): StaticExportReference[];
|
|
141
|
+
/** Collects root component names referenced by JSX elements in a module. */
|
|
118
142
|
export declare function collectJsxComponentRootNames(input: {
|
|
119
143
|
code: string;
|
|
120
144
|
filename?: string | undefined;
|
|
121
145
|
}): string[];
|
|
146
|
+
/** Collects identifier reference names from a module, excluding declarations. */
|
|
122
147
|
export declare function collectIdentifierReferenceNames(input: {
|
|
123
148
|
code: string;
|
|
124
149
|
filename?: string | undefined;
|
|
125
150
|
}): string[];
|
|
151
|
+
/** Checks whether browser globals may execute during server rendering without a guard. */
|
|
126
152
|
export declare function hasUnguardedBrowserGlobalReference(input: {
|
|
127
153
|
code: string;
|
|
128
154
|
filename?: string | undefined;
|
|
129
155
|
}): boolean;
|
|
156
|
+
/** Collects unique named form action references from a module. */
|
|
130
157
|
export declare function collectFormActionReferenceNames(input: {
|
|
131
158
|
code: string;
|
|
132
159
|
filename?: string | undefined;
|
|
133
160
|
}): string[];
|
|
161
|
+
/** Collects named form action references and their source spans from a module. */
|
|
134
162
|
export declare function collectFormActionReferences(input: {
|
|
135
163
|
code: string;
|
|
136
164
|
filename?: string | undefined;
|
|
137
165
|
}): FormActionReference[];
|
|
166
|
+
/** Collects form action expression references and their source spans from a module. */
|
|
138
167
|
export declare function collectFormActionExpressionReferences(input: {
|
|
139
168
|
code: string;
|
|
140
169
|
filename?: string | undefined;
|
|
141
170
|
}): FormActionExpressionReference[];
|
|
171
|
+
/** Collects value export names declared at the top level of a module. */
|
|
142
172
|
export declare function collectTopLevelValueExportNames(input: {
|
|
143
173
|
code: string;
|
|
144
174
|
filename?: string | undefined;
|
|
145
175
|
}): string[];
|
|
176
|
+
/** Collects render reachability information for top-level exports in a module. */
|
|
146
177
|
export declare function collectTopLevelExportRenderInfo(input: {
|
|
147
178
|
code: string;
|
|
148
179
|
filename?: string | undefined;
|
|
149
180
|
}): TopLevelExportRenderInfo[];
|
|
181
|
+
/** Analyzes a route module for directives, static imports, exports, references, and render reachability. */
|
|
150
182
|
export declare function collectClientRouteModuleAnalysis(input: {
|
|
151
183
|
code: string;
|
|
152
184
|
filename?: string | undefined;
|
|
153
185
|
}): ClientRouteModuleAnalysis;
|
|
186
|
+
/** Analyzes a cached compiler module context for route-module metadata. */
|
|
154
187
|
export declare function collectClientRouteModuleAnalysisFromContext(context: CompilerModuleContext): ClientRouteModuleAnalysis;
|
|
188
|
+
/** Checks whether a module begins with a specific directive string. */
|
|
155
189
|
export declare function hasModuleDirective(input: {
|
|
156
190
|
code: string;
|
|
157
191
|
directive: string;
|
|
158
192
|
filename?: string | undefined;
|
|
159
193
|
}): boolean;
|
|
194
|
+
/** Checks whether a module contains syntax that requires client runtime execution. */
|
|
160
195
|
export declare function hasClientRuntimeSyntax(input: {
|
|
161
196
|
code: string;
|
|
162
197
|
filename?: string | undefined;
|
package/dist/internal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAKxC,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,8BAA8B,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,YAAY,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EACb,UAAU,EACX,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,gBAAgB;IAC/B,IAA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gB,2CAA2C,CACzD,OAAO,EAAE,qBAAqB,GAC7B,yBAAyB,CA0B3B;AAukBD,uEAAuE;AACvE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B,GAAG,OAAO,CAIV;AAqBD,sFAAsF;AACtF,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B,GAAG,OAAO,CAIV;AA6+CD,YAAY,EACV,eAAe,EACf,WAAW,EACX,WAAW,EACX,eAAe,EACf,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,MAAM,EACN,YAAY,EACZ,aAAa,EACb,SAAS,EACT,MAAM,EACN,QAAQ,EACR,iBAAiB,EACjB,iBAAiB,EACjB,MAAM,GACP,MAAM,SAAS,CAAC"}
|
package/dist/internal.js
CHANGED
|
@@ -2,29 +2,29 @@ import { analyzeCompilerModuleContextWithOxc, analyzeWithOxc, } from "./oxc.js";
|
|
|
2
2
|
import { createCompilerModuleContextWithOxc, } from "./compiler-module-context.js";
|
|
3
3
|
export { transformCompilerModuleContext } from "./transform.js";
|
|
4
4
|
export { stripTypeScriptWithOxc } from "./oxc-transform.js";
|
|
5
|
+
/** Analyzes source code into compiler IR with diagnostics. */
|
|
5
6
|
export function analyzeToIr(input) {
|
|
6
7
|
return analyzeWithOxc(input);
|
|
7
8
|
}
|
|
9
|
+
/** Analyzes a pre-parsed compiler module context into compiler IR with diagnostics. */
|
|
8
10
|
export function analyzeCompilerModuleContextToIr(context, input) {
|
|
9
11
|
return analyzeCompilerModuleContextWithOxc(context, input);
|
|
10
12
|
}
|
|
13
|
+
/** Creates a compiler module context from source code and an optional filename. */
|
|
11
14
|
export function createCompilerModuleContext(input) {
|
|
12
15
|
return createCompilerModuleContextWithOxc(input);
|
|
13
16
|
}
|
|
17
|
+
/** Checks whether a module declares any of the given names as top-level exports. */
|
|
14
18
|
export function hasTopLevelExportDeclaration(input) {
|
|
15
19
|
const names = new Set(input.names);
|
|
16
20
|
const parsed = parseModule(input.code, input.filename);
|
|
17
21
|
return programBody(parsed.program).some((statement) => exportedNames(statement).some((name) => names.has(name)));
|
|
18
22
|
}
|
|
19
|
-
|
|
20
|
-
// declaration. Returns `undefined` when the export is absent or not a boolean
|
|
21
|
-
// literal. AST-based so commented-out or string-literal occurrences of the same
|
|
22
|
-
// text are not mistaken for a real export.
|
|
23
|
+
/** Reads a top-level exported boolean literal by name, ignoring comments and non-literal values. */
|
|
23
24
|
export function readTopLevelBooleanExport(input) {
|
|
24
25
|
return readTopLevelBooleanExportFromContext(createCompilerModuleContext({ code: input.code, filename: input.filename }), input.name);
|
|
25
26
|
}
|
|
26
|
-
|
|
27
|
-
// (e.g. the dev server) avoid re-parsing the module per request.
|
|
27
|
+
/** Reads a top-level exported boolean literal from a cached compiler module context. */
|
|
28
28
|
export function readTopLevelBooleanExportFromContext(context, name) {
|
|
29
29
|
const parsed = parseModuleContext(context);
|
|
30
30
|
for (const statement of programBody(parsed.program)) {
|
|
@@ -63,6 +63,7 @@ function booleanExpressionValue(node) {
|
|
|
63
63
|
}
|
|
64
64
|
return undefined;
|
|
65
65
|
}
|
|
66
|
+
/** Removes top-level export declarations for selected names while preserving their values where possible. */
|
|
66
67
|
export function stripTopLevelExportDeclarations(input) {
|
|
67
68
|
const names = new Set(input.names);
|
|
68
69
|
const parsed = parseModule(input.code, input.filename);
|
|
@@ -76,6 +77,7 @@ export function stripTopLevelExportDeclarations(input) {
|
|
|
76
77
|
}
|
|
77
78
|
return code;
|
|
78
79
|
}
|
|
80
|
+
/** Converts selected top-level export declarations into non-exported declarations. */
|
|
79
81
|
export function demoteTopLevelExportDeclarations(input) {
|
|
80
82
|
const names = new Set(input.names);
|
|
81
83
|
const parsed = parseModule(input.code, input.filename);
|
|
@@ -89,6 +91,7 @@ export function demoteTopLevelExportDeclarations(input) {
|
|
|
89
91
|
}
|
|
90
92
|
return code;
|
|
91
93
|
}
|
|
94
|
+
/** Removes unused static value imports while preserving side-effect and type-only imports. */
|
|
92
95
|
export function stripUnusedStaticValueImports(input) {
|
|
93
96
|
const parsed = parseModule(input.code, input.filename);
|
|
94
97
|
const referencedNames = new Set(collectIdentifierReferenceNames(input));
|
|
@@ -102,18 +105,22 @@ export function stripUnusedStaticValueImports(input) {
|
|
|
102
105
|
}
|
|
103
106
|
return code;
|
|
104
107
|
}
|
|
108
|
+
/** Collects module specifier strings from static import and export declarations. */
|
|
105
109
|
export function collectStaticModuleSpecifiers(input) {
|
|
106
110
|
const parsed = parseModule(input.code, input.filename);
|
|
107
111
|
return programBody(parsed.program).flatMap(staticModuleSpecifier);
|
|
108
112
|
}
|
|
113
|
+
/** Collects static import declarations and their local binding names. */
|
|
109
114
|
export function collectStaticImportReferences(input) {
|
|
110
115
|
const parsed = parseModule(input.code, input.filename);
|
|
111
116
|
return programBody(parsed.program).flatMap(staticImportReference);
|
|
112
117
|
}
|
|
118
|
+
/** Collects static export declarations and their exported names. */
|
|
113
119
|
export function collectStaticExportReferences(input) {
|
|
114
120
|
const parsed = parseModule(input.code, input.filename);
|
|
115
121
|
return programBody(parsed.program).flatMap(staticExportReference);
|
|
116
122
|
}
|
|
123
|
+
/** Collects root component names referenced by JSX elements in a module. */
|
|
117
124
|
export function collectJsxComponentRootNames(input) {
|
|
118
125
|
const parsed = parseModule(input.code, input.filename);
|
|
119
126
|
const names = new Set();
|
|
@@ -123,34 +130,30 @@ export function collectJsxComponentRootNames(input) {
|
|
|
123
130
|
expandJsxComponentAliasRoots(names, aliasState.aliases);
|
|
124
131
|
return Array.from(names).sort();
|
|
125
132
|
}
|
|
133
|
+
/** Collects identifier reference names from a module, excluding declarations. */
|
|
126
134
|
export function collectIdentifierReferenceNames(input) {
|
|
127
135
|
const parsed = parseModule(input.code, input.filename);
|
|
128
136
|
const names = new Set();
|
|
129
137
|
collectIdentifierReferenceNamesFromNode(parsed.program, names);
|
|
130
138
|
return Array.from(names).sort();
|
|
131
139
|
}
|
|
132
|
-
|
|
133
|
-
// `document`, `localStorage`) in a position that may execute during server
|
|
134
|
-
// rendering. A reference is considered guarded -- and therefore server-safe --
|
|
135
|
-
// when it can only evaluate behind a `typeof window !== "undefined"` style
|
|
136
|
-
// check: the guarded branch of an if/ternary, the short-circuited side of a
|
|
137
|
-
// logical expression, or statements following a guarded early exit. A guard on
|
|
138
|
-
// any one browser global covers the others, matching how isomorphic modules
|
|
139
|
-
// are written in practice. Alias-tracked guards (`const isBrowser = ...`) are
|
|
140
|
-
// not followed; they conservatively report an unguarded reference.
|
|
140
|
+
/** Checks whether browser globals may execute during server rendering without a guard. */
|
|
141
141
|
export function hasUnguardedBrowserGlobalReference(input) {
|
|
142
142
|
const parsed = parseModule(input.code, input.filename);
|
|
143
143
|
return hasUnguardedBrowserGlobalReferenceInNode(parsed.program, false);
|
|
144
144
|
}
|
|
145
|
+
/** Collects unique named form action references from a module. */
|
|
145
146
|
export function collectFormActionReferenceNames(input) {
|
|
146
147
|
return Array.from(new Set(collectFormActionReferences(input).map((reference) => reference.name))).sort();
|
|
147
148
|
}
|
|
149
|
+
/** Collects named form action references and their source spans from a module. */
|
|
148
150
|
export function collectFormActionReferences(input) {
|
|
149
151
|
const parsed = parseModule(input.code, input.filename);
|
|
150
152
|
const references = [];
|
|
151
153
|
collectFormActionReferencesFromNode(parsed.program, references);
|
|
152
154
|
return references.sort((left, right) => left.start === right.start ? left.name.localeCompare(right.name) : left.start - right.start);
|
|
153
155
|
}
|
|
156
|
+
/** Collects form action expression references and their source spans from a module. */
|
|
154
157
|
export function collectFormActionExpressionReferences(input) {
|
|
155
158
|
const parsed = parseModule(input.code, input.filename);
|
|
156
159
|
const references = [];
|
|
@@ -159,6 +162,7 @@ export function collectFormActionExpressionReferences(input) {
|
|
|
159
162
|
? left.expression.localeCompare(right.expression)
|
|
160
163
|
: left.start - right.start);
|
|
161
164
|
}
|
|
165
|
+
/** Collects value export names declared at the top level of a module. */
|
|
162
166
|
export function collectTopLevelValueExportNames(input) {
|
|
163
167
|
const parsed = parseModule(input.code, input.filename);
|
|
164
168
|
const names = new Set();
|
|
@@ -169,14 +173,17 @@ export function collectTopLevelValueExportNames(input) {
|
|
|
169
173
|
}
|
|
170
174
|
return Array.from(names).sort();
|
|
171
175
|
}
|
|
176
|
+
/** Collects render reachability information for top-level exports in a module. */
|
|
172
177
|
export function collectTopLevelExportRenderInfo(input) {
|
|
173
178
|
const parsed = parseModule(input.code, input.filename);
|
|
174
179
|
return collectTopLevelExportRenderInfoFromProgram(parsed.program);
|
|
175
180
|
}
|
|
181
|
+
/** Analyzes a route module for directives, static imports, exports, references, and render reachability. */
|
|
176
182
|
export function collectClientRouteModuleAnalysis(input) {
|
|
177
183
|
const parsed = parseModule(input.code, input.filename);
|
|
178
184
|
return collectClientRouteModuleAnalysisFromContext(parsed);
|
|
179
185
|
}
|
|
186
|
+
/** Analyzes a cached compiler module context for route-module metadata. */
|
|
180
187
|
export function collectClientRouteModuleAnalysisFromContext(context) {
|
|
181
188
|
const parsed = parseModuleContext(context);
|
|
182
189
|
const body = programBody(parsed.program);
|
|
@@ -559,6 +566,7 @@ function isNonComputedPropertyKey(node) {
|
|
|
559
566
|
node.type === "MethodDefinition") &&
|
|
560
567
|
node.computed !== true);
|
|
561
568
|
}
|
|
569
|
+
/** Checks whether a module begins with a specific directive string. */
|
|
562
570
|
export function hasModuleDirective(input) {
|
|
563
571
|
const parsed = parseModule(input.code, input.filename);
|
|
564
572
|
return hasModuleDirectiveInProgram(parsed.program, input.directive);
|
|
@@ -578,6 +586,7 @@ function hasModuleDirectiveInProgram(program, expectedDirective) {
|
|
|
578
586
|
}
|
|
579
587
|
return false;
|
|
580
588
|
}
|
|
589
|
+
/** Checks whether a module contains syntax that requires client runtime execution. */
|
|
581
590
|
export function hasClientRuntimeSyntax(input) {
|
|
582
591
|
const parsed = parseModule(input.code, input.filename);
|
|
583
592
|
return hasClientRuntimeSyntaxNode(parsed.program);
|