vike 0.4.237-commit-92dc549 → 0.4.237-commit-2d6f480
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/cjs/client/runtime-server-routing/utils.js +1 -1
- package/dist/cjs/node/api/build.js +4 -30
- package/dist/cjs/node/api/prepareViteApiCall.js +0 -1
- package/dist/cjs/node/prerender/runPrerender.js +5 -6
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +3 -1
- package/dist/cjs/node/runtime/renderPage/createPageContextServerSide.js +1 -1
- package/dist/cjs/node/runtime/renderPage/execHookOnRenderHtml.js +1 -11
- package/dist/cjs/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +42 -46
- package/dist/cjs/node/runtime/renderPage/{renderPageAlreadyRouted.js → renderPageAfterRoute.js} +3 -4
- package/dist/cjs/node/runtime/renderPage.js +6 -9
- package/dist/cjs/node/runtime/utils.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +3 -5
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +4 -11
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +120 -14
- package/dist/cjs/node/vite/plugins/pluginBuild.js +1 -2
- package/dist/cjs/node/vite/plugins/pluginDev/determineOptimizeDeps.js +3 -2
- package/dist/cjs/node/vite/plugins/pluginFileEnv.js +4 -3
- package/dist/cjs/node/vite/plugins/pluginPreview.js +1 -11
- package/dist/cjs/node/vite/shared/getOutDirs.js +5 -11
- package/dist/cjs/node/vite/shared/isViteServerSide.js +46 -19
- package/dist/cjs/shared/page-configs/{loadPageEntry.js → loadAndParseVirtualFilePageEntry.js} +2 -2
- package/dist/cjs/shared/page-configs/resolveVikeConfigPublic.js +5 -0
- package/dist/cjs/shared/route/execHookOnBeforeRoute.js +0 -1
- package/dist/cjs/shared/route/index.js +0 -1
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/{augmentType.js → updateType.js} +3 -3
- package/dist/esm/__internal/index.d.ts +1 -1
- package/dist/esm/client/runtime-client-routing/createPageContextClientSide.js +2 -2
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.js +6 -6
- package/dist/esm/client/runtime-client-routing/utils.d.ts +1 -1
- package/dist/esm/client/runtime-client-routing/utils.js +1 -1
- package/dist/esm/client/runtime-server-routing/createPageContextClientSide.js +3 -3
- package/dist/esm/client/runtime-server-routing/utils.d.ts +1 -1
- package/dist/esm/client/runtime-server-routing/utils.js +1 -1
- package/dist/esm/client/shared/loadPageConfigsLazyClientSide.js +2 -2
- package/dist/esm/node/api/build.js +5 -31
- package/dist/esm/node/api/prepareViteApiCall.d.ts +0 -2
- package/dist/esm/node/api/prepareViteApiCall.js +0 -1
- package/dist/esm/node/prerender/runPrerender.d.ts +9 -300
- package/dist/esm/node/prerender/runPrerender.js +6 -7
- package/dist/esm/node/runtime/renderPage/analyzePage.d.ts +4 -3
- package/dist/esm/node/runtime/renderPage/analyzePage.js +3 -1
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.js +2 -2
- package/dist/esm/node/runtime/renderPage/execHookOnRenderHtml.d.ts +0 -1
- package/dist/esm/node/runtime/renderPage/execHookOnRenderHtml.js +1 -11
- package/dist/esm/node/runtime/renderPage/getPageAssets.d.ts +2 -4
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.d.ts +105 -19
- package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +44 -48
- package/dist/esm/node/runtime/renderPage/{renderPageAlreadyRouted.d.ts → renderPageAfterRoute.d.ts} +20 -4
- package/dist/esm/node/runtime/renderPage/{renderPageAlreadyRouted.js → renderPageAfterRoute.js} +5 -6
- package/dist/esm/node/runtime/renderPage.js +8 -11
- package/dist/esm/node/runtime/utils.d.ts +1 -1
- package/dist/esm/node/runtime/utils.js +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.d.ts +0 -1
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.js +5 -7
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildApp.js +3 -10
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.d.ts +4 -0
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.js +120 -17
- package/dist/esm/node/vite/plugins/pluginBuild.js +1 -2
- package/dist/esm/node/vite/plugins/pluginDev/determineOptimizeDeps.js +3 -2
- package/dist/esm/node/vite/plugins/pluginFileEnv.js +4 -3
- package/dist/esm/node/vite/plugins/pluginPreview.js +3 -13
- package/dist/esm/node/vite/shared/getOutDirs.d.ts +1 -3
- package/dist/esm/node/vite/shared/getOutDirs.js +6 -12
- package/dist/esm/node/vite/shared/isViteServerSide.d.ts +1 -1
- package/dist/esm/node/vite/shared/isViteServerSide.js +46 -19
- package/dist/esm/shared/page-configs/loadAndParseVirtualFilePageEntry.d.ts +3 -0
- package/dist/esm/shared/page-configs/{loadPageEntry.js → loadAndParseVirtualFilePageEntry.js} +2 -2
- package/dist/esm/shared/page-configs/resolveVikeConfigPublic.js +5 -0
- package/dist/esm/shared/route/execHookOnBeforeRoute.d.ts +3 -3
- package/dist/esm/shared/route/execHookOnBeforeRoute.js +0 -1
- package/dist/esm/shared/route/index.d.ts +5 -6
- package/dist/esm/shared/route/index.js +0 -1
- package/dist/esm/types/Config.d.ts +2 -4
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/updateType.d.ts +3 -0
- package/dist/esm/utils/updateType.js +7 -0
- package/package.json +3 -3
- package/dist/cjs/node/runtime/renderPage/debugPageFiles.js +0 -52
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginAutoFullBuild.js +0 -150
- package/dist/esm/node/runtime/renderPage/debugPageFiles.d.ts +0 -23
- package/dist/esm/node/runtime/renderPage/debugPageFiles.js +0 -47
- package/dist/esm/node/vite/plugins/pluginBuild/pluginAutoFullBuild.d.ts +0 -5
- package/dist/esm/node/vite/plugins/pluginBuild/pluginAutoFullBuild.js +0 -145
- package/dist/esm/shared/page-configs/loadPageEntry.d.ts +0 -3
- package/dist/esm/utils/augmentType.d.ts +0 -3
- package/dist/esm/utils/augmentType.js +0 -7
|
@@ -1,34 +1,120 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { loadPageConfigsLazyServerSide };
|
|
2
2
|
export type { PageContext_loadPageConfigsLazyServerSide };
|
|
3
3
|
export type { PageConfigsLazy };
|
|
4
4
|
import { type VikeConfigPublicPageLazyLoaded } from '../../../shared/getPageFiles.js';
|
|
5
5
|
import { PromiseType } from '../utils.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import type { GlobalContextServerInternal } from '../globalContext.js';
|
|
9
|
-
import { type PageContextExecHookServer } from './execHookServer.js';
|
|
6
|
+
import { type PageAsset } from './getPageAssets.js';
|
|
7
|
+
import type { PageConfigRuntime } from '../../../types/PageConfig.js';
|
|
10
8
|
import type { PassToClient } from '../html/serializeContext.js';
|
|
11
|
-
type
|
|
12
|
-
type
|
|
9
|
+
import type { PageContextAfterRoute } from '../../../shared/route/index.js';
|
|
10
|
+
import type { PageContextCreated } from './createPageContextServerSide.js';
|
|
11
|
+
type PageContext_loadPageConfigsLazyServerSide = PageContextCreated & PageContextAfterRoute & {
|
|
12
|
+
is404: boolean | null;
|
|
13
13
|
pageId: string;
|
|
14
|
-
urlOriginal: string;
|
|
15
|
-
_globalContext: GlobalContextServerInternal;
|
|
16
14
|
};
|
|
17
15
|
type PageConfigsLazy = PromiseType<ReturnType<typeof loadPageConfigsLazyServerSide>>;
|
|
18
|
-
declare function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
declare function loadPageConfigsLazyServerSide(pageContext: PageContext_loadPageConfigsLazyServerSide): Promise<{
|
|
17
|
+
_isOriginalObject: true;
|
|
18
|
+
isPageContext: true;
|
|
19
|
+
} & {
|
|
20
|
+
isClientSide: false;
|
|
21
|
+
isPrerendering: boolean;
|
|
22
|
+
} & Pick<import("../../../types/PageContext.js").PageContextInternalServer, "urlOriginal" | "headersOriginal"> & {
|
|
23
|
+
url?: string;
|
|
24
|
+
headers?: Record<string, string>;
|
|
25
|
+
} & {
|
|
26
|
+
_globalContext: {
|
|
27
|
+
isGlobalContext: true;
|
|
28
|
+
_isOriginalObject: true;
|
|
29
|
+
_virtualFileExportsGlobalEntry: unknown;
|
|
30
|
+
_pageFilesAll: import("../../../shared/getPageFiles.js").PageFile[];
|
|
31
|
+
_pageConfigs: PageConfigRuntime[];
|
|
32
|
+
_pageConfigGlobal: import("../../../types/PageConfig.js").PageConfigGlobalRuntime;
|
|
33
|
+
_allPageIds: string[];
|
|
34
|
+
_vikeConfigPublicGlobal: {
|
|
35
|
+
config: import("../../../types/index.js").ConfigResolved;
|
|
36
|
+
_source: import("../../../shared/page-configs/resolveVikeConfigPublic.js").Source;
|
|
37
|
+
_sources: import("../../../shared/page-configs/resolveVikeConfigPublic.js").Sources;
|
|
38
|
+
_from: import("../../../shared/page-configs/resolveVikeConfigPublic.js").From;
|
|
39
|
+
};
|
|
40
|
+
config: import("../../../types/index.js").ConfigResolved;
|
|
41
|
+
pages: {
|
|
42
|
+
[k: string]: import("../../../shared/page-configs/resolveVikeConfigPublic.js").VikeConfigPublicPageEagerLoaded;
|
|
43
|
+
};
|
|
44
|
+
} & (({
|
|
45
|
+
_isProduction: false;
|
|
46
|
+
_isPrerendering: false;
|
|
47
|
+
assetsManifest: null;
|
|
48
|
+
_viteDevServer: import("vite").ViteDevServer | undefined;
|
|
49
|
+
viteConfig: import("vite").ResolvedConfig | undefined;
|
|
50
|
+
isClientSide: false;
|
|
51
|
+
_pageRoutes: import("../../../shared/route/loadPageRoutes.js").PageRoutes;
|
|
52
|
+
_onBeforeRouteHook: import("../../../shared/hooks/getHook.js").Hook | null;
|
|
53
|
+
} | {
|
|
54
|
+
_isPrerendering: true;
|
|
55
|
+
viteConfig: import("vite").ResolvedConfig;
|
|
56
|
+
_isProduction: true;
|
|
57
|
+
assetsManifest: import("../../../types/ViteManifest.js").ViteManifest;
|
|
58
|
+
_viteDevServer: null;
|
|
59
|
+
_usesClientRouter: boolean;
|
|
60
|
+
isClientSide: false;
|
|
61
|
+
_pageRoutes: import("../../../shared/route/loadPageRoutes.js").PageRoutes;
|
|
62
|
+
_onBeforeRouteHook: import("../../../shared/hooks/getHook.js").Hook | null;
|
|
63
|
+
} | {
|
|
64
|
+
_isPrerendering: false;
|
|
65
|
+
viteConfig: null;
|
|
66
|
+
_isProduction: true;
|
|
67
|
+
assetsManifest: import("../../../types/ViteManifest.js").ViteManifest;
|
|
68
|
+
_viteDevServer: null;
|
|
69
|
+
_usesClientRouter: boolean;
|
|
70
|
+
isClientSide: false;
|
|
71
|
+
_pageRoutes: import("../../../shared/route/loadPageRoutes.js").PageRoutes;
|
|
72
|
+
_onBeforeRouteHook: import("../../../shared/hooks/getHook.js").Hook | null;
|
|
73
|
+
}) & {
|
|
74
|
+
baseServer: string;
|
|
75
|
+
baseAssets: string;
|
|
76
|
+
viteConfigRuntime: {
|
|
77
|
+
root: string;
|
|
78
|
+
build: {
|
|
79
|
+
outDir: string;
|
|
80
|
+
};
|
|
81
|
+
_baseViteOriginal: string;
|
|
82
|
+
vitePluginServerEntry: {
|
|
83
|
+
inject: boolean | undefined;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
_pageFilesAll: import("../../../shared/getPageFiles.js").PageFile[];
|
|
88
|
+
_baseServer: string;
|
|
89
|
+
_baseAssets: string;
|
|
90
|
+
_pageContextInit: import("../renderPage.js").PageContextInit;
|
|
91
|
+
_urlRewrite: null;
|
|
92
|
+
_urlHandler: ((url: string) => string) | null;
|
|
93
|
+
isClientSideNavigation: boolean;
|
|
94
|
+
} & {
|
|
95
|
+
config: import("../../../types/index.js").ConfigResolved;
|
|
96
|
+
_source: import("../../../shared/page-configs/resolveVikeConfigPublic.js").Source;
|
|
97
|
+
_sources: import("../../../shared/page-configs/resolveVikeConfigPublic.js").Sources;
|
|
98
|
+
_from: import("../../../shared/page-configs/resolveVikeConfigPublic.js").From;
|
|
99
|
+
} & {
|
|
100
|
+
urlParsed: import("../utils.js").UrlPublic;
|
|
101
|
+
urlPathname: string;
|
|
102
|
+
url: string;
|
|
103
|
+
} & {
|
|
104
|
+
headers: Record<string, string> | null;
|
|
105
|
+
} & PageContextAfterRoute & {
|
|
106
|
+
is404: boolean | null;
|
|
107
|
+
pageId: string;
|
|
108
|
+
} & {
|
|
109
|
+
_pageConfig: PageConfigRuntime | null;
|
|
110
|
+
} & {
|
|
111
|
+
_pageConfig: null | PageConfigRuntime;
|
|
112
|
+
} & VikeConfigPublicPageLazyLoaded & {
|
|
113
|
+
_pageConfig: null | PageConfigRuntime;
|
|
24
114
|
} & {
|
|
25
|
-
__getPageAssets: () => Promise<PageAsset[]>;
|
|
26
|
-
}>;
|
|
27
|
-
declare function loadPageConfigsLazyServerSide(pageContext: PageContext_loadPageConfigsLazyServerSide): Promise<VikeConfigPublicPageLazyLoaded & {
|
|
28
115
|
Page: unknown;
|
|
29
116
|
_isHtmlOnly: boolean;
|
|
30
117
|
_passToClient: PassToClient;
|
|
31
|
-
_pageFilePathsLoaded: string[];
|
|
32
118
|
headersResponse: Headers;
|
|
33
119
|
} & {
|
|
34
120
|
__getPageAssets: () => Promise<PageAsset[]>;
|
|
@@ -1,43 +1,39 @@
|
|
|
1
|
-
export {
|
|
2
|
-
import { getPageFilesServerSide
|
|
1
|
+
export { loadPageConfigsLazyServerSide };
|
|
2
|
+
import { getPageFilesServerSide } from '../../../shared/getPageFiles.js';
|
|
3
3
|
import { resolveVikeConfigPublicPageLazyLoaded } from '../../../shared/page-configs/resolveVikeConfigPublic.js';
|
|
4
4
|
import { analyzePageClientSideInit } from '../../../shared/getPageFiles/analyzePageClientSide.js';
|
|
5
|
-
import { assertUsage, assertWarning, hasProp, isArray, isObject, objectAssign } from '../utils.js';
|
|
5
|
+
import { assertUsage, assertWarning, hasProp, isArray, isObject, objectAssign, updateType, } from '../utils.js';
|
|
6
6
|
import { getPageAssets } from './getPageAssets.js';
|
|
7
|
-
import { debugPageFiles } from './debugPageFiles.js';
|
|
8
7
|
import { findPageConfig } from '../../../shared/page-configs/findPageConfig.js';
|
|
9
8
|
import { analyzePage } from './analyzePage.js';
|
|
10
|
-
import {
|
|
9
|
+
import { loadAndParseVirtualFilePageEntry } from '../../../shared/page-configs/loadAndParseVirtualFilePageEntry.js';
|
|
11
10
|
import { execHookServer } from './execHookServer.js';
|
|
12
11
|
import { getCacheControl } from './getCacheControl.js';
|
|
13
|
-
async function
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
async function loadPageConfigsLazyServerSide(pageContext) {
|
|
13
|
+
objectAssign(pageContext, {
|
|
14
|
+
_pageConfig: findPageConfig(pageContext._globalContext._pageConfigs, pageContext.pageId),
|
|
15
|
+
});
|
|
16
|
+
// Load the page's + files
|
|
17
|
+
updateType(pageContext, await loadPageUserFiles(pageContext));
|
|
18
|
+
// Resolve new computed pageContext properties
|
|
19
|
+
updateType(pageContext, await resolvePageContext(pageContext));
|
|
20
|
+
// Execute +onCreatePageContext
|
|
16
21
|
await execHookServer('onCreatePageContext', pageContext);
|
|
17
22
|
return pageContext;
|
|
18
23
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const pageConfig = findPageConfig(pageContext._globalContext._pageConfigs, pageContext.pageId); // Make pageConfig globally available as pageContext._pageConfig ?
|
|
22
|
-
const globalContext = pageContext._globalContext;
|
|
23
|
-
const [{ pageFilesLoaded, configPublicPageLazy }] = await Promise.all([
|
|
24
|
-
loadPageConfigFiles(pageContext._globalContext._pageFilesAll, pageConfig, globalContext._pageConfigGlobal, pageContext.pageId, !globalContext._isProduction),
|
|
25
|
-
analyzePageClientSideInit(pageContext._globalContext._pageFilesAll, pageContext.pageId, {
|
|
26
|
-
sharedPageFilesAlreadyLoaded: true,
|
|
27
|
-
}),
|
|
28
|
-
]);
|
|
29
|
-
const { isHtmlOnly, isClientRouting, clientEntries, clientDependencies, pageFilesClientSide, pageFilesServerSide } = await analyzePage(pageContext._globalContext._pageFilesAll, pageConfig, pageContext.pageId, globalContext);
|
|
30
|
-
const isV1Design = !!pageConfig;
|
|
24
|
+
async function resolvePageContext(pageContext) {
|
|
25
|
+
const { isHtmlOnly, clientEntries, clientDependencies } = analyzePage(pageContext);
|
|
31
26
|
const passToClient = [];
|
|
32
27
|
const errMsgSuffix = ' should be an array of strings.';
|
|
28
|
+
const isV1Design = !!pageContext._pageConfig;
|
|
33
29
|
if (!isV1Design) {
|
|
34
|
-
|
|
30
|
+
pageContext.exportsAll.passToClient?.forEach((e) => {
|
|
35
31
|
assertUsage(hasProp(e, 'exportValue', 'string[]'), `${e.exportSource}${errMsgSuffix}`);
|
|
36
32
|
passToClient.push(...e.exportValue);
|
|
37
33
|
});
|
|
38
34
|
}
|
|
39
35
|
else {
|
|
40
|
-
|
|
36
|
+
pageContext.from.configsCumulative.passToClient?.values.forEach((v) => {
|
|
41
37
|
const { value, definedAt } = v;
|
|
42
38
|
const errMsg = `+passToClient value defined at ${definedAt}${errMsgSuffix}`;
|
|
43
39
|
//*/ TO-DO/next-major-release: remove the passToClient once setting from the public API
|
|
@@ -57,16 +53,13 @@ async function loadPageConfigsLazyServerSide(pageContext) {
|
|
|
57
53
|
passToClient.push(...valS);
|
|
58
54
|
});
|
|
59
55
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
objectAssign(pageContextAddendum, {
|
|
63
|
-
Page: configPublicPageLazy.exports.Page,
|
|
56
|
+
objectAssign(pageContext, {
|
|
57
|
+
Page: pageContext.exports.Page,
|
|
64
58
|
_isHtmlOnly: isHtmlOnly,
|
|
65
59
|
_passToClient: passToClient,
|
|
66
|
-
|
|
67
|
-
headersResponse: resolveHeadersResponse(pageContext, pageContextAddendum),
|
|
60
|
+
headersResponse: resolveHeadersResponse(pageContext),
|
|
68
61
|
});
|
|
69
|
-
objectAssign(
|
|
62
|
+
objectAssign(pageContext, {
|
|
70
63
|
__getPageAssets: async () => {
|
|
71
64
|
if ('_pageAssets' in pageContext) {
|
|
72
65
|
return pageContext._pageAssets;
|
|
@@ -79,14 +72,14 @@ async function loadPageConfigsLazyServerSide(pageContext) {
|
|
|
79
72
|
},
|
|
80
73
|
});
|
|
81
74
|
// TO-DO/next-major-release: remove
|
|
82
|
-
Object.assign(
|
|
75
|
+
Object.assign(pageContext, {
|
|
83
76
|
_getPageAssets: async () => {
|
|
84
77
|
assertWarning(false, 'pageContext._getPageAssets() deprecated, see https://vike.dev/preloading', {
|
|
85
78
|
onlyOnce: true,
|
|
86
79
|
showStackTrace: true,
|
|
87
80
|
});
|
|
88
81
|
const pageAssetsOldFormat = [];
|
|
89
|
-
(await
|
|
82
|
+
(await pageContext.__getPageAssets()).forEach((p) => {
|
|
90
83
|
if (p.assetType === 'script' && p.isEntry) {
|
|
91
84
|
pageAssetsOldFormat.push({
|
|
92
85
|
src: p.src,
|
|
@@ -105,30 +98,33 @@ async function loadPageConfigsLazyServerSide(pageContext) {
|
|
|
105
98
|
return pageAssetsOldFormat;
|
|
106
99
|
},
|
|
107
100
|
});
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return
|
|
101
|
+
return pageContext;
|
|
102
|
+
}
|
|
103
|
+
async function loadPageUserFiles(pageContext) {
|
|
104
|
+
const [{ configPublicPageLazy }] = await Promise.all([
|
|
105
|
+
loadPageUserFiles_v1Design(pageContext),
|
|
106
|
+
analyzePageClientSideInit(pageContext._globalContext._pageFilesAll, pageContext.pageId, {
|
|
107
|
+
sharedPageFilesAlreadyLoaded: true,
|
|
108
|
+
}),
|
|
109
|
+
]);
|
|
110
|
+
objectAssign(pageContext, configPublicPageLazy);
|
|
111
|
+
return pageContext;
|
|
119
112
|
}
|
|
120
|
-
async function
|
|
121
|
-
const pageFilesServerSide = getPageFilesServerSide(
|
|
122
|
-
const
|
|
113
|
+
async function loadPageUserFiles_v1Design(pageContext) {
|
|
114
|
+
const pageFilesServerSide = getPageFilesServerSide(pageContext._pageFilesAll, pageContext.pageId);
|
|
115
|
+
const isDev = !pageContext._globalContext._isProduction;
|
|
116
|
+
const pageConfigLoaded = !pageContext._pageConfig
|
|
117
|
+
? null
|
|
118
|
+
: await loadAndParseVirtualFilePageEntry(pageContext._pageConfig, isDev);
|
|
123
119
|
await Promise.all(pageFilesServerSide.map((p) => p.loadFile?.()));
|
|
124
|
-
const configPublicPageLazy = resolveVikeConfigPublicPageLazyLoaded(pageFilesServerSide, pageConfigLoaded,
|
|
120
|
+
const configPublicPageLazy = resolveVikeConfigPublicPageLazyLoaded(pageFilesServerSide, pageConfigLoaded, pageContext._globalContext._pageConfigGlobal);
|
|
125
121
|
return {
|
|
126
122
|
configPublicPageLazy,
|
|
127
123
|
pageFilesLoaded: pageFilesServerSide,
|
|
128
124
|
};
|
|
129
125
|
}
|
|
130
|
-
function resolveHeadersResponse(pageContext
|
|
131
|
-
const headersResponse = mergeHeaders(
|
|
126
|
+
function resolveHeadersResponse(pageContext) {
|
|
127
|
+
const headersResponse = mergeHeaders(pageContext.config.headersResponse);
|
|
132
128
|
if (!headersResponse.get('Cache-Control')) {
|
|
133
129
|
const cacheControl = getCacheControl(pageContext.pageId, pageContext._globalContext._pageConfigs);
|
|
134
130
|
if (cacheControl)
|
package/dist/esm/node/runtime/renderPage/{renderPageAlreadyRouted.d.ts → renderPageAfterRoute.d.ts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { renderPageAfterRoute };
|
|
2
2
|
export { prerenderPage };
|
|
3
3
|
export type { PageContextAfterRender };
|
|
4
4
|
import { type PageContextUrlInternal } from '../../../shared/getPageContextUrlComputed.js';
|
|
@@ -10,7 +10,7 @@ type PageContextAfterRender = {
|
|
|
10
10
|
httpResponse: HttpResponse;
|
|
11
11
|
errorWhileRendering: null | Error;
|
|
12
12
|
};
|
|
13
|
-
declare function
|
|
13
|
+
declare function renderPageAfterRoute<PageContext extends {
|
|
14
14
|
pageId: string;
|
|
15
15
|
_pageContextAlreadyProvidedByOnPrerenderHook?: true;
|
|
16
16
|
is404: null | boolean;
|
|
@@ -118,11 +118,19 @@ declare function prerenderPage(pageContext: PageContextCreated & PageConfigsLazy
|
|
|
118
118
|
url: string;
|
|
119
119
|
} & {
|
|
120
120
|
headers: Record<string, string> | null;
|
|
121
|
+
} & import("../../../shared/route/index.js").PageContextAfterRoute & {
|
|
122
|
+
is404: boolean | null;
|
|
123
|
+
pageId: string;
|
|
124
|
+
} & {
|
|
125
|
+
_pageConfig: import("../../../types/PageConfig.js").PageConfigRuntime | null;
|
|
126
|
+
} & {
|
|
127
|
+
_pageConfig: null | import("../../../types/PageConfig.js").PageConfigRuntime;
|
|
121
128
|
} & import("../../../shared/getPageFiles.js").VikeConfigPublicPageLazyLoaded & {
|
|
129
|
+
_pageConfig: null | import("../../../types/PageConfig.js").PageConfigRuntime;
|
|
130
|
+
} & {
|
|
122
131
|
Page: unknown;
|
|
123
132
|
_isHtmlOnly: boolean;
|
|
124
133
|
_passToClient: import("../html/serializeContext.js").PassToClient;
|
|
125
|
-
_pageFilePathsLoaded: string[];
|
|
126
134
|
headersResponse: Headers;
|
|
127
135
|
} & {
|
|
128
136
|
__getPageAssets: () => Promise<import("./getPageAssets.js").PageAsset[]>;
|
|
@@ -229,11 +237,19 @@ declare function prerenderPage(pageContext: PageContextCreated & PageConfigsLazy
|
|
|
229
237
|
url: string;
|
|
230
238
|
} & {
|
|
231
239
|
headers: Record<string, string> | null;
|
|
240
|
+
} & import("../../../shared/route/index.js").PageContextAfterRoute & {
|
|
241
|
+
is404: boolean | null;
|
|
242
|
+
pageId: string;
|
|
243
|
+
} & {
|
|
244
|
+
_pageConfig: import("../../../types/PageConfig.js").PageConfigRuntime | null;
|
|
245
|
+
} & {
|
|
246
|
+
_pageConfig: null | import("../../../types/PageConfig.js").PageConfigRuntime;
|
|
232
247
|
} & import("../../../shared/getPageFiles.js").VikeConfigPublicPageLazyLoaded & {
|
|
248
|
+
_pageConfig: null | import("../../../types/PageConfig.js").PageConfigRuntime;
|
|
249
|
+
} & {
|
|
233
250
|
Page: unknown;
|
|
234
251
|
_isHtmlOnly: boolean;
|
|
235
252
|
_passToClient: import("../html/serializeContext.js").PassToClient;
|
|
236
|
-
_pageFilePathsLoaded: string[];
|
|
237
253
|
headersResponse: Headers;
|
|
238
254
|
} & {
|
|
239
255
|
__getPageAssets: () => Promise<import("./getPageAssets.js").PageAsset[]>;
|
package/dist/esm/node/runtime/renderPage/{renderPageAlreadyRouted.js → renderPageAfterRoute.js}
RENAMED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { renderPageAfterRoute };
|
|
2
2
|
export { prerenderPage };
|
|
3
3
|
import { getErrorPageId } from '../../../shared/error-page.js';
|
|
4
4
|
import { getHtmlString } from '../html/renderHtml.js';
|
|
5
|
-
import { assert, assertUsage,
|
|
5
|
+
import { assert, assertUsage, updateType, hasProp, objectAssign } from '../utils.js';
|
|
6
6
|
import { getPageContextClientSerialized } from '../html/serializeContext.js';
|
|
7
7
|
import { createHttpResponsePage, createHttpResponsePageContextJson } from './createHttpResponse.js';
|
|
8
|
-
import {
|
|
8
|
+
import { loadPageConfigsLazyServerSide, } from './loadPageConfigsLazyServerSide.js';
|
|
9
9
|
import { execHookOnRenderHtml } from './execHookOnRenderHtml.js';
|
|
10
10
|
import { execHookDataAndOnBeforeRender } from './execHookDataAndOnBeforeRender.js';
|
|
11
11
|
import { logRuntimeError } from '../loggerRuntime.js';
|
|
@@ -14,8 +14,7 @@ import { preparePageContextForPublicUsageServer } from './preparePageContextForP
|
|
|
14
14
|
import { execHookGuard } from '../../../shared/route/execHookGuard.js';
|
|
15
15
|
import pc from '@brillout/picocolors';
|
|
16
16
|
import { isServerSideError } from '../../../shared/misc/isServerSideError.js';
|
|
17
|
-
|
|
18
|
-
async function renderPageAlreadyRouted(pageContext) {
|
|
17
|
+
async function renderPageAfterRoute(pageContext) {
|
|
19
18
|
// pageContext.pageId can either be the:
|
|
20
19
|
// - ID of the page matching the routing, or the
|
|
21
20
|
// - ID of the error page `_error.page.js`.
|
|
@@ -24,7 +23,7 @@ async function renderPageAlreadyRouted(pageContext) {
|
|
|
24
23
|
assert(isError ===
|
|
25
24
|
(pageContext.pageId ===
|
|
26
25
|
getErrorPageId(pageContext._globalContext._pageFilesAll, pageContext._globalContext._pageConfigs)));
|
|
27
|
-
|
|
26
|
+
updateType(pageContext, await loadPageConfigsLazyServerSide(pageContext));
|
|
28
27
|
if (!isError) {
|
|
29
28
|
await execHookGuard(pageContext, (pageContext) => preparePageContextForPublicUsageServer(pageContext));
|
|
30
29
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { renderPage };
|
|
2
2
|
export { renderPage_addAsyncHookwrapper };
|
|
3
|
-
import {
|
|
3
|
+
import { renderPageAfterRoute } from './renderPage/renderPageAfterRoute.js';
|
|
4
4
|
import { createPageContextServerSide, createPageContextServerSideWithoutGlobalContext, } from './renderPage/createPageContextServerSide.js';
|
|
5
5
|
import { route } from '../../shared/route/index.js';
|
|
6
|
-
import { assert, hasProp, objectAssign, isUrl, parseUrl, onSetupRuntime, assertWarning, getGlobalObject, checkType, assertUsage, normalizeUrlPathname, removeBaseServer, modifyUrlPathname, prependBase, removeUrlOrigin, setUrlOrigin, isUri, getUrlPretty,
|
|
6
|
+
import { assert, hasProp, objectAssign, isUrl, parseUrl, onSetupRuntime, assertWarning, getGlobalObject, checkType, assertUsage, normalizeUrlPathname, removeBaseServer, modifyUrlPathname, prependBase, removeUrlOrigin, setUrlOrigin, isUri, getUrlPretty, updateType, } from './utils.js';
|
|
7
7
|
import { assertNoInfiniteAbortLoop, getPageContextFromAllRewrites, isAbortError, logAbortErrorHandled, } from '../../shared/route/abort.js';
|
|
8
8
|
import { getGlobalContextServerInternal, initGlobalContext_renderPage, } from './globalContext.js';
|
|
9
9
|
import { handlePageContextRequestUrl } from './renderPage/handlePageContextRequestUrl.js';
|
|
@@ -16,7 +16,7 @@ import pc from '@brillout/picocolors';
|
|
|
16
16
|
import { getPageContextClientSerializedAbort, getPageContextClientSerialized } from './html/serializeContext.js';
|
|
17
17
|
import { getErrorPageId } from '../../shared/error-page.js';
|
|
18
18
|
import { handleErrorWithoutErrorPage } from './renderPage/handleErrorWithoutErrorPage.js';
|
|
19
|
-
import {
|
|
19
|
+
import { loadPageConfigsLazyServerSide } from './renderPage/loadPageConfigsLazyServerSide.js';
|
|
20
20
|
import { resolveRedirects } from './renderPage/resolveRedirects.js';
|
|
21
21
|
import { getVikeConfigError } from '../shared/getVikeConfigError.js';
|
|
22
22
|
const globalObject = getGlobalObject('runtime/renderPage.ts', {
|
|
@@ -153,7 +153,7 @@ async function renderPageAlreadyPrepared(pageContextBegin, globalContext, httpRe
|
|
|
153
153
|
async function renderPageOnError(errNominalPage, pageContextBegin, pageContextNominalPageBegin, globalContext, httpRequestId, pageContextsFromRewrite) {
|
|
154
154
|
assert(pageContextNominalPageBegin);
|
|
155
155
|
assert(hasProp(pageContextNominalPageBegin, 'urlOriginal', 'string'));
|
|
156
|
-
const pageContextErrorPageInit = await getPageContextErrorPageInit(pageContextBegin, errNominalPage
|
|
156
|
+
const pageContextErrorPageInit = await getPageContextErrorPageInit(pageContextBegin, errNominalPage);
|
|
157
157
|
// Handle `throw redirect()` and `throw render()` while rendering nominal page
|
|
158
158
|
if (isAbortError(errNominalPage)) {
|
|
159
159
|
const handled = await handleAbortError(errNominalPage, pageContextsFromRewrite, pageContextBegin, pageContextNominalPageBegin, httpRequestId, pageContextErrorPageInit, globalContext);
|
|
@@ -178,7 +178,7 @@ async function renderPageOnError(errNominalPage, pageContextBegin, pageContextNo
|
|
|
178
178
|
}
|
|
179
179
|
let pageContextErrorPage;
|
|
180
180
|
try {
|
|
181
|
-
pageContextErrorPage = await
|
|
181
|
+
pageContextErrorPage = await renderPageAfterRoute(pageContextErrorPageInit);
|
|
182
182
|
}
|
|
183
183
|
catch (errErrorPage) {
|
|
184
184
|
// Handle `throw redirect()` and `throw render()` while rendering error page
|
|
@@ -293,11 +293,11 @@ async function renderPageNominal(pageContext) {
|
|
|
293
293
|
assert(hasProp(pageContext, 'pageId', 'string'));
|
|
294
294
|
assert(pageContext.errorWhileRendering === null);
|
|
295
295
|
// Render
|
|
296
|
-
const pageContextAfterRender = await
|
|
296
|
+
const pageContextAfterRender = await renderPageAfterRoute(pageContext);
|
|
297
297
|
assert(pageContext === pageContextAfterRender);
|
|
298
298
|
return pageContextAfterRender;
|
|
299
299
|
}
|
|
300
|
-
async function getPageContextErrorPageInit(pageContextBegin, errNominalPage
|
|
300
|
+
async function getPageContextErrorPageInit(pageContextBegin, errNominalPage) {
|
|
301
301
|
const pageContext = forkPageContext(pageContextBegin);
|
|
302
302
|
assert(errNominalPage);
|
|
303
303
|
objectAssign(pageContext, {
|
|
@@ -305,9 +305,6 @@ async function getPageContextErrorPageInit(pageContextBegin, errNominalPage, pag
|
|
|
305
305
|
errorWhileRendering: errNominalPage,
|
|
306
306
|
routeParams: {},
|
|
307
307
|
});
|
|
308
|
-
objectAssign(pageContext, {
|
|
309
|
-
_debugRouteMatches: pageContextNominalPagePartial._debugRouteMatches || 'ROUTING_ERROR',
|
|
310
|
-
});
|
|
311
308
|
assert(pageContext.errorWhileRendering);
|
|
312
309
|
return pageContext;
|
|
313
310
|
}
|
|
@@ -423,7 +420,7 @@ pageContextNominalPageBegin, httpRequestId, pageContextErrorPageInit, globalCont
|
|
|
423
420
|
objectAssign(pageContext, { pageId: errorPageId });
|
|
424
421
|
objectAssign(pageContext, pageContextAbort);
|
|
425
422
|
objectAssign(pageContext, pageContextErrorPageInit, true);
|
|
426
|
-
|
|
423
|
+
updateType(pageContext, await loadPageConfigsLazyServerSide(pageContext));
|
|
427
424
|
// We include pageContextInit: we don't only serialize pageContextAbort because the error page may need to access pageContextInit
|
|
428
425
|
pageContextSerialized = getPageContextClientSerialized(pageContext, false);
|
|
429
426
|
}
|
|
@@ -55,7 +55,7 @@ export * from '../../utils/isVikeReactApp.js';
|
|
|
55
55
|
export * from '../../utils/getPropAccessNotation.js';
|
|
56
56
|
export * from '../../utils/PROJECT_VERSION.js';
|
|
57
57
|
export * from '../../utils/genPromise.js';
|
|
58
|
-
export * from '../../utils/
|
|
58
|
+
export * from '../../utils/updateType.js';
|
|
59
59
|
export * from '../../utils/changeEnumerable.js';
|
|
60
60
|
export * from '../../utils/getViteRPC.js';
|
|
61
61
|
export * from '../../utils/isRunnableDevEnvironment.js';
|
|
@@ -59,7 +59,7 @@ export * from '../../utils/isVikeReactApp.js';
|
|
|
59
59
|
export * from '../../utils/getPropAccessNotation.js';
|
|
60
60
|
export * from '../../utils/PROJECT_VERSION.js';
|
|
61
61
|
export * from '../../utils/genPromise.js';
|
|
62
|
-
export * from '../../utils/
|
|
62
|
+
export * from '../../utils/updateType.js';
|
|
63
63
|
export * from '../../utils/changeEnumerable.js';
|
|
64
64
|
export * from '../../utils/getViteRPC.js';
|
|
65
65
|
export * from '../../utils/isRunnableDevEnvironment.js';
|
|
@@ -12,7 +12,6 @@ declare function handleAssetsManifest_getBuildConfig(config: UserConfig): Promis
|
|
|
12
12
|
readonly ssrEmitAssets: true | undefined;
|
|
13
13
|
readonly cssMinify: "esbuild" | undefined;
|
|
14
14
|
readonly manifest: true;
|
|
15
|
-
readonly copyPublicDir: boolean | undefined;
|
|
16
15
|
}>;
|
|
17
16
|
declare function handleAssetsManifest(config: ResolvedConfig, viteEnv: Environment, options: {
|
|
18
17
|
dir: string | undefined;
|
|
@@ -11,9 +11,9 @@ import { assert, assertWarning, getGlobalObject, isEqualStringList, isObject, pL
|
|
|
11
11
|
import { parseVirtualFileId } from '../../../shared/virtualFileId.js';
|
|
12
12
|
import { getAssetsDir } from '../../shared/getAssetsDir.js';
|
|
13
13
|
import pc from '@brillout/picocolors';
|
|
14
|
-
import {
|
|
14
|
+
import { isV1Design } from '../../shared/resolveVikeConfigInternal.js';
|
|
15
15
|
import { getOutDirs } from '../../shared/getOutDirs.js';
|
|
16
|
-
import { isViteServerSide_onlySsrEnv, isViteServerSide
|
|
16
|
+
import { isViteServerSide_onlySsrEnv, isViteServerSide } from '../../shared/isViteServerSide.js';
|
|
17
17
|
import { set_macro_ASSETS_MANIFEST } from './pluginBuildEntry.js';
|
|
18
18
|
import { getManifestFilePathRelative } from '../../shared/getManifestFilePathRelative.js';
|
|
19
19
|
const globalObject = getGlobalObject('build/handleAssetsManifest.ts', {
|
|
@@ -280,7 +280,6 @@ async function writeManifestFile(manifest, manifestFilePath) {
|
|
|
280
280
|
await fs.writeFile(manifestFilePath, manifestFileContent, 'utf-8');
|
|
281
281
|
}
|
|
282
282
|
async function handleAssetsManifest_getBuildConfig(config) {
|
|
283
|
-
const vikeConfig = await getVikeConfigInternal();
|
|
284
283
|
const isFixEnabled = handleAssetsManifest_isFixEnabled(config);
|
|
285
284
|
return {
|
|
286
285
|
// https://github.com/vikejs/vike/issues/1339
|
|
@@ -288,10 +287,9 @@ async function handleAssetsManifest_getBuildConfig(config) {
|
|
|
288
287
|
// Required if `ssrEmitAssets: true`, see https://github.com/vitejs/vite/pull/11430#issuecomment-1454800934
|
|
289
288
|
cssMinify: isFixEnabled ? 'esbuild' : undefined,
|
|
290
289
|
manifest: true,
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
: !isViteServerSide_withoutEnv(config),
|
|
290
|
+
/* Already set by vike:build:pluginBuildApp
|
|
291
|
+
copyPublicDir: !isViteServerSide_withoutEnv(config),
|
|
292
|
+
*/
|
|
295
293
|
};
|
|
296
294
|
}
|
|
297
295
|
async function handleAssetsManifest(config, viteEnv, options, bundle) {
|
|
@@ -2,8 +2,7 @@ export { pluginBuildApp };
|
|
|
2
2
|
import { runPrerender_forceExit } from '../../../prerender/runPrerenderEntry.js';
|
|
3
3
|
import { resolveOutDir } from '../../shared/getOutDirs.js';
|
|
4
4
|
import { assert } from '../../utils.js';
|
|
5
|
-
import { isPrerenderForceExit } from './
|
|
6
|
-
import { getVikeConfigInternal } from '../../shared/resolveVikeConfigInternal.js';
|
|
5
|
+
import { isPrerenderForceExit } from './pluginBuildConfig.js';
|
|
7
6
|
function pluginBuildApp() {
|
|
8
7
|
return [
|
|
9
8
|
{
|
|
@@ -12,10 +11,7 @@ function pluginBuildApp() {
|
|
|
12
11
|
enforce: 'pre',
|
|
13
12
|
config: {
|
|
14
13
|
order: 'pre',
|
|
15
|
-
|
|
16
|
-
const vikeConfig = await getVikeConfigInternal();
|
|
17
|
-
if (!vikeConfig.config.vite6BuilderApp)
|
|
18
|
-
return;
|
|
14
|
+
handler(_config) {
|
|
19
15
|
return {
|
|
20
16
|
builder: {
|
|
21
17
|
// Can be overridden by another plugin e.g vike-vercel https://github.com/vikejs/vike/pull/2184#issuecomment-2659425195
|
|
@@ -37,10 +33,7 @@ function pluginBuildApp() {
|
|
|
37
33
|
{
|
|
38
34
|
name: 'vike:build:pluginBuildApp',
|
|
39
35
|
apply: 'build',
|
|
40
|
-
|
|
41
|
-
const vikeConfig = await getVikeConfigInternal();
|
|
42
|
-
if (!vikeConfig.config.vite6BuilderApp)
|
|
43
|
-
return;
|
|
36
|
+
config(config) {
|
|
44
37
|
return {
|
|
45
38
|
environments: {
|
|
46
39
|
ssr: {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { pluginBuildConfig };
|
|
2
2
|
export { assertRollupInput };
|
|
3
3
|
export { analyzeClientEntries };
|
|
4
|
+
export { pluginAutoFullBuild };
|
|
5
|
+
export { isPrerenderForceExit };
|
|
4
6
|
import type { ResolvedConfig, Plugin } from 'vite';
|
|
5
7
|
import type { PageConfigBuildTime } from '../../../../types/PageConfig.js';
|
|
6
8
|
declare function pluginBuildConfig(): Plugin[];
|
|
@@ -10,3 +12,5 @@ declare function analyzeClientEntries(pageConfigs: PageConfigBuildTime[], config
|
|
|
10
12
|
clientEntries: Record<string, string>;
|
|
11
13
|
};
|
|
12
14
|
declare function assertRollupInput(config: ResolvedConfig): void;
|
|
15
|
+
declare function pluginAutoFullBuild(): Plugin[];
|
|
16
|
+
declare function isPrerenderForceExit(): boolean;
|