evolit 0.1.0-alpha.6 → 0.1.0-alpha.8
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/package.json +1 -1
- package/src/build.js +6 -2
- package/src/client-assets.js +22 -0
- package/src/deployment-runtime.js +6 -2
package/package.json
CHANGED
package/src/build.js
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
emitBundledClientAssets,
|
|
16
16
|
emitHashedClientAssets,
|
|
17
17
|
normalizeHydrationDataForClient,
|
|
18
|
+
resolveRouteClientImports,
|
|
18
19
|
resolveSharedVendorModuleUrl,
|
|
19
20
|
rewriteHydrationDataScript,
|
|
20
21
|
rewriteServerAssetPlaceholders,
|
|
@@ -241,8 +242,11 @@ export async function buildProject(projectRoot) {
|
|
|
241
242
|
);
|
|
242
243
|
const ssrAdapter = createSsrAdapter({
|
|
243
244
|
assetResolver,
|
|
244
|
-
async resolveAdditionalHead({ result }) {
|
|
245
|
-
const clientImports =
|
|
245
|
+
async resolveAdditionalHead({ routeResult, result }) {
|
|
246
|
+
const clientImports = [
|
|
247
|
+
...(Array.isArray(result.clientImports) ? result.clientImports : []),
|
|
248
|
+
...resolveRouteClientImports(routeResult, projectRoot, clientAssets),
|
|
249
|
+
];
|
|
246
250
|
const urls = collectTransitiveAssetPreloads(clientImports, clientAssets);
|
|
247
251
|
const styleUrls = collectTransitiveStyleUrls(clientImports, clientAssets);
|
|
248
252
|
|
package/src/client-assets.js
CHANGED
|
@@ -1776,6 +1776,28 @@ export function collectTransitiveAssetPreloads(publicUrls, assetManifest) {
|
|
|
1776
1776
|
return discovered;
|
|
1777
1777
|
}
|
|
1778
1778
|
|
|
1779
|
+
export function resolveRouteClientImports(routeResult, projectRoot, assetManifest) {
|
|
1780
|
+
const normalizedManifest = normalizeClientAssetManifest(assetManifest);
|
|
1781
|
+
if (!normalizedManifest) {
|
|
1782
|
+
return [];
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
const routeModules = [
|
|
1786
|
+
routeResult?.route?.page,
|
|
1787
|
+
...(routeResult?.route?.layouts ?? []),
|
|
1788
|
+
routeResult?.boundaryModule,
|
|
1789
|
+
].filter((modulePath) => typeof modulePath === "string");
|
|
1790
|
+
|
|
1791
|
+
return [...new Set(routeModules.map((modulePath) => {
|
|
1792
|
+
const relativePath = path.relative(projectRoot, modulePath).split(path.sep).join("/");
|
|
1793
|
+
const extension = path.extname(relativePath);
|
|
1794
|
+
const clientModule = extension
|
|
1795
|
+
? `${relativePath.slice(0, -extension.length)}.mjs`
|
|
1796
|
+
: `${relativePath}.mjs`;
|
|
1797
|
+
return normalizedManifest.byClientModule[clientModule] ?? null;
|
|
1798
|
+
}).filter((publicUrl) => typeof publicUrl === "string"))];
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1779
1801
|
export function collectTransitiveStyleUrls(publicUrls, assetManifest) {
|
|
1780
1802
|
const normalizedManifest = normalizeClientAssetManifest(assetManifest);
|
|
1781
1803
|
if (!normalizedManifest) {
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
getSharedOutputRoot,
|
|
13
13
|
normalizeHydrationDataForClient,
|
|
14
14
|
normalizeClientAssetManifest,
|
|
15
|
+
resolveRouteClientImports,
|
|
15
16
|
resolveSharedVendorModuleUrl,
|
|
16
17
|
resolveBrowserPackageAssetFilePath,
|
|
17
18
|
rewriteHydrationDataScript,
|
|
@@ -233,8 +234,11 @@ export async function createRequestRenderer({ projectRoot, mode, assetManifest,
|
|
|
233
234
|
assetResolver(moduleId) {
|
|
234
235
|
return currentAssetResolver(moduleId);
|
|
235
236
|
},
|
|
236
|
-
async resolveAdditionalHead({ result }) {
|
|
237
|
-
const clientImports =
|
|
237
|
+
async resolveAdditionalHead({ routeResult, result }) {
|
|
238
|
+
const clientImports = [
|
|
239
|
+
...(Array.isArray(result.clientImports) ? result.clientImports : []),
|
|
240
|
+
...resolveRouteClientImports(routeResult, projectRoot, currentAssetManifest),
|
|
241
|
+
];
|
|
238
242
|
const urls = currentAssetManifest
|
|
239
243
|
? collectTransitiveAssetPreloads(clientImports, currentAssetManifest)
|
|
240
244
|
: [];
|