@reckona/mreact-router 0.0.120 → 0.0.121
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/build.d.ts +1 -0
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +64 -45
- package/dist/build.js.map +1 -1
- package/dist/client.d.ts +1 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +15 -1
- package/dist/client.js.map +1 -1
- package/dist/module-runner.js +14 -6
- package/dist/module-runner.js.map +1 -1
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +19 -2
- package/dist/render.js.map +1 -1
- package/package.json +11 -11
- package/src/build.ts +478 -370
- package/src/client.ts +34 -11
- package/src/module-runner.ts +26 -11
- package/src/render.ts +20 -2
package/dist/build.d.ts
CHANGED
|
@@ -97,6 +97,7 @@ export interface BuiltRouteSourceAnalysisSummary {
|
|
|
97
97
|
authIncludesClaims: boolean;
|
|
98
98
|
cachePolicy?: RouteCachePolicy | undefined;
|
|
99
99
|
clientBoundaryImports: readonly string[];
|
|
100
|
+
clientBoundaryFallbackImports: readonly string[];
|
|
100
101
|
clientRoute: boolean;
|
|
101
102
|
hasLoader: boolean;
|
|
102
103
|
routeCode: string;
|
package/dist/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAwCA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAwCA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAGL,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EAG1B,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,g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E,CAAC;IACjD,YAAY,CAAC,EAAE,qBAAqB,GAAG,SAAS,CAAC;IACjD,WAAW,CAAC,EAAE,SAAS,YAAY,EAAE,GAAG,SAAS,CAAC;CACnD,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAUlC;AA0ID,UAAU,4BAA4B;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,QAAQ,GAAG,UAAU,CAAC;CAC9B;AA61CD,wBAAsB,+CAA+C,CAAC,OAAO,EAAE;IAC7E,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,MAAM,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,SAAS;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACzD,WAAW,CAAC,EAAE,SAAS,YAAY,EAAE,GAAG,SAAS,CAAC;CACnD,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAYlC;AA28BD,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,yBAAyB,CAAC,CA4CpC;AA6DD,wBAAsB,8BAA8B,CAClD,OAAO,EAAE,qCAAqC,GAC7C,OAAO,CAAC,+BAA+B,CAAC,CAsD1C"}
|
package/dist/build.js
CHANGED
|
@@ -10,7 +10,7 @@ import { compilerModuleContextForSource, collectClientRouteReferences, createCli
|
|
|
10
10
|
import { buildClientRouteBatchOutput, buildNavigationRuntimeBundle, clientScriptForPath, routeIdForPath, } from "./navigation-runtime.js";
|
|
11
11
|
import { bundleAppRouterSourceModule, fileImportMetaUrlPlugin, importAppRouterSourceModule, } from "./module-runner.js";
|
|
12
12
|
import { scanAppRoutes } from "./routes.js";
|
|
13
|
-
import { appFileConventionForRootFilename
|
|
13
|
+
import { appFileConventionForRootFilename } from "./file-conventions.js";
|
|
14
14
|
import { resolveAppRouterProjectOptions, resolveBuildTargets, } from "./config.js";
|
|
15
15
|
import { routeCachePolicyFromSource } from "./cache.js";
|
|
16
16
|
import { bundleMiddlewareModuleCode, renderAppRequest } from "./render.js";
|
|
@@ -416,6 +416,7 @@ async function analyzeBuildRouteSources(options) {
|
|
|
416
416
|
{
|
|
417
417
|
...analyzeBuildSource(source, route.file),
|
|
418
418
|
clientBoundaryImports: clientInference.clientBoundaryImports,
|
|
419
|
+
clientBoundaryFallbackImports: clientInference.clientBoundaryFallbackImports,
|
|
419
420
|
clientRoute: clientInference.client,
|
|
420
421
|
file,
|
|
421
422
|
route,
|
|
@@ -784,7 +785,9 @@ async function findRuntimePackageJson(packageName, startDir) {
|
|
|
784
785
|
}
|
|
785
786
|
}
|
|
786
787
|
function isRuntimePackageSpecifier(specifier) {
|
|
787
|
-
if (specifier.startsWith(".") ||
|
|
788
|
+
if (specifier.startsWith(".") ||
|
|
789
|
+
specifier.startsWith("/") ||
|
|
790
|
+
/^[A-Za-z][A-Za-z0-9+.-]*:/.test(specifier)) {
|
|
788
791
|
return false;
|
|
789
792
|
}
|
|
790
793
|
const packageName = runtimePackageNameForSpecifier(specifier);
|
|
@@ -867,7 +870,9 @@ function isSourceModuleFile(file) {
|
|
|
867
870
|
return /\.(?:mreact\.tsx|tsx?|jsx?|mjs|mts|cjs|cts)$/.test(file);
|
|
868
871
|
}
|
|
869
872
|
function isAppRelativeFile(file, relativeRoutesDir) {
|
|
870
|
-
return relativeRoutesDir === "" ||
|
|
873
|
+
return (relativeRoutesDir === "" ||
|
|
874
|
+
file === relativeRoutesDir ||
|
|
875
|
+
file.startsWith(`${relativeRoutesDir}/`));
|
|
871
876
|
}
|
|
872
877
|
function moduleIdForBuildFile(file, relativeRoutesDir) {
|
|
873
878
|
return relativeRoutesDir === "" ? file : file.slice(relativeRoutesDir.length + 1);
|
|
@@ -921,9 +926,7 @@ async function copyAppFileConventionAssets(appDir, outDir) {
|
|
|
921
926
|
if (convention === undefined || convention.kind !== "asset") {
|
|
922
927
|
continue;
|
|
923
928
|
}
|
|
924
|
-
const outputPath = convention.path.startsWith("/")
|
|
925
|
-
? convention.path.slice(1)
|
|
926
|
-
: convention.path;
|
|
929
|
+
const outputPath = convention.path.startsWith("/") ? convention.path.slice(1) : convention.path;
|
|
927
930
|
await copyFile(join(appDir, entry.name), join(outDir, outputPath));
|
|
928
931
|
paths.push(convention.path);
|
|
929
932
|
}
|
|
@@ -1113,7 +1116,7 @@ async function buildServerModuleArtifacts(options) {
|
|
|
1113
1116
|
metadataArtifactFiles.has(file)) {
|
|
1114
1117
|
if (loaderArtifactFiles.has(file)) {
|
|
1115
1118
|
const code = requestBatchOutputs.get(routeRequestArtifactBatchKey(file, "loader")) ??
|
|
1116
|
-
await bundleRouteLoaderModuleCode({
|
|
1119
|
+
(await bundleRouteLoaderModuleCode({
|
|
1117
1120
|
appDir: options.project.routesDir,
|
|
1118
1121
|
bundleCache: options.bundleCache,
|
|
1119
1122
|
cacheDir: options.cacheDir,
|
|
@@ -1121,7 +1124,7 @@ async function buildServerModuleArtifacts(options) {
|
|
|
1121
1124
|
filename: absoluteFile,
|
|
1122
1125
|
importPolicy: requestModuleImportPolicy,
|
|
1123
1126
|
vitePlugins: options.vitePlugins,
|
|
1124
|
-
});
|
|
1127
|
+
}));
|
|
1125
1128
|
artifact.loader = {
|
|
1126
1129
|
code,
|
|
1127
1130
|
sourceHash: hashText(source),
|
|
@@ -1129,7 +1132,7 @@ async function buildServerModuleArtifacts(options) {
|
|
|
1129
1132
|
}
|
|
1130
1133
|
if (metadataArtifactFiles.has(file)) {
|
|
1131
1134
|
const code = requestBatchOutputs.get(routeRequestArtifactBatchKey(file, "metadata")) ??
|
|
1132
|
-
await bundleRouteRequestModuleCode({
|
|
1135
|
+
(await bundleRouteRequestModuleCode({
|
|
1133
1136
|
appDir: options.project.routesDir,
|
|
1134
1137
|
bundleCache: options.bundleCache,
|
|
1135
1138
|
cacheDir: options.cacheDir,
|
|
@@ -1138,7 +1141,7 @@ async function buildServerModuleArtifacts(options) {
|
|
|
1138
1141
|
importPolicy: requestModuleImportPolicy,
|
|
1139
1142
|
label: "Metadata",
|
|
1140
1143
|
vitePlugins: options.vitePlugins,
|
|
1141
|
-
});
|
|
1144
|
+
}));
|
|
1142
1145
|
artifact.routeMetadata = {
|
|
1143
1146
|
code,
|
|
1144
1147
|
sourceHash: hashText(source),
|
|
@@ -1148,7 +1151,7 @@ async function buildServerModuleArtifacts(options) {
|
|
|
1148
1151
|
const batchedRequestCode = requestBatchOutputs.get(routeRequestArtifactBatchKey(file, "request"));
|
|
1149
1152
|
artifact.request = {
|
|
1150
1153
|
code: batchedRequestCode ??
|
|
1151
|
-
await buildRequestModuleArtifactCode({
|
|
1154
|
+
(await buildRequestModuleArtifactCode({
|
|
1152
1155
|
appDir: options.project.routesDir,
|
|
1153
1156
|
bundleCache: options.bundleCache,
|
|
1154
1157
|
cacheDir: options.cacheDir,
|
|
@@ -1157,7 +1160,7 @@ async function buildServerModuleArtifacts(options) {
|
|
|
1157
1160
|
routeKind: route?.kind,
|
|
1158
1161
|
source,
|
|
1159
1162
|
vitePlugins: options.vitePlugins,
|
|
1160
|
-
}),
|
|
1163
|
+
})),
|
|
1161
1164
|
sourceHash: hashText(source),
|
|
1162
1165
|
};
|
|
1163
1166
|
}
|
|
@@ -1190,8 +1193,9 @@ async function buildServerModuleArtifacts(options) {
|
|
|
1190
1193
|
vitePlugins: options.vitePlugins,
|
|
1191
1194
|
})
|
|
1192
1195
|
: undefined;
|
|
1193
|
-
const clientBoundaryImports = routeAnalysis?.clientBoundaryImports ??
|
|
1194
|
-
|
|
1196
|
+
const clientBoundaryImports = routeAnalysis?.clientBoundaryImports ?? clientInference?.clientBoundaryImports ?? [];
|
|
1197
|
+
const clientBoundaryFallbackImports = routeAnalysis?.clientBoundaryFallbackImports ??
|
|
1198
|
+
clientInference?.clientBoundaryFallbackImports ??
|
|
1195
1199
|
[];
|
|
1196
1200
|
for (const diagnostic of clientInference?.diagnostics ?? []) {
|
|
1197
1201
|
console.warn(formatClientRouteInferenceDiagnostic(diagnostic));
|
|
@@ -1206,6 +1210,7 @@ async function buildServerModuleArtifacts(options) {
|
|
|
1206
1210
|
cache: options.serverTransformCache,
|
|
1207
1211
|
code,
|
|
1208
1212
|
clientBoundaryImports,
|
|
1213
|
+
clientBoundaryFallbackImports,
|
|
1209
1214
|
filename: join(options.projectRoot, file),
|
|
1210
1215
|
moduleContextCache: options.clientRouteInferenceCache,
|
|
1211
1216
|
serverOutput,
|
|
@@ -1284,6 +1289,7 @@ async function buildServerComponentBundleArtifactCode(options) {
|
|
|
1284
1289
|
async function transformServerRouteSource(options) {
|
|
1285
1290
|
const cacheKey = stableCacheKey({
|
|
1286
1291
|
clientBoundaryImports: options.clientBoundaryImports,
|
|
1292
|
+
clientBoundaryFallbackImports: options.clientBoundaryFallbackImports ?? [],
|
|
1287
1293
|
codeHash: hashText(options.code),
|
|
1288
1294
|
filename: resolve(options.filename),
|
|
1289
1295
|
serverOutput: options.serverOutput,
|
|
@@ -1302,6 +1308,7 @@ async function transformServerRouteSource(options) {
|
|
|
1302
1308
|
return transformCompilerModuleContext({
|
|
1303
1309
|
code: options.code,
|
|
1304
1310
|
clientBoundaryImports: options.clientBoundaryImports,
|
|
1311
|
+
clientBoundaryFallbackImports: options.clientBoundaryFallbackImports ?? [],
|
|
1305
1312
|
dev: false,
|
|
1306
1313
|
filename: options.filename,
|
|
1307
1314
|
moduleContext,
|
|
@@ -1316,8 +1323,11 @@ async function transformServerRouteSource(options) {
|
|
|
1316
1323
|
function builtRouteSourceAnalysisSummary(options) {
|
|
1317
1324
|
return {
|
|
1318
1325
|
authIncludesClaims: options.analysis.authIncludesClaims,
|
|
1319
|
-
...(options.analysis.cachePolicy === undefined
|
|
1326
|
+
...(options.analysis.cachePolicy === undefined
|
|
1327
|
+
? {}
|
|
1328
|
+
: { cachePolicy: options.analysis.cachePolicy }),
|
|
1320
1329
|
clientBoundaryImports: options.analysis.clientBoundaryImports,
|
|
1330
|
+
clientBoundaryFallbackImports: options.analysis.clientBoundaryFallbackImports,
|
|
1321
1331
|
clientRoute: options.analysis.clientRoute,
|
|
1322
1332
|
hasLoader: options.analysis.hasLoader,
|
|
1323
1333
|
routeCode: options.analysis.routeCode,
|
|
@@ -1536,9 +1546,9 @@ function isMiddlewareFile(appDir, file) {
|
|
|
1536
1546
|
return file === join(appDir, "middleware.ts") || file === join(appDir, "middleware.mreact.ts");
|
|
1537
1547
|
}
|
|
1538
1548
|
function hasMetadataExport(code) {
|
|
1539
|
-
return /\bexport\s+const\s+metadata\s*=/.test(code) ||
|
|
1549
|
+
return (/\bexport\s+const\s+metadata\s*=/.test(code) ||
|
|
1540
1550
|
/\bexport\s+(?:async\s+)?function\s+generateMetadata\b/.test(code) ||
|
|
1541
|
-
/\bexport\s*\{[^}]*\bgenerateMetadata\b[^}]*\}/.test(code);
|
|
1551
|
+
/\bexport\s*\{[^}]*\bgenerateMetadata\b[^}]*\}/.test(code));
|
|
1542
1552
|
}
|
|
1543
1553
|
async function readDeclaredProjectPackages(projectRoot) {
|
|
1544
1554
|
try {
|
|
@@ -1563,11 +1573,13 @@ async function writeCloudflareRouteModules(options) {
|
|
|
1563
1573
|
const analysis = options.sourceAnalysis.byFile.get(routeFile);
|
|
1564
1574
|
return analysis === undefined
|
|
1565
1575
|
? []
|
|
1566
|
-
: [
|
|
1576
|
+
: [
|
|
1577
|
+
{
|
|
1567
1578
|
route,
|
|
1568
1579
|
routeFile,
|
|
1569
1580
|
routeId: routeIdForPath(route.path),
|
|
1570
|
-
}
|
|
1581
|
+
},
|
|
1582
|
+
];
|
|
1571
1583
|
}));
|
|
1572
1584
|
await mkdir(routesDir, { recursive: true });
|
|
1573
1585
|
const serverRouteModules = await buildCloudflareServerRouteModuleBatch({
|
|
@@ -1583,7 +1595,8 @@ async function writeCloudflareRouteModules(options) {
|
|
|
1583
1595
|
cacheDir: options.cacheDir,
|
|
1584
1596
|
define: options.define,
|
|
1585
1597
|
routes: requiredRoutes
|
|
1586
|
-
.filter(({ route, routeFile }) => route.kind === "page" &&
|
|
1598
|
+
.filter(({ route, routeFile }) => route.kind === "page" &&
|
|
1599
|
+
options.sourceAnalysis.byRouteFile.get(routeFile)?.hasLoader === true)
|
|
1587
1600
|
.map(({ route, routeId }) => ({ filename: route.file, routeId })),
|
|
1588
1601
|
root: options.projectRoot,
|
|
1589
1602
|
vitePlugins: options.vitePlugins,
|
|
@@ -1690,9 +1703,7 @@ async function writeCloudflareRouteModules(options) {
|
|
|
1690
1703
|
throw new Error("Missing bundled Cloudflare component module.");
|
|
1691
1704
|
}
|
|
1692
1705
|
const componentImport = `./${componentFile.split("/").pop() ?? componentFile}`;
|
|
1693
|
-
routeModuleExports = [
|
|
1694
|
-
cloudflarePageRouteFacadeModuleSource(componentImport),
|
|
1695
|
-
];
|
|
1706
|
+
routeModuleExports = [cloudflarePageRouteFacadeModuleSource(componentImport)];
|
|
1696
1707
|
}
|
|
1697
1708
|
catch (error) {
|
|
1698
1709
|
throw new Error(`Failed to build Cloudflare route module for ${routeFile}: ${errorMessage(error)}`);
|
|
@@ -2073,9 +2084,7 @@ async function buildCloudflareServerComponentModule(options) {
|
|
|
2073
2084
|
filename: `${options.filename}.mreact-cloudflare-component.js`,
|
|
2074
2085
|
cacheDir: options.cacheDir,
|
|
2075
2086
|
define: options.define,
|
|
2076
|
-
modules: metadataModule === undefined
|
|
2077
|
-
? new Map()
|
|
2078
|
-
: new Map([["mreact:metadata", metadataModule]]),
|
|
2087
|
+
modules: metadataModule === undefined ? new Map() : new Map([["mreact:metadata", metadataModule]]),
|
|
2079
2088
|
plugins: [
|
|
2080
2089
|
cloudflareServerSourceTransformPlugin({
|
|
2081
2090
|
projectRoot: options.projectRoot,
|
|
@@ -2627,9 +2636,7 @@ export const slots = routeModule.slots;`;
|
|
|
2627
2636
|
cacheDir: options.cacheDir,
|
|
2628
2637
|
define: options.define,
|
|
2629
2638
|
filename: `${options.filename}.mreact-cloudflare-${options.serverOutput}-component.js`,
|
|
2630
|
-
modules: metadataModule === undefined
|
|
2631
|
-
? new Map()
|
|
2632
|
-
: new Map([["mreact:metadata", metadataModule]]),
|
|
2639
|
+
modules: metadataModule === undefined ? new Map() : new Map([["mreact:metadata", metadataModule]]),
|
|
2633
2640
|
plugins: [
|
|
2634
2641
|
cloudflareServerSourceTransformPlugin({
|
|
2635
2642
|
projectRoot: options.projectRoot,
|
|
@@ -2891,6 +2898,7 @@ async function transformCloudflareServerSource(options) {
|
|
|
2891
2898
|
const output = transformCompilerModuleContext({
|
|
2892
2899
|
code: options.source,
|
|
2893
2900
|
clientBoundaryImports: clientInference.clientBoundaryImports,
|
|
2901
|
+
clientBoundaryFallbackImports: clientInference.clientBoundaryFallbackImports,
|
|
2894
2902
|
dev: false,
|
|
2895
2903
|
filename: options.filename,
|
|
2896
2904
|
moduleContext,
|
|
@@ -2900,7 +2908,9 @@ async function transformCloudflareServerSource(options) {
|
|
|
2900
2908
|
});
|
|
2901
2909
|
const fatalDiagnostics = output.diagnostics.filter((diagnostic) => diagnostic.code !== "MR_UNSUPPORTED_SERVER_EVENT_HANDLER");
|
|
2902
2910
|
if (fatalDiagnostics.length > 0) {
|
|
2903
|
-
throw new Error(fatalDiagnostics
|
|
2911
|
+
throw new Error(fatalDiagnostics
|
|
2912
|
+
.map((diagnostic) => formatDiagnostic(options.filename, diagnostic))
|
|
2913
|
+
.join("\n"));
|
|
2904
2914
|
}
|
|
2905
2915
|
return output.code;
|
|
2906
2916
|
}
|
|
@@ -2932,9 +2942,18 @@ function cloudflareWorkspaceRuntimePlugin() {
|
|
|
2932
2942
|
"@reckona/mreact-compat/event-priority",
|
|
2933
2943
|
packageFile("react-compat", "@reckona/mreact-compat", "event-priority"),
|
|
2934
2944
|
],
|
|
2935
|
-
[
|
|
2936
|
-
|
|
2937
|
-
|
|
2945
|
+
[
|
|
2946
|
+
"@reckona/mreact-compat/flight",
|
|
2947
|
+
packageFile("react-compat", "@reckona/mreact-compat", "flight"),
|
|
2948
|
+
],
|
|
2949
|
+
[
|
|
2950
|
+
"@reckona/mreact-compat/hooks",
|
|
2951
|
+
packageFile("react-compat", "@reckona/mreact-compat", "hooks-entry"),
|
|
2952
|
+
],
|
|
2953
|
+
[
|
|
2954
|
+
"@reckona/mreact-compat/internal",
|
|
2955
|
+
packageFile("react-compat", "@reckona/mreact-compat", "internal"),
|
|
2956
|
+
],
|
|
2938
2957
|
[
|
|
2939
2958
|
"@reckona/mreact-compat/jsx-dev-runtime",
|
|
2940
2959
|
packageFile("react-compat", "@reckona/mreact-compat", "jsx-dev-runtime"),
|
|
@@ -2943,9 +2962,15 @@ function cloudflareWorkspaceRuntimePlugin() {
|
|
|
2943
2962
|
"@reckona/mreact-compat/jsx-runtime",
|
|
2944
2963
|
packageFile("react-compat", "@reckona/mreact-compat", "jsx-runtime"),
|
|
2945
2964
|
],
|
|
2946
|
-
[
|
|
2965
|
+
[
|
|
2966
|
+
"@reckona/mreact-compat/scheduler",
|
|
2967
|
+
packageFile("react-compat", "@reckona/mreact-compat", "scheduler"),
|
|
2968
|
+
],
|
|
2947
2969
|
["@reckona/mreact-query", packageFile("query", "@reckona/mreact-query", "index")],
|
|
2948
|
-
[
|
|
2970
|
+
[
|
|
2971
|
+
"@reckona/mreact-reactive-core",
|
|
2972
|
+
packageFile("reactive-core", "@reckona/mreact-reactive-core", "index"),
|
|
2973
|
+
],
|
|
2949
2974
|
[
|
|
2950
2975
|
"@reckona/mreact-router/adapters/cloudflare",
|
|
2951
2976
|
packageFile("router", "@reckona/mreact-router", "adapters/cloudflare"),
|
|
@@ -3155,9 +3180,7 @@ async function writeClientRouteBundles(options) {
|
|
|
3155
3180
|
await writeFile(join(mapBaseDir, sourceMap), map);
|
|
3156
3181
|
}
|
|
3157
3182
|
for (const asset of output.assets ?? []) {
|
|
3158
|
-
const source = typeof asset.source === "string"
|
|
3159
|
-
? asset.source
|
|
3160
|
-
: Buffer.from(asset.source).toString("utf8");
|
|
3183
|
+
const source = typeof asset.source === "string" ? asset.source : Buffer.from(asset.source).toString("utf8");
|
|
3161
3184
|
await mkdir(dirname(join(options.clientDir, asset.fileName)), { recursive: true });
|
|
3162
3185
|
await writeFile(join(options.clientDir, asset.fileName), source);
|
|
3163
3186
|
}
|
|
@@ -3276,9 +3299,7 @@ async function writeRouteCssAssetsForFiles(options) {
|
|
|
3276
3299
|
? (options.routeIds[0] ?? "index")
|
|
3277
3300
|
: `shared.${hashText(cssFiles.join("\0")).slice(0, 8)}`;
|
|
3278
3301
|
for (const [index, asset] of cssAssets.entries()) {
|
|
3279
|
-
const source = typeof asset.source === "string"
|
|
3280
|
-
? asset.source
|
|
3281
|
-
: Buffer.from(asset.source).toString("utf8");
|
|
3302
|
+
const source = typeof asset.source === "string" ? asset.source : Buffer.from(asset.source).toString("utf8");
|
|
3282
3303
|
const hash = createHash("sha256").update(source).digest("hex").slice(0, 8);
|
|
3283
3304
|
const cssFile = `assets/routes/${routeStem}${cssAssets.length === 1 ? "" : `.${index}`}.${hash}.css`;
|
|
3284
3305
|
await mkdir(dirname(join(options.clientDir, cssFile)), { recursive: true });
|
|
@@ -3552,6 +3573,7 @@ async function validateProductionRoutes(options) {
|
|
|
3552
3573
|
cache: options.serverTransformCache,
|
|
3553
3574
|
code: analysis.routeCode,
|
|
3554
3575
|
clientBoundaryImports: analysis.clientBoundaryImports,
|
|
3576
|
+
clientBoundaryFallbackImports: analysis.clientBoundaryFallbackImports,
|
|
3555
3577
|
filename: route.file,
|
|
3556
3578
|
moduleContextCache: options.clientRouteInferenceCache,
|
|
3557
3579
|
serverOutput: analysis.streamRoute ? "stream" : "string",
|
|
@@ -3576,10 +3598,7 @@ async function collectBuildFiles(projectRoot, allowedSourceDirs, appDir) {
|
|
|
3576
3598
|
}
|
|
3577
3599
|
return [{ file, relativeFile }];
|
|
3578
3600
|
});
|
|
3579
|
-
const fileContents = await mapWithBuildConcurrency(sourceFiles, async ({ file, relativeFile }) => [
|
|
3580
|
-
relativeFile,
|
|
3581
|
-
await readFile(file, "utf8"),
|
|
3582
|
-
]);
|
|
3601
|
+
const fileContents = await mapWithBuildConcurrency(sourceFiles, async ({ file, relativeFile }) => [relativeFile, await readFile(file, "utf8")]);
|
|
3583
3602
|
for (const [relativeFile, source] of fileContents) {
|
|
3584
3603
|
files[relativeFile] = source;
|
|
3585
3604
|
}
|