@reckona/mreact-router 0.0.92 → 0.0.94
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/README.md +9 -3
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +7 -2
- package/dist/build.js.map +1 -1
- package/dist/client-route-inference.d.ts +1 -1
- package/dist/client-route-inference.d.ts.map +1 -1
- package/dist/client-route-inference.js +1 -1
- package/dist/client-route-inference.js.map +1 -1
- package/dist/client.d.ts +12 -6
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +124 -15
- package/dist/client.js.map +1 -1
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +30 -6
- package/dist/vite.js.map +1 -1
- package/package.json +11 -11
- package/src/build.ts +7 -2
- package/src/client-route-inference.ts +2 -1
- package/src/client.ts +177 -15
- package/src/vite.ts +45 -11
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { collectClientRouteReferences, compilerModuleContextForSource, createClientRouteInferenceCache, detectClientNavigationHint,
|
|
1
|
+
export { collectClientRouteReferences, compilerModuleContextForSource, createClientRouteInferenceCache, detectClientNavigationHint, detectNavigationRuntimeOverride, formatClientRouteInferenceDiagnostic, inferClientRouteModule, isClientRouteModule, isClientRouteSource, resolveNavigationRuntime, routeToClientManifestEntry, type ClientReferenceImport, type ClientRouteInferenceCache, type ClientRouteInferenceDiagnostic, type ClientRouteInferenceResult, type ClientRouteManifestEntry, type ClientRouteReferenceResult, } from "./client.js";
|
|
2
2
|
//# sourceMappingURL=client-route-inference.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-route-inference.d.ts","sourceRoot":"","sources":["../src/client-route-inference.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,EAC9B,+BAA+B,EAC/B,0BAA0B,EAC1B,
|
|
1
|
+
{"version":3,"file":"client-route-inference.d.ts","sourceRoot":"","sources":["../src/client-route-inference.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,EAC9B,+BAA+B,EAC/B,0BAA0B,EAC1B,+BAA+B,EAC/B,oCAAoC,EACpC,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,0BAA0B,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,8BAA8B,EACnC,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,GAChC,MAAM,aAAa,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { collectClientRouteReferences, compilerModuleContextForSource, createClientRouteInferenceCache, detectClientNavigationHint,
|
|
1
|
+
export { collectClientRouteReferences, compilerModuleContextForSource, createClientRouteInferenceCache, detectClientNavigationHint, detectNavigationRuntimeOverride, formatClientRouteInferenceDiagnostic, inferClientRouteModule, isClientRouteModule, isClientRouteSource, resolveNavigationRuntime, routeToClientManifestEntry, } from "./client.js";
|
|
2
2
|
//# sourceMappingURL=client-route-inference.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-route-inference.js","sourceRoot":"","sources":["../src/client-route-inference.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,EAC9B,+BAA+B,EAC/B,0BAA0B,EAC1B,
|
|
1
|
+
{"version":3,"file":"client-route-inference.js","sourceRoot":"","sources":["../src/client-route-inference.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,EAC9B,+BAA+B,EAC/B,0BAA0B,EAC1B,+BAA+B,EAC/B,oCAAoC,EACpC,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,0BAA0B,GAO3B,MAAM,aAAa,CAAC","sourcesContent":["export {\n collectClientRouteReferences,\n compilerModuleContextForSource,\n createClientRouteInferenceCache,\n detectClientNavigationHint,\n detectNavigationRuntimeOverride,\n formatClientRouteInferenceDiagnostic,\n inferClientRouteModule,\n isClientRouteModule,\n isClientRouteSource,\n resolveNavigationRuntime,\n routeToClientManifestEntry,\n type ClientReferenceImport,\n type ClientRouteInferenceCache,\n type ClientRouteInferenceDiagnostic,\n type ClientRouteInferenceResult,\n type ClientRouteManifestEntry,\n type ClientRouteReferenceResult,\n} from \"./client.js\";\n"]}
|
package/dist/client.d.ts
CHANGED
|
@@ -67,6 +67,7 @@ export interface ClientReferenceImport {
|
|
|
67
67
|
export interface ClientRouteReferenceResult extends ClientRouteInferenceResult {
|
|
68
68
|
clientReferenceImports: ClientReferenceImport[];
|
|
69
69
|
clientReferenceManifest: ClientReferenceMetadata[];
|
|
70
|
+
usesNavigationLink: boolean;
|
|
70
71
|
}
|
|
71
72
|
export interface ClientRouteInferenceDiagnostic {
|
|
72
73
|
code: typeof clientBoundaryInferenceServerOnlyReferenceCode | typeof clientBoundaryInferenceUnsupportedReferenceCode;
|
|
@@ -104,6 +105,14 @@ export declare function collectClientRouteReferences(options: {
|
|
|
104
105
|
filename: string;
|
|
105
106
|
vitePlugins?: readonly PluginOption[] | undefined;
|
|
106
107
|
}): Promise<ClientRouteReferenceResult>;
|
|
108
|
+
export declare function resolveNavigationRuntime(options: {
|
|
109
|
+
appDir?: string | undefined;
|
|
110
|
+
cache?: ClientRouteInferenceCache | undefined;
|
|
111
|
+
code: string;
|
|
112
|
+
filename: string;
|
|
113
|
+
references?: ClientRouteReferenceResult | undefined;
|
|
114
|
+
vitePlugins?: readonly PluginOption[] | undefined;
|
|
115
|
+
}): Promise<boolean>;
|
|
107
116
|
export declare function isClientRouteSource(code: string): boolean;
|
|
108
117
|
export declare function compilerModuleContextForSource(options: {
|
|
109
118
|
cache: ClientRouteInferenceCache;
|
|
@@ -174,13 +183,10 @@ export declare function buildClientRouteEntrySource(options: BuildClientRouteOut
|
|
|
174
183
|
* source. Returns the hinted value, or `true` when no hint is present (i.e.,
|
|
175
184
|
* preserve the historical "navigation runtime is always present" behavior).
|
|
176
185
|
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
* export const clientNavigation = false
|
|
180
|
-
* export const clientNavigation = false ;
|
|
181
|
-
* export const clientNavigation: boolean = false
|
|
186
|
+
* AST-based so commented-out or string-literal occurrences of the pattern are
|
|
187
|
+
* not mistaken for a real export.
|
|
182
188
|
*/
|
|
183
189
|
export declare function detectClientNavigationHint(source: string): boolean;
|
|
184
|
-
export declare function
|
|
190
|
+
export declare function detectNavigationRuntimeOverride(source: string): boolean | undefined;
|
|
185
191
|
export {};
|
|
186
192
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAIA,OAAO,EAML,KAAK,yBAAyB,EAI/B,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACxF,OAAO,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAIA,OAAO,EAML,KAAK,yBAAyB,EAI/B,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACxF,OAAO,EAOL,KAAK,qBAAqB,EAC3B,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAIL,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC7B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,KAAK,0BAA0B,EAChC,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAY5C,OAAO,KAAK,EAAU,YAAY,EAAE,MAAM,MAAM,CAAC;AAIjD,MAAM,WAAW,wBAAwB;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC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AM,CAAA;CAAE,CAAC,CAYzC;AAED,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAuBzC;AAED,wBAAsB,2BAA2B,CAAC,OAAO,EAAE;IACzD,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,oBAAoB,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IACrD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,MAAM,EAAE,SAAS,6BAA6B,EAAE,CAAC;IACjD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,SAAS,YAAY,EAAE,GAAG,SAAS,CAAC;CACnD,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAqDvC;AAED,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAw0D3B;AAwLD;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAElE;AAsDD,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAEnF"}
|
package/dist/client.js
CHANGED
|
@@ -3,7 +3,7 @@ import { readFile, stat } from "node:fs/promises";
|
|
|
3
3
|
import { builtinModules } from "node:module";
|
|
4
4
|
import { dirname, extname, join, relative, sep } from "node:path";
|
|
5
5
|
import { analyzeBoundaryGraph, collectClientRouteModuleAnalysis, formatDiagnostic, } from "@reckona/mreact-compiler";
|
|
6
|
-
import { collectClientRouteModuleAnalysisFromContext, createCompilerModuleContext, stripTypeScriptWithOxc, transformCompilerModuleContext, } from "@reckona/mreact-compiler/internal";
|
|
6
|
+
import { collectClientRouteModuleAnalysisFromContext, createCompilerModuleContext, readTopLevelBooleanExport, readTopLevelBooleanExportFromContext, stripTypeScriptWithOxc, transformCompilerModuleContext, } from "@reckona/mreact-compiler/internal";
|
|
7
7
|
import { assetPath } from "./assets.js";
|
|
8
8
|
import { bundleRouterModule, bundleRouterModules, } from "./bundle-pipeline.js";
|
|
9
9
|
import { resolveClientConsolePureFunctions, } from "./config.js";
|
|
@@ -273,8 +273,33 @@ export async function collectClientRouteReferences(options) {
|
|
|
273
273
|
clientReferenceImports,
|
|
274
274
|
clientReferenceManifest,
|
|
275
275
|
diagnostics: sources.flatMap((source) => source.inference.diagnostics),
|
|
276
|
+
usesNavigationLink: routeInference.usesNavigationLink ||
|
|
277
|
+
sources.some((source) => source.filename !== options.filename && source.inference.usesNavigationLink),
|
|
276
278
|
};
|
|
277
279
|
}
|
|
280
|
+
export async function resolveNavigationRuntime(options) {
|
|
281
|
+
const cache = options.cache ?? createClientRouteInferenceCache();
|
|
282
|
+
// Read the override from the cached module context so the dev server does not
|
|
283
|
+
// re-parse every page route on each request.
|
|
284
|
+
const moduleContext = await compilerModuleContextForSource({
|
|
285
|
+
cache,
|
|
286
|
+
code: options.code,
|
|
287
|
+
filename: options.filename,
|
|
288
|
+
});
|
|
289
|
+
const override = readTopLevelBooleanExportFromContext(moduleContext, "navigationRuntime");
|
|
290
|
+
if (override !== undefined) {
|
|
291
|
+
return override;
|
|
292
|
+
}
|
|
293
|
+
const references = options.references ??
|
|
294
|
+
(await collectClientRouteReferences({
|
|
295
|
+
appDir: options.appDir,
|
|
296
|
+
cache,
|
|
297
|
+
code: options.code,
|
|
298
|
+
filename: options.filename,
|
|
299
|
+
vitePlugins: options.vitePlugins,
|
|
300
|
+
}));
|
|
301
|
+
return references.usesNavigationLink;
|
|
302
|
+
}
|
|
278
303
|
async function inferClientRouteShellModules(options) {
|
|
279
304
|
return Promise.all((await clientShellFilesForPage(options.appDir, options.filename)).map(async (shell) => {
|
|
280
305
|
const code = stripRouteClientSource({
|
|
@@ -328,10 +353,13 @@ function hasServerOnlyImports(analysis) {
|
|
|
328
353
|
}
|
|
329
354
|
async function inferClientRouteModuleSource(options) {
|
|
330
355
|
const analysis = await clientRouteModuleAnalysisForSource(options);
|
|
356
|
+
const usesNavigationLinkLocal = detectLinkComponentUsage(analysis);
|
|
331
357
|
if (isServerOnlyClientRouteSource(analysis)) {
|
|
332
358
|
return emptyClientRouteModuleInferenceResult({
|
|
359
|
+
navigationLinkExportNames: detectLinkComponentExportNames(analysis),
|
|
333
360
|
serverOnly: true,
|
|
334
361
|
serverOnlyClientRuntime: analysis.clientRuntime,
|
|
362
|
+
usesNavigationLink: usesNavigationLinkLocal,
|
|
335
363
|
});
|
|
336
364
|
}
|
|
337
365
|
if (isExplicitClientRouteSource(analysis, options.filename)) {
|
|
@@ -353,6 +381,8 @@ async function inferClientRouteModuleSource(options) {
|
|
|
353
381
|
let boundaryGraphFallbackRequired = false;
|
|
354
382
|
let clientProxy = false;
|
|
355
383
|
let nestedClient = false;
|
|
384
|
+
let usesNavigationLink = usesNavigationLinkLocal;
|
|
385
|
+
const navigationLinkExportNames = new Set(detectLinkComponentExportNames(analysis));
|
|
356
386
|
const exportInfo = analysis.topLevelExportRenderInfo;
|
|
357
387
|
const implicitModuleClient = exportInfo.length === 0 && analysis.clientRuntime;
|
|
358
388
|
for (const info of exportInfo) {
|
|
@@ -369,7 +399,13 @@ async function inferClientRouteModuleSource(options) {
|
|
|
369
399
|
}
|
|
370
400
|
const jsxComponentRoots = new Set(analysis.jsxComponentRoots);
|
|
371
401
|
const componentCallRoots = new Set(analysis.componentCallRoots);
|
|
372
|
-
|
|
402
|
+
// A bare-identifier default export (`export default Page`) is the route's
|
|
403
|
+
// rendered component even though the module body has no JSX for it; treat it
|
|
404
|
+
// as a rendered root so a re-exported imported component (and any Link it
|
|
405
|
+
// renders) is followed.
|
|
406
|
+
const renderedComponentRoots = analysis.defaultExportIdentifier === undefined
|
|
407
|
+
? unionSets(jsxComponentRoots, componentCallRoots)
|
|
408
|
+
: new Set([...jsxComponentRoots, ...componentCallRoots, analysis.defaultExportIdentifier]);
|
|
373
409
|
const identifierReferences = new Set(analysis.identifierReferences);
|
|
374
410
|
for (const reference of analysis.staticImports) {
|
|
375
411
|
const renderedByJsx = isRenderedImportReference(reference, jsxComponentRoots);
|
|
@@ -411,6 +447,20 @@ async function inferClientRouteModuleSource(options) {
|
|
|
411
447
|
sourceTransform: options.sourceTransform,
|
|
412
448
|
});
|
|
413
449
|
diagnostics.push(...imported.diagnostics);
|
|
450
|
+
// Propagate the navigation runtime only for imports that are actually
|
|
451
|
+
// rendered here, and only for the specific exports whose subtree renders a
|
|
452
|
+
// `Link`. A merely-referenced import (e.g. `const C = Nav`) recurses for
|
|
453
|
+
// client-boundary detection but must not pull in a transitive `Link`, and
|
|
454
|
+
// a barrel re-exporting Link-free siblings must not over-trigger.
|
|
455
|
+
if (rendered) {
|
|
456
|
+
const importedNavigationExportNames = renderedImportedExportNames(reference, renderedComponentRoots);
|
|
457
|
+
if (matchesInferredExportNames(importedNavigationExportNames, imported.navigationLinkExportNames)) {
|
|
458
|
+
usesNavigationLink = true;
|
|
459
|
+
for (const exportName of renderedLocalExportNames(reference, exportInfo)) {
|
|
460
|
+
navigationLinkExportNames.add(exportName);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
414
464
|
if (!imported.client) {
|
|
415
465
|
if (rendered && imported.boundaryGraphFallbackCandidate) {
|
|
416
466
|
boundaryGraphFallbackRequired = true;
|
|
@@ -487,6 +537,24 @@ async function inferClientRouteModuleSource(options) {
|
|
|
487
537
|
sourceTransform: options.sourceTransform,
|
|
488
538
|
});
|
|
489
539
|
diagnostics.push(...exported.diagnostics);
|
|
540
|
+
// A re-export renders nothing itself, so it does not set the module's
|
|
541
|
+
// own `usesNavigationLink`; it only forwards per-export `Link` usage so
|
|
542
|
+
// an importer that renders this name can decide precisely. Map the
|
|
543
|
+
// source module's export names onto the names this barrel re-exposes:
|
|
544
|
+
// `export * from` keeps the original names, `export { A as Nav } from`
|
|
545
|
+
// renames them.
|
|
546
|
+
if (reference.exportAll) {
|
|
547
|
+
for (const exportName of exported.navigationLinkExportNames) {
|
|
548
|
+
navigationLinkExportNames.add(exportName);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
else {
|
|
552
|
+
for (const specifier of reference.specifiers) {
|
|
553
|
+
if (exported.navigationLinkExportNames.includes(specifier.localName)) {
|
|
554
|
+
navigationLinkExportNames.add(specifier.exportedName);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
490
558
|
if (exported.clientBoundaryModule) {
|
|
491
559
|
clientProxy = true;
|
|
492
560
|
}
|
|
@@ -520,8 +588,10 @@ async function inferClientRouteModuleSource(options) {
|
|
|
520
588
|
nestedClientExportNames: Array.from(nestedClientExportNames),
|
|
521
589
|
clientReferenceSourceFiles: Array.from(new Set(clientReferenceSourceFiles)),
|
|
522
590
|
diagnostics,
|
|
591
|
+
navigationLinkExportNames: Array.from(navigationLinkExportNames),
|
|
523
592
|
serverOnly: false,
|
|
524
593
|
serverOnlyClientRuntime: false,
|
|
594
|
+
usesNavigationLink,
|
|
525
595
|
};
|
|
526
596
|
}
|
|
527
597
|
finally {
|
|
@@ -539,8 +609,10 @@ function emptyClientRouteModuleInferenceResult(overrides = {}) {
|
|
|
539
609
|
nestedClientExportNames: [],
|
|
540
610
|
clientReferenceSourceFiles: [],
|
|
541
611
|
diagnostics: [],
|
|
612
|
+
navigationLinkExportNames: [],
|
|
542
613
|
serverOnly: false,
|
|
543
614
|
serverOnlyClientRuntime: false,
|
|
615
|
+
usesNavigationLink: false,
|
|
544
616
|
...overrides,
|
|
545
617
|
};
|
|
546
618
|
}
|
|
@@ -556,7 +628,7 @@ async function clientRouteModuleAnalysisForSource(options) {
|
|
|
556
628
|
code: options.code,
|
|
557
629
|
filename: options.filename,
|
|
558
630
|
}))));
|
|
559
|
-
options.cache.moduleAnalysisByFile.
|
|
631
|
+
setLatestModuleCacheEntry(options.cache.moduleAnalysisByFile, options.filename, cacheKey, analysis);
|
|
560
632
|
return analysis;
|
|
561
633
|
}
|
|
562
634
|
export async function compilerModuleContextForSource(options) {
|
|
@@ -569,12 +641,26 @@ export async function compilerModuleContextForSource(options) {
|
|
|
569
641
|
code: options.code,
|
|
570
642
|
filename: options.filename,
|
|
571
643
|
}));
|
|
572
|
-
options.cache.moduleContextByFile.
|
|
644
|
+
setLatestModuleCacheEntry(options.cache.moduleContextByFile, options.filename, cacheKey, context);
|
|
573
645
|
return context;
|
|
574
646
|
}
|
|
575
647
|
function sourceAnalysisCacheKey(filename, code) {
|
|
576
648
|
return `${filename}\0${hashSourceText(code)}`;
|
|
577
649
|
}
|
|
650
|
+
// Keeps only the latest content version per file in the source-keyed caches.
|
|
651
|
+
// The cache persists across dev requests, and keys embed a content hash, so
|
|
652
|
+
// without this an edited file would accumulate an entry per saved version.
|
|
653
|
+
// Filenames cannot contain the NUL separator, so the `${filename}\0` prefix
|
|
654
|
+
// matches exactly that file's prior entries.
|
|
655
|
+
function setLatestModuleCacheEntry(map, filename, cacheKey, value) {
|
|
656
|
+
const prefix = `${filename}\0`;
|
|
657
|
+
for (const existing of map.keys()) {
|
|
658
|
+
if (existing !== cacheKey && existing.startsWith(prefix)) {
|
|
659
|
+
map.delete(existing);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
map.set(cacheKey, value);
|
|
663
|
+
}
|
|
578
664
|
function hashSourceText(text) {
|
|
579
665
|
return createHash("sha256").update(text).digest("hex");
|
|
580
666
|
}
|
|
@@ -2991,19 +3077,42 @@ function importerInRuntimePackage(importer, directories, packageNames) {
|
|
|
2991
3077
|
* source. Returns the hinted value, or `true` when no hint is present (i.e.,
|
|
2992
3078
|
* preserve the historical "navigation runtime is always present" behavior).
|
|
2993
3079
|
*
|
|
2994
|
-
*
|
|
2995
|
-
*
|
|
2996
|
-
* export const clientNavigation = false
|
|
2997
|
-
* export const clientNavigation = false ;
|
|
2998
|
-
* export const clientNavigation: boolean = false
|
|
3080
|
+
* AST-based so commented-out or string-literal occurrences of the pattern are
|
|
3081
|
+
* not mistaken for a real export.
|
|
2999
3082
|
*/
|
|
3000
3083
|
export function detectClientNavigationHint(source) {
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3084
|
+
return readTopLevelBooleanExport({ code: source, name: "clientNavigation" }) ?? true;
|
|
3085
|
+
}
|
|
3086
|
+
// `Link` ships from the dedicated `/link` subpath and is also re-exported from
|
|
3087
|
+
// the package root for backward compatibility, so both specifiers must count.
|
|
3088
|
+
// The root entry exports many bindings, so a root import only triggers the
|
|
3089
|
+
// navigation runtime when the rendered specifier is `Link` specifically.
|
|
3090
|
+
const navigationLinkPackageSpecifiers = new Set([
|
|
3091
|
+
"@reckona/mreact-router",
|
|
3092
|
+
"@reckona/mreact-router/link",
|
|
3093
|
+
]);
|
|
3094
|
+
function staticImportsRenderLink(staticImports, renderedRoots, renderedNames) {
|
|
3095
|
+
return staticImports.some((reference) => navigationLinkPackageSpecifiers.has(reference.source) &&
|
|
3096
|
+
reference.specifiers.some((specifier) => (specifier.importedName === "Link" && renderedRoots.has(specifier.localName)) ||
|
|
3097
|
+
(specifier.kind === "namespace" && renderedNames.has(`${specifier.localName}.Link`))));
|
|
3098
|
+
}
|
|
3099
|
+
function detectLinkComponentUsage(analysis) {
|
|
3100
|
+
// Use the export-reachable rendered roots, not the file-wide JSX roots, so a
|
|
3101
|
+
// `Link` rendered only in dead/unreachable code does not trigger the runtime.
|
|
3102
|
+
return staticImportsRenderLink(analysis.staticImports, new Set(analysis.reachableRenderedComponentRoots), new Set(analysis.reachableRenderedComponentNames));
|
|
3103
|
+
}
|
|
3104
|
+
// Export names whose own render subtree (transitively, within this module)
|
|
3105
|
+
// renders a navigation `Link`. Lets callers attribute `Link` usage to the
|
|
3106
|
+
// specific export they render, so a barrel that re-exports both Link-using and
|
|
3107
|
+
// Link-free components only triggers the runtime for the ones actually rendered.
|
|
3108
|
+
function detectLinkComponentExportNames(analysis) {
|
|
3109
|
+
return Object.keys(analysis.reachableExportRenderedComponentRoots).filter((exportName) => staticImportsRenderLink(analysis.staticImports, new Set(analysis.reachableExportRenderedComponentRoots[exportName] ?? []), new Set(analysis.reachableExportRenderedComponentNames[exportName] ?? [])));
|
|
3110
|
+
}
|
|
3111
|
+
// Reads the explicit `export const navigationRuntime = true | false` override.
|
|
3112
|
+
// Returns `undefined` when absent. AST-based so commented-out or string-literal
|
|
3113
|
+
// occurrences of the pattern are not mistaken for a real export.
|
|
3114
|
+
export function detectNavigationRuntimeOverride(source) {
|
|
3115
|
+
return readTopLevelBooleanExport({ code: source, name: "navigationRuntime" });
|
|
3007
3116
|
}
|
|
3008
3117
|
function detectRouteCellStateHint(code) {
|
|
3009
3118
|
const callExpression = routeCellCallExpressionSource(code);
|