@reckona/mreact-router 0.0.175 → 0.0.176
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/adapters/cloudflare.d.ts.map +1 -1
- package/dist/adapters/cloudflare.js +5 -49
- package/dist/adapters/cloudflare.js.map +1 -1
- package/dist/build.d.ts +1 -0
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +90 -0
- package/dist/build.js.map +1 -1
- package/dist/built-assets.d.ts +11 -0
- package/dist/built-assets.d.ts.map +1 -0
- package/dist/built-assets.js +130 -0
- package/dist/built-assets.js.map +1 -0
- package/dist/built-runtime.d.ts +53 -0
- package/dist/built-runtime.d.ts.map +1 -0
- package/dist/built-runtime.js +178 -0
- package/dist/built-runtime.js.map +1 -0
- package/dist/built-server-module-artifacts.d.ts +19 -0
- package/dist/built-server-module-artifacts.d.ts.map +1 -0
- package/dist/built-server-module-artifacts.js +217 -0
- package/dist/built-server-module-artifacts.js.map +1 -0
- package/dist/client-manifest-assets.d.ts +16 -0
- package/dist/client-manifest-assets.d.ts.map +1 -0
- package/dist/client-manifest-assets.js +60 -0
- package/dist/client-manifest-assets.js.map +1 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +31 -3
- package/dist/client.js.map +1 -1
- package/dist/node-server.d.ts +29 -0
- package/dist/node-server.d.ts.map +1 -0
- package/dist/node-server.js +81 -0
- package/dist/node-server.js.map +1 -0
- package/dist/render.d.ts +9 -0
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +20 -41
- package/dist/render.js.map +1 -1
- package/dist/route-dispatch.d.ts +2 -0
- package/dist/route-dispatch.d.ts.map +1 -0
- package/dist/route-dispatch.js +16 -0
- package/dist/route-dispatch.js.map +1 -0
- package/dist/route-loader-runtime.d.ts +22 -0
- package/dist/route-loader-runtime.d.ts.map +1 -0
- package/dist/route-loader-runtime.js +30 -0
- package/dist/route-loader-runtime.js.map +1 -0
- package/dist/routes.d.ts +2 -0
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +48 -1
- package/dist/routes.js.map +1 -1
- package/dist/serve.d.ts +4 -3
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +84 -582
- package/dist/serve.js.map +1 -1
- package/package.json +11 -11
- package/src/adapters/cloudflare.ts +5 -60
- package/src/build.ts +143 -0
- package/src/built-assets.ts +164 -0
- package/src/built-runtime.ts +312 -0
- package/src/built-server-module-artifacts.ts +340 -0
- package/src/client-manifest-assets.ts +92 -0
- package/src/client.ts +31 -3
- package/src/node-server.ts +129 -0
- package/src/render.ts +38 -60
- package/src/route-dispatch.ts +17 -0
- package/src/route-loader-runtime.ts +54 -0
- package/src/routes.ts +70 -1
- package/src/serve.ts +105 -863
package/dist/build.js
CHANGED
|
@@ -270,6 +270,7 @@ export async function buildApp(options) {
|
|
|
270
270
|
...clientBundle.styles.flatMap((style) => style.css),
|
|
271
271
|
...(navigationRuntimeScript === undefined ? [] : [navigationRuntimeScript]),
|
|
272
272
|
])).sort();
|
|
273
|
+
const serverModuleClosureFiles = buildServerModuleClosureManifest(serverModules, sourceAnalysis);
|
|
273
274
|
const prerenderedRoutes = shouldTrackBuildPhases === false
|
|
274
275
|
? await prerenderStaticRoutes({
|
|
275
276
|
appDir: project.routesDir,
|
|
@@ -341,6 +342,9 @@ export async function buildApp(options) {
|
|
|
341
342
|
...(serverActionManifest.allowedActions.length === 0
|
|
342
343
|
? {}
|
|
343
344
|
: { serverActionManifest: serverActionManifest.allowedActions }),
|
|
345
|
+
...(Object.keys(serverModuleClosureFiles).length === 0
|
|
346
|
+
? {}
|
|
347
|
+
: { serverModuleClosureFiles }),
|
|
344
348
|
...(Object.keys(serverModuleArtifacts.files).length === 0
|
|
345
349
|
? {}
|
|
346
350
|
: { serverModuleFiles: serverModuleArtifacts.files }),
|
|
@@ -559,6 +563,92 @@ function analyzeBuildSource(source, filename) {
|
|
|
559
563
|
function buildSourceAnalysisForFile(sourceAnalysis, projectRoot, file) {
|
|
560
564
|
return sourceAnalysis.byFile.get(relative(projectRoot, file).split(sep).join("/"));
|
|
561
565
|
}
|
|
566
|
+
function buildServerModuleClosureManifest(serverModules, sourceAnalysis) {
|
|
567
|
+
const sourceFiles = new Set(sourceAnalysis.byFile.keys());
|
|
568
|
+
const closureFiles = {};
|
|
569
|
+
for (const file of Object.keys(serverModules).sort()) {
|
|
570
|
+
const closure = [];
|
|
571
|
+
collectManifestServerModuleClosureFiles(file, sourceAnalysis, sourceFiles, new Set(), closure);
|
|
572
|
+
if (closure.length > 0) {
|
|
573
|
+
closureFiles[file] = closure;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
return closureFiles;
|
|
577
|
+
}
|
|
578
|
+
function collectManifestServerModuleClosureFiles(file, sourceAnalysis, sourceFiles, seen, closure) {
|
|
579
|
+
if (seen.has(file)) {
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
seen.add(file);
|
|
583
|
+
closure.push(file);
|
|
584
|
+
const source = sourceAnalysis.byFile.get(file)?.source;
|
|
585
|
+
if (source === undefined) {
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
for (const specifier of localManifestServerModuleSpecifiers(source)) {
|
|
589
|
+
const resolved = resolveManifestLocalServerSourceImport(file, specifier, sourceFiles);
|
|
590
|
+
if (resolved !== undefined) {
|
|
591
|
+
collectManifestServerModuleClosureFiles(resolved, sourceAnalysis, sourceFiles, seen, closure);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
const localManifestServerModuleImportPattern = /\b(?:import|export)\s+(?:type\s+)?(?:[^"']*?\s+from\s*)?["'](?<source>\.{1,2}\/[^"']+)["']/g;
|
|
596
|
+
function localManifestServerModuleSpecifiers(code) {
|
|
597
|
+
const specifiers = new Set();
|
|
598
|
+
localManifestServerModuleImportPattern.lastIndex = 0;
|
|
599
|
+
for (const match of code.matchAll(localManifestServerModuleImportPattern)) {
|
|
600
|
+
const source = match.groups?.source;
|
|
601
|
+
if (source !== undefined) {
|
|
602
|
+
specifiers.add(source);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
return Array.from(specifiers);
|
|
606
|
+
}
|
|
607
|
+
function resolveManifestLocalServerSourceImport(fromFile, specifier, sourceFiles) {
|
|
608
|
+
const base = resolveManifestRelativePath(manifestDirname(fromFile), specifier);
|
|
609
|
+
for (const candidate of manifestLocalServerSourceImportCandidates(base)) {
|
|
610
|
+
if (sourceFiles.has(candidate)) {
|
|
611
|
+
return candidate;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
return undefined;
|
|
615
|
+
}
|
|
616
|
+
function manifestLocalServerSourceImportCandidates(base) {
|
|
617
|
+
const candidates = [base];
|
|
618
|
+
if (base.endsWith(".js")) {
|
|
619
|
+
const withoutJs = base.slice(0, -".js".length);
|
|
620
|
+
candidates.push(`${withoutJs}.ts`, `${withoutJs}.tsx`, `${withoutJs}.mreact.tsx`);
|
|
621
|
+
}
|
|
622
|
+
else if (base.endsWith(".jsx")) {
|
|
623
|
+
const withoutJsx = base.slice(0, -".jsx".length);
|
|
624
|
+
candidates.push(`${withoutJsx}.tsx`, `${withoutJsx}.mreact.tsx`);
|
|
625
|
+
}
|
|
626
|
+
else if (base.endsWith(".mreact")) {
|
|
627
|
+
candidates.push(`${base}.tsx`);
|
|
628
|
+
}
|
|
629
|
+
else {
|
|
630
|
+
candidates.push(`${base}.ts`, `${base}.tsx`, `${base}.mreact.tsx`, `${base}/index.ts`, `${base}/index.tsx`, `${base}/index.mreact.tsx`);
|
|
631
|
+
}
|
|
632
|
+
return candidates;
|
|
633
|
+
}
|
|
634
|
+
function manifestDirname(file) {
|
|
635
|
+
const index = file.lastIndexOf("/");
|
|
636
|
+
return index === -1 ? "" : file.slice(0, index);
|
|
637
|
+
}
|
|
638
|
+
function resolveManifestRelativePath(fromDir, specifier) {
|
|
639
|
+
const segments = fromDir === "" ? [] : fromDir.split("/");
|
|
640
|
+
for (const segment of specifier.split("/")) {
|
|
641
|
+
if (segment === "" || segment === ".") {
|
|
642
|
+
continue;
|
|
643
|
+
}
|
|
644
|
+
if (segment === "..") {
|
|
645
|
+
segments.pop();
|
|
646
|
+
continue;
|
|
647
|
+
}
|
|
648
|
+
segments.push(segment);
|
|
649
|
+
}
|
|
650
|
+
return segments.join("/");
|
|
651
|
+
}
|
|
562
652
|
function canUseBuildServerActionPlaceholders(references) {
|
|
563
653
|
return references.every((reference) => reference.expression === reference.exportName &&
|
|
564
654
|
/^[A-Za-z_$][\w$]*$/u.test(reference.expression));
|