vike 0.4.235 → 0.4.236-commit-64431e7
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/__internal/index.js +1 -1
- package/dist/cjs/client/shared/createGetGlobalContextClient.js +2 -3
- package/dist/cjs/client/shared/preparePageContextForPublicUsageClientShared.js +4 -4
- package/dist/cjs/node/api/prepareViteApiCall.js +1 -1
- package/dist/cjs/node/cli/index.js +1 -1
- package/dist/cjs/node/createPageRenderer.js +1 -1
- package/dist/cjs/node/importBuild.js +1 -1
- package/dist/cjs/node/prerender/context.js +1 -1
- package/dist/cjs/node/prerender/index.js +1 -1
- package/dist/cjs/node/prerender/resolvePrerenderConfig.js +2 -2
- package/dist/cjs/node/prerender/runPrerender.js +9 -13
- package/dist/cjs/node/runtime/globalContext.js +109 -28
- package/dist/cjs/node/runtime/html/injectAssets/getViteDevScript.js +8 -1
- package/dist/cjs/node/runtime/html/injectAssets/injectAssets__public.js +1 -1
- package/dist/cjs/node/runtime/html/injectAssets/injectHtmlTags.js +2 -0
- package/dist/cjs/node/runtime/html/serializeContext.js +73 -15
- package/dist/cjs/node/runtime/index-deprecated.js +1 -1
- package/dist/cjs/node/runtime/index.js +1 -1
- package/dist/cjs/node/runtime/page-files/setup.js +1 -1
- package/dist/cjs/node/runtime/renderPage/assertArguments.js +1 -1
- package/dist/cjs/node/runtime/renderPage/createHttpResponse.js +9 -6
- package/dist/cjs/node/runtime/renderPage/createPageContextServerSide.js +4 -4
- package/dist/cjs/node/runtime/renderPage/execHookDataAndOnBeforeRender.js +2 -2
- package/dist/cjs/node/runtime/renderPage/{createHttpResponse/getCacheControl.js → getCacheControl.js} +9 -9
- package/dist/cjs/node/runtime/renderPage/getHttpResponseBody.js +4 -4
- package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +1 -1
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +15 -12
- package/dist/cjs/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +35 -16
- package/dist/cjs/node/runtime/renderPage/preparePageContextForPublicUsageServer.js +1 -1
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +1 -0
- package/dist/cjs/node/runtime/renderPage.js +4 -6
- package/dist/cjs/node/runtime/utils.js +1 -0
- package/dist/cjs/node/vite/index.js +2 -0
- package/dist/cjs/node/vite/onLoad.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +3 -3
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +3 -2
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildEntry.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistFileNames.js +16 -7
- package/dist/cjs/node/vite/plugins/pluginCommon/assertResolveAlias.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginCommon.js +9 -4
- package/dist/cjs/node/vite/plugins/pluginDev.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginEnvVars.js +4 -4
- package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +2 -2
- package/dist/cjs/node/vite/plugins/pluginFileEnv.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginViteRPC.js +42 -0
- package/dist/cjs/node/vite/shared/addSsrMiddleware.js +1 -1
- package/dist/cjs/node/vite/shared/applyRegExWithMagicString.js +1 -0
- package/dist/cjs/node/vite/shared/loggerNotProd.js +10 -6
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +5 -1
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +1 -3
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/filesystemRouting.js +4 -6
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/transpileAndExecuteFile.js +1 -1
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal.js +6 -6
- package/dist/cjs/shared/RenderErrorPage.js +1 -1
- package/dist/cjs/shared/abort.js +1 -1
- package/dist/cjs/shared/createGlobalContextShared.js +28 -7
- package/dist/cjs/shared/createPageContextShared.js +1 -2
- package/dist/cjs/shared/determinePageIdOld.js +1 -1
- package/dist/cjs/shared/error-page.js +3 -3
- package/dist/cjs/shared/getPageContextUrlComputed.js +4 -4
- package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +1 -1
- package/dist/cjs/shared/getPageFiles/analyzePageClientSide/analyzeExports.js +1 -1
- package/dist/cjs/shared/getPageFiles/analyzePageClientSide/determineClientEntry.js +1 -1
- package/dist/cjs/shared/getPageFiles/analyzePageClientSide.js +2 -2
- package/dist/cjs/shared/getPageFiles/assert_exports_old_design.js +1 -1
- package/dist/cjs/shared/getPageFiles/fileTypes.js +1 -1
- package/dist/cjs/shared/getPageFiles/getAllPageIdFiles.js +1 -1
- package/dist/cjs/shared/getPageFiles/getPageFileObject.js +1 -1
- package/dist/cjs/shared/getPageFiles/parseVirtualFileExports.js +1 -1
- package/dist/cjs/shared/getProxyForPublicUsage.js +3 -3
- package/dist/cjs/shared/page-configs/getConfigDefinedAt.js +4 -3
- package/dist/cjs/shared/page-configs/resolveVikeConfigPublic.js +10 -10
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +1 -1
- package/dist/cjs/shared/preparePageContextForPublicUsage.js +5 -5
- package/dist/cjs/shared/route/abort.js +1 -1
- package/dist/cjs/shared/route/deduceRouteStringFromFilesystemPath.js +1 -1
- package/dist/cjs/shared/route/execHookGuard.js +1 -1
- package/dist/cjs/shared/route/execHookOnBeforeRoute.js +1 -1
- package/dist/cjs/shared/route/index.js +1 -1
- package/dist/cjs/shared/route/loadPageRoutes.js +10 -4
- package/dist/cjs/shared/route/resolveRouteFunction.js +3 -3
- package/dist/cjs/shared/route/resolveRouteString.js +1 -1
- package/dist/cjs/shared/route/routing.js +1 -1
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assertSetup.js +11 -8
- package/dist/cjs/utils/debug.js +1 -0
- package/dist/cjs/utils/debugGlob.js +1 -1
- package/dist/cjs/utils/getViteRPC.js +79 -0
- package/dist/cjs/utils/parseNpmPackage.js +1 -1
- package/dist/esm/__internal/index.d.ts +1 -1
- package/dist/esm/__internal/index.js +1 -1
- package/dist/esm/client/node.js +1 -1
- package/dist/esm/client/runtime-client-routing/createPageContextClientSide.d.ts +1 -1
- package/dist/esm/client/runtime-client-routing/createPageContextClientSide.js +2 -2
- package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.d.ts +10 -2
- package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.js +6 -6
- package/dist/esm/client/runtime-client-routing/globalContext.d.ts +1 -1
- package/dist/esm/client/runtime-client-routing/index.js +1 -1
- package/dist/esm/client/runtime-client-routing/isClientSideRoutable.js +1 -1
- package/dist/esm/client/runtime-client-routing/prefetch/getPrefetchSettings.js +6 -6
- package/dist/esm/client/runtime-client-routing/prefetch.js +10 -10
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.d.ts +3 -1
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.js +3 -3
- package/dist/esm/client/runtime-client-routing/skipLink.js +1 -1
- package/dist/esm/client/runtime-server-routing/createPageContextClientSide.d.ts +1 -1
- package/dist/esm/client/runtime-server-routing/createPageContextClientSide.js +2 -2
- package/dist/esm/client/runtime-server-routing/globalContext.d.ts +1 -1
- package/dist/esm/client/runtime-server-routing/index.js +1 -1
- package/dist/esm/client/shared/createGetGlobalContextClient.d.ts +5 -4
- package/dist/esm/client/shared/createGetGlobalContextClient.js +1 -2
- package/dist/esm/client/shared/execHookOnRenderClient.js +1 -1
- package/dist/esm/client/shared/loadPageConfigsLazyClientSide.js +2 -2
- package/dist/esm/client/shared/preparePageContextForPublicUsageClientShared.js +4 -4
- package/dist/esm/node/api/prepareViteApiCall.js +1 -1
- package/dist/esm/node/cli/index.js +1 -1
- package/dist/esm/node/createPageRenderer.js +1 -1
- package/dist/esm/node/importBuild.js +1 -1
- package/dist/esm/node/prerender/context.js +1 -1
- package/dist/esm/node/prerender/index.js +1 -1
- package/dist/esm/node/prerender/resolvePrerenderConfig.js +2 -2
- package/dist/esm/node/prerender/runPrerender.d.ts +42 -133
- package/dist/esm/node/prerender/runPrerender.js +9 -13
- package/dist/esm/node/runtime/globalContext.d.ts +39 -59
- package/dist/esm/node/runtime/globalContext.js +112 -31
- package/dist/esm/node/runtime/html/injectAssets/getViteDevScript.js +8 -1
- package/dist/esm/node/runtime/html/injectAssets/injectAssets__public.js +1 -1
- package/dist/esm/node/runtime/html/injectAssets/injectHtmlTags.js +2 -0
- package/dist/esm/node/runtime/html/serializeContext.d.ts +7 -1
- package/dist/esm/node/runtime/html/serializeContext.js +73 -15
- package/dist/esm/node/runtime/index-deprecated.js +1 -1
- package/dist/esm/node/runtime/index.js +1 -1
- package/dist/esm/node/runtime/page-files/setup.js +1 -1
- package/dist/esm/node/runtime/renderPage/assertArguments.js +1 -1
- package/dist/esm/node/runtime/renderPage/createHttpResponse.d.ts +1 -0
- package/dist/esm/node/runtime/renderPage/createHttpResponse.js +9 -6
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.d.ts +12 -35
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.js +4 -4
- package/dist/esm/node/runtime/renderPage/execHookDataAndOnBeforeRender.js +2 -2
- package/dist/esm/node/runtime/renderPage/getCacheControl.d.ts +5 -0
- package/dist/esm/node/runtime/renderPage/{createHttpResponse/getCacheControl.js → getCacheControl.js} +8 -9
- package/dist/esm/node/runtime/renderPage/getHttpResponseBody.js +4 -4
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +1 -1
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +16 -13
- package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.d.ts +8 -4
- package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +36 -17
- package/dist/esm/node/runtime/renderPage/preparePageContextForPublicUsageServer.js +1 -1
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +24 -68
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +1 -0
- package/dist/esm/node/runtime/renderPage.d.ts +13 -36
- package/dist/esm/node/runtime/renderPage.js +4 -6
- package/dist/esm/node/runtime/utils.d.ts +1 -0
- package/dist/esm/node/runtime/utils.js +1 -0
- package/dist/esm/node/vite/index.js +3 -1
- package/dist/esm/node/vite/onLoad.js +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.js +3 -3
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.js +3 -2
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildEntry.js +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistFileNames.js +16 -7
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +0 -1
- package/dist/esm/node/vite/plugins/pluginCommon/assertResolveAlias.js +1 -1
- package/dist/esm/node/vite/plugins/pluginCommon.d.ts +3 -0
- package/dist/esm/node/vite/plugins/pluginCommon.js +9 -4
- package/dist/esm/node/vite/plugins/pluginDev.js +1 -1
- package/dist/esm/node/vite/plugins/pluginEnvVars.js +1 -1
- package/dist/esm/node/vite/plugins/pluginFileEnv.js +1 -1
- package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +1 -1
- package/dist/esm/node/vite/plugins/pluginViteRPC.d.ts +25 -0
- package/dist/esm/node/vite/plugins/pluginViteRPC.js +40 -0
- package/dist/esm/node/vite/shared/addSsrMiddleware.js +1 -1
- package/dist/esm/node/vite/shared/applyRegExWithMagicString.js +1 -0
- package/dist/esm/node/vite/shared/loggerNotProd.js +10 -0
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +5 -1
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +1 -3
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/filesystemRouting.js +4 -6
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/transpileAndExecuteFile.js +1 -1
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal.js +6 -6
- package/dist/esm/shared/RenderErrorPage.js +1 -1
- package/dist/esm/shared/abort.js +1 -1
- package/dist/esm/shared/createGlobalContextShared.d.ts +3 -3
- package/dist/esm/shared/createGlobalContextShared.js +28 -7
- package/dist/esm/shared/createPageContextShared.d.ts +2 -3
- package/dist/esm/shared/createPageContextShared.js +1 -2
- package/dist/esm/shared/determinePageIdOld.js +1 -1
- package/dist/esm/shared/error-page.js +3 -3
- package/dist/esm/shared/getPageContextUrlComputed.js +4 -4
- package/dist/esm/shared/getPageFiles/analyzeClientSide.js +1 -1
- package/dist/esm/shared/getPageFiles/analyzePageClientSide/analyzeExports.js +1 -1
- package/dist/esm/shared/getPageFiles/analyzePageClientSide/determineClientEntry.js +1 -1
- package/dist/esm/shared/getPageFiles/analyzePageClientSide.js +2 -2
- package/dist/esm/shared/getPageFiles/assert_exports_old_design.js +1 -1
- package/dist/esm/shared/getPageFiles/fileTypes.js +1 -1
- package/dist/esm/shared/getPageFiles/getAllPageIdFiles.js +1 -1
- package/dist/esm/shared/getPageFiles/getPageFileObject.js +1 -1
- package/dist/esm/shared/getPageFiles/parseVirtualFileExports.js +1 -1
- package/dist/esm/shared/getProxyForPublicUsage.js +1 -1
- package/dist/esm/shared/hooks/getHook.js +1 -1
- package/dist/esm/shared/page-configs/getConfigDefinedAt.js +4 -3
- package/dist/esm/shared/page-configs/resolveVikeConfigPublic.js +12 -12
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +1 -1
- package/dist/esm/shared/preparePageContextForPublicUsage.js +5 -5
- package/dist/esm/shared/route/abort.js +1 -1
- package/dist/esm/shared/route/deduceRouteStringFromFilesystemPath.js +1 -1
- package/dist/esm/shared/route/execHookGuard.js +1 -1
- package/dist/esm/shared/route/execHookOnBeforeRoute.js +1 -1
- package/dist/esm/shared/route/index.js +1 -1
- package/dist/esm/shared/route/loadPageRoutes.d.ts +5 -0
- package/dist/esm/shared/route/loadPageRoutes.js +10 -4
- package/dist/esm/shared/route/resolveRouteFunction.js +3 -3
- package/dist/esm/shared/route/resolveRouteString.js +1 -1
- package/dist/esm/shared/route/routing.js +1 -1
- package/dist/esm/types/Config.d.ts +9 -1
- package/dist/esm/types/PageContext.d.ts +8 -2
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/assertSetup.js +11 -8
- package/dist/esm/utils/debug.d.ts +1 -1
- package/dist/esm/utils/debug.js +1 -0
- package/dist/esm/utils/debugGlob.js +1 -1
- package/dist/esm/utils/getViteRPC.d.ts +6 -0
- package/dist/esm/utils/getViteRPC.js +77 -0
- package/dist/esm/utils/parseNpmPackage.js +1 -1
- package/package.json +12 -6
- package/dist/esm/node/runtime/renderPage/createHttpResponse/getCacheControl.d.ts +0 -5
|
@@ -10,7 +10,7 @@ type PageContextInit = Pick<PageContextInternalServer, 'urlOriginal' | 'headersO
|
|
|
10
10
|
/** @deprecated Set `pageContextInit.urlOriginal` instead */ url?: string;
|
|
11
11
|
/** @deprecated Set pageContextInit.headersOriginal instead */ headers?: Record<string, string>;
|
|
12
12
|
};
|
|
13
|
-
type PageContextBegin =
|
|
13
|
+
type PageContextBegin = ReturnType<typeof getPageContextBegin>;
|
|
14
14
|
declare function renderPage<PageContextUserAdded extends {}, PageContextInitUser extends PageContextInit>(pageContextInit: PageContextInitUser): Promise<PageContextInitUser & {
|
|
15
15
|
httpResponse: HttpResponse;
|
|
16
16
|
} & Partial<PageContextServer & PageContextUserAdded>>;
|
|
@@ -18,7 +18,7 @@ declare let asyncHookWrapper: <PageContext>(_httpRequestId: number, ret: () => P
|
|
|
18
18
|
pageContextReturn: Awaited<PageContext>;
|
|
19
19
|
}>;
|
|
20
20
|
declare function renderPage_addAsyncHookwrapper(wrapper: typeof asyncHookWrapper): void;
|
|
21
|
-
declare function getPageContextBegin(pageContextInit: PageContextInit, globalContext: GlobalContextServerInternal, httpRequestId: number):
|
|
21
|
+
declare function getPageContextBegin(pageContextInit: PageContextInit, globalContext: GlobalContextServerInternal, httpRequestId: number): {
|
|
22
22
|
_isOriginalObject: true;
|
|
23
23
|
isPageContext: true;
|
|
24
24
|
} & {
|
|
@@ -46,24 +46,12 @@ declare function getPageContextBegin(pageContextInit: PageContextInit, globalCon
|
|
|
46
46
|
pages: {
|
|
47
47
|
[k: string]: import("../../shared/page-configs/resolveVikeConfigPublic.js").VikeConfigPublicPageEager;
|
|
48
48
|
};
|
|
49
|
-
} & ({
|
|
49
|
+
} & (({
|
|
50
50
|
_isProduction: false;
|
|
51
51
|
_isPrerendering: false;
|
|
52
52
|
assetsManifest: null;
|
|
53
|
-
_viteDevServer: import("vite").ViteDevServer;
|
|
54
|
-
viteConfig: import("vite").ResolvedConfig;
|
|
55
|
-
viteConfigRuntime: {
|
|
56
|
-
root: string;
|
|
57
|
-
build: {
|
|
58
|
-
outDir: string;
|
|
59
|
-
};
|
|
60
|
-
_baseViteOriginal: string;
|
|
61
|
-
vitePluginServerEntry: {
|
|
62
|
-
inject: boolean | undefined;
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
baseServer: string;
|
|
66
|
-
baseAssets: string;
|
|
53
|
+
_viteDevServer: import("vite").ViteDevServer | undefined;
|
|
54
|
+
viteConfig: import("vite").ResolvedConfig | undefined;
|
|
67
55
|
isClientSide: false;
|
|
68
56
|
_pageRoutes: import("../../shared/route/loadPageRoutes.js").PageRoutes;
|
|
69
57
|
_onBeforeRouteHook: import("../../shared/hooks/getHook.js").Hook | null;
|
|
@@ -73,19 +61,7 @@ declare function getPageContextBegin(pageContextInit: PageContextInit, globalCon
|
|
|
73
61
|
_isProduction: true;
|
|
74
62
|
assetsManifest: import("../../types/ViteManifest.js").ViteManifest;
|
|
75
63
|
_viteDevServer: null;
|
|
76
|
-
viteConfigRuntime: {
|
|
77
|
-
root: string;
|
|
78
|
-
build: {
|
|
79
|
-
outDir: string;
|
|
80
|
-
};
|
|
81
|
-
_baseViteOriginal: string;
|
|
82
|
-
vitePluginServerEntry: {
|
|
83
|
-
inject: boolean | undefined;
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
64
|
_usesClientRouter: boolean;
|
|
87
|
-
baseServer: string;
|
|
88
|
-
baseAssets: string;
|
|
89
65
|
isClientSide: false;
|
|
90
66
|
_pageRoutes: import("../../shared/route/loadPageRoutes.js").PageRoutes;
|
|
91
67
|
_onBeforeRouteHook: import("../../shared/hooks/getHook.js").Hook | null;
|
|
@@ -95,6 +71,13 @@ declare function getPageContextBegin(pageContextInit: PageContextInit, globalCon
|
|
|
95
71
|
_isProduction: true;
|
|
96
72
|
assetsManifest: import("../../types/ViteManifest.js").ViteManifest;
|
|
97
73
|
_viteDevServer: null;
|
|
74
|
+
_usesClientRouter: boolean;
|
|
75
|
+
isClientSide: false;
|
|
76
|
+
_pageRoutes: import("../../shared/route/loadPageRoutes.js").PageRoutes;
|
|
77
|
+
_onBeforeRouteHook: import("../../shared/hooks/getHook.js").Hook | null;
|
|
78
|
+
}) & {
|
|
79
|
+
baseServer: string;
|
|
80
|
+
baseAssets: string;
|
|
98
81
|
viteConfigRuntime: {
|
|
99
82
|
root: string;
|
|
100
83
|
build: {
|
|
@@ -105,12 +88,6 @@ declare function getPageContextBegin(pageContextInit: PageContextInit, globalCon
|
|
|
105
88
|
inject: boolean | undefined;
|
|
106
89
|
};
|
|
107
90
|
};
|
|
108
|
-
_usesClientRouter: boolean;
|
|
109
|
-
baseServer: string;
|
|
110
|
-
baseAssets: string;
|
|
111
|
-
isClientSide: false;
|
|
112
|
-
_pageRoutes: import("../../shared/route/loadPageRoutes.js").PageRoutes;
|
|
113
|
-
_onBeforeRouteHook: import("../../shared/hooks/getHook.js").Hook | null;
|
|
114
91
|
});
|
|
115
92
|
_pageFilesAll: import("../../shared/getPageFiles.js").PageFile[];
|
|
116
93
|
_baseServer: string;
|
|
@@ -132,4 +109,4 @@ declare function getPageContextBegin(pageContextInit: PageContextInit, globalCon
|
|
|
132
109
|
headers: Record<string, string> | null;
|
|
133
110
|
} & {
|
|
134
111
|
_httpRequestId: number;
|
|
135
|
-
}
|
|
112
|
+
};
|
|
@@ -79,7 +79,7 @@ async function renderPagePrepare(pageContextInit, httpRequestId) {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
const { globalContext } = await getGlobalContextServerInternal();
|
|
82
|
-
const pageContextBegin =
|
|
82
|
+
const pageContextBegin = getPageContextBegin(pageContextInit, globalContext, httpRequestId);
|
|
83
83
|
// Check Base URL
|
|
84
84
|
{
|
|
85
85
|
const pageContextHttpResponse = await checkBaseUrl(pageContextBegin, globalContext);
|
|
@@ -169,9 +169,7 @@ async function renderPageOnError(errNominalPage, pageContextBegin, pageContextNo
|
|
|
169
169
|
objectAssign(pageContextErrorPageInit, { pageId: null });
|
|
170
170
|
return handleErrorWithoutErrorPage(pageContextErrorPageInit);
|
|
171
171
|
}
|
|
172
|
-
|
|
173
|
-
objectAssign(pageContextErrorPageInit, { pageId: errorPageId });
|
|
174
|
-
}
|
|
172
|
+
objectAssign(pageContextErrorPageInit, { pageId: errorPageId });
|
|
175
173
|
}
|
|
176
174
|
let pageContextErrorPage;
|
|
177
175
|
try {
|
|
@@ -308,9 +306,9 @@ async function getPageContextErrorPageInit(pageContextBegin, errNominalPage, pag
|
|
|
308
306
|
assert(pageContext.errorWhileRendering);
|
|
309
307
|
return pageContext;
|
|
310
308
|
}
|
|
311
|
-
|
|
309
|
+
function getPageContextBegin(pageContextInit, globalContext, httpRequestId) {
|
|
312
310
|
const { isClientSideNavigation, _urlHandler } = handlePageContextUrl(pageContextInit.urlOriginal);
|
|
313
|
-
const pageContextBegin =
|
|
311
|
+
const pageContextBegin = createPageContextServerSide(pageContextInit, globalContext, {
|
|
314
312
|
isPrerendering: false,
|
|
315
313
|
ssr: {
|
|
316
314
|
urlHandler: _urlHandler,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default plugin;
|
|
2
2
|
export { plugin };
|
|
3
|
-
//
|
|
3
|
+
// TO-DO/next-major-release: remove
|
|
4
4
|
export { plugin as ssr };
|
|
5
5
|
export { getVikeConfig } from './shared/resolveVikeConfigInternal.js';
|
|
6
6
|
export { PROJECT_VERSION as version } from './utils.js';
|
|
@@ -22,6 +22,7 @@ import { resolveClientEntriesDev } from './shared/resolveClientEntriesDev.js';
|
|
|
22
22
|
import { pluginWorkaroundCssModuleHmr } from './plugins/pluginWorkaroundCssModuleHmr.js';
|
|
23
23
|
import { pluginWorkaroundVite6HmrRegression } from './plugins/pluginWorkaroundVite6HmrRegression.js';
|
|
24
24
|
import { pluginReplaceConstants } from './plugins/pluginReplaceConstants.js';
|
|
25
|
+
import { pluginViteRPC } from './plugins/pluginViteRPC.js';
|
|
25
26
|
// We don't call this in ./onLoad.ts to avoid a cyclic dependency with utils.ts
|
|
26
27
|
setResolveClientEntriesDev(resolveClientEntriesDev);
|
|
27
28
|
// Return `PluginInterop` instead of `Plugin` to avoid type mismatch upon different Vite versions
|
|
@@ -41,6 +42,7 @@ function plugin(vikeVitePluginOptions = {}) {
|
|
|
41
42
|
pluginWorkaroundCssModuleHmr(),
|
|
42
43
|
pluginWorkaroundVite6HmrRegression(),
|
|
43
44
|
pluginReplaceConstants(),
|
|
45
|
+
pluginViteRPC(),
|
|
44
46
|
];
|
|
45
47
|
Object.assign(plugins, { _vikeVitePluginOptions: vikeVitePluginOptions });
|
|
46
48
|
return plugins;
|
|
@@ -10,7 +10,7 @@ function onLoad() {
|
|
|
10
10
|
assertNodeVersion();
|
|
11
11
|
// package.json#peerDependencies isn't enough as users often ignore it
|
|
12
12
|
// This assertion isn't reliable: the user may still use a Vite version older than 5.1.0 — see https://github.com/vitejs/vite/pull/19355
|
|
13
|
-
// TO-DO/
|
|
13
|
+
// TO-DO/eventually: let's also use this.meta.viteVersion https://github.com/vitejs/vite/pull/20088
|
|
14
14
|
assertVersion('Vite', version, '5.1.0');
|
|
15
15
|
// Ensure we don't bloat the server runtime with heavy dependencies such Vite and esbuild
|
|
16
16
|
assertIsNotProductionRuntime();
|
|
@@ -11,7 +11,7 @@ declare function handleAssetsManifest_assertUsageCssTarget(config: ResolvedConfi
|
|
|
11
11
|
declare function handleAssetsManifest_getBuildConfig(config: UserConfig): Promise<{
|
|
12
12
|
readonly ssrEmitAssets: true | undefined;
|
|
13
13
|
readonly cssMinify: "esbuild" | undefined;
|
|
14
|
-
readonly manifest: "
|
|
14
|
+
readonly manifest: ".vite/manifest.json";
|
|
15
15
|
readonly copyPublicDir: boolean | undefined;
|
|
16
16
|
}>;
|
|
17
17
|
declare function handleAssetsManifest(config: ResolvedConfig, viteEnv: Environment | undefined, options: {
|
|
@@ -295,8 +295,8 @@ async function handleAssetsManifest_getBuildConfig(config) {
|
|
|
295
295
|
};
|
|
296
296
|
}
|
|
297
297
|
async function handleAssetsManifest(config, viteEnv, options, bundle) {
|
|
298
|
-
const
|
|
299
|
-
if (
|
|
298
|
+
const isSsrEnv = isViteServerBuild_onlySsrEnv(config, viteEnv);
|
|
299
|
+
if (isSsrEnv) {
|
|
300
300
|
assert(!assetsJsonFilePath);
|
|
301
301
|
const outDirs = getOutDirs(config, viteEnv);
|
|
302
302
|
assetsJsonFilePath = path.posix.join(outDirs.outDirRoot, 'assets.json');
|
|
@@ -310,7 +310,7 @@ async function handleAssetsManifest(config, viteEnv, options, bundle) {
|
|
|
310
310
|
// - Also in some other server builds such as dist/vercel/ from vike-vercel
|
|
311
311
|
// - Don't replace it in dist/rsc/ from vike-react-rsc since __VITE_ASSETS_MANIFEST__ doesn't exist there
|
|
312
312
|
const noop = await set_macro_ASSETS_MANIFEST(assetsJsonFilePath, bundle, outDir);
|
|
313
|
-
if (
|
|
313
|
+
if (isSsrEnv)
|
|
314
314
|
assert(!noop); // dist/server should always contain __VITE_ASSETS_MANIFEST__
|
|
315
315
|
}
|
|
316
316
|
}
|
|
@@ -4,7 +4,7 @@ export { analyzeClientEntries };
|
|
|
4
4
|
export { manifestTempFile };
|
|
5
5
|
import type { ResolvedConfig, Plugin } from 'vite';
|
|
6
6
|
import type { PageConfigBuildTime } from '../../../../types/PageConfig.js';
|
|
7
|
-
declare const manifestTempFile = "
|
|
7
|
+
declare const manifestTempFile = ".vite/manifest.json";
|
|
8
8
|
declare function pluginBuildConfig(): Plugin[];
|
|
9
9
|
declare function analyzeClientEntries(pageConfigs: PageConfigBuildTime[], config: ResolvedConfig): {
|
|
10
10
|
hasClientRouting: boolean;
|
|
@@ -14,7 +14,8 @@ import { isViteServerBuild } from '../../shared/isViteServerBuild.js';
|
|
|
14
14
|
import { resolveOutDir } from '../../shared/getOutDirs.js';
|
|
15
15
|
import { handleAssetsManifest_assertUsageCssCodeSplit, handleAssetsManifest_getBuildConfig, } from './handleAssetsManifest.js';
|
|
16
16
|
import { resolveIncludeAssetsImportedByServer } from '../../../runtime/renderPage/getPageAssets.js';
|
|
17
|
-
|
|
17
|
+
// TODO/now: stop setting `manifest` altogether and use the resolved value instead? So that other tools can easily read the manifest (e.g. @cloudflare/plugin-vite reads the manifest).
|
|
18
|
+
const manifestTempFile = '.vite/manifest.json';
|
|
18
19
|
function pluginBuildConfig() {
|
|
19
20
|
let config;
|
|
20
21
|
return [
|
|
@@ -56,7 +57,7 @@ function pluginBuildConfig() {
|
|
|
56
57
|
async function getEntries(config) {
|
|
57
58
|
const vikeConfig = await getVikeConfigInternal();
|
|
58
59
|
const { _pageConfigs: pageConfigs } = vikeConfig;
|
|
59
|
-
//
|
|
60
|
+
// TO-DO/next-major-release: remove
|
|
60
61
|
const pageFileEntries = await getPageFileEntries(config, resolveIncludeAssetsImportedByServer(vikeConfig.config));
|
|
61
62
|
assertUsage(Object.keys(pageFileEntries).length !== 0 || pageConfigs.length !== 0, 'At least one page should be defined, see https://vike.dev/add');
|
|
62
63
|
if (isViteServerBuild(config)) {
|
|
@@ -33,7 +33,7 @@ function getServerProductionEntryCode(config) {
|
|
|
33
33
|
const importPath = getImportPath(config);
|
|
34
34
|
const buildInfo = {
|
|
35
35
|
versionAtBuildTime: PROJECT_VERSION,
|
|
36
|
-
usesClientRouter: isUsingClientRouter(), //
|
|
36
|
+
usesClientRouter: isUsingClientRouter(), // TO-DO/next-major-release: remove
|
|
37
37
|
viteConfigRuntime: getViteConfigRuntime(config),
|
|
38
38
|
};
|
|
39
39
|
assertBuildInfo(buildInfo);
|
|
@@ -13,6 +13,8 @@ function pluginDistFileNames() {
|
|
|
13
13
|
apply: 'build',
|
|
14
14
|
enforce: 'post',
|
|
15
15
|
configResolved(config) {
|
|
16
|
+
// TODO/now remove
|
|
17
|
+
// if (true as boolean) return
|
|
16
18
|
const rollupOutputs = getRollupOutputs(config);
|
|
17
19
|
// We need to support multiple outputs: @vite/plugin-legacy adds an output, see https://github.com/vikejs/vike/issues/477#issuecomment-1406434802
|
|
18
20
|
rollupOutputs.forEach((rollupOutput) => {
|
|
@@ -101,6 +103,7 @@ function getIdHash(id) {
|
|
|
101
103
|
return crypto.createHash('md5').update(id).digest('hex').slice(0, 8);
|
|
102
104
|
}
|
|
103
105
|
function getAssetFileName(assetInfo, config) {
|
|
106
|
+
const userRootDir = config.root;
|
|
104
107
|
const assetsDir = getAssetsDir(config);
|
|
105
108
|
const dir = assetsDir + '/static';
|
|
106
109
|
let { name } = assetInfo;
|
|
@@ -118,11 +121,11 @@ function getAssetFileName(assetInfo, config) {
|
|
|
118
121
|
// Vite 3
|
|
119
122
|
name?.endsWith('?extractAssets&lang.css')) {
|
|
120
123
|
name = name.split('.').slice(0, -2).join('.');
|
|
121
|
-
name = clean(name);
|
|
124
|
+
name = clean(name, userRootDir);
|
|
122
125
|
return `${dir}/${name}.[hash][extname]`;
|
|
123
126
|
}
|
|
124
127
|
name = name.split('.').slice(0, -1).join('.');
|
|
125
|
-
name = clean(name);
|
|
128
|
+
name = clean(name, userRootDir);
|
|
126
129
|
return `${dir}/${name}.[hash][extname]`;
|
|
127
130
|
}
|
|
128
131
|
function getChunkFileName(_chunkInfo, config) {
|
|
@@ -135,11 +138,12 @@ function getChunkFileName(_chunkInfo, config) {
|
|
|
135
138
|
return name;
|
|
136
139
|
}
|
|
137
140
|
function getEntryFileName(chunkInfo, config, isEntry) {
|
|
141
|
+
const userRootDir = config.root;
|
|
138
142
|
const assetsDir = getAssetsDir(config);
|
|
139
143
|
const isForClientSide = !config.build.ssr;
|
|
140
144
|
let { name } = chunkInfo;
|
|
141
145
|
assertPosixPath(name);
|
|
142
|
-
name = clean(name, true,
|
|
146
|
+
name = clean(name, userRootDir, true,
|
|
143
147
|
// Not needed for client-side because dist/ filenames contain `.[hash].js`
|
|
144
148
|
!isForClientSide);
|
|
145
149
|
if (isForClientSide) {
|
|
@@ -149,9 +153,14 @@ function getEntryFileName(chunkInfo, config, isEntry) {
|
|
|
149
153
|
return `${name}.${isEntry ? 'mjs' : 'js'}`;
|
|
150
154
|
}
|
|
151
155
|
}
|
|
152
|
-
function removePathSeparators(name) {
|
|
156
|
+
function removePathSeparators(name, userRootDir) {
|
|
153
157
|
assertPosixPath(name);
|
|
154
|
-
|
|
158
|
+
if (name.startsWith(userRootDir)) {
|
|
159
|
+
name = name.slice(userRootDir.length);
|
|
160
|
+
if (name.startsWith('/'))
|
|
161
|
+
name = name.slice(1);
|
|
162
|
+
}
|
|
163
|
+
assert(!name.startsWith('/'), { name });
|
|
155
164
|
const entryDir = 'entries/';
|
|
156
165
|
const hasEntryDir = name.startsWith(entryDir);
|
|
157
166
|
if (hasEntryDir) {
|
|
@@ -164,14 +173,14 @@ function removePathSeparators(name) {
|
|
|
164
173
|
}
|
|
165
174
|
return name;
|
|
166
175
|
}
|
|
167
|
-
function clean(name, removePathSep, fixGlob) {
|
|
176
|
+
function clean(name, userRootDir, removePathSep, fixGlob) {
|
|
168
177
|
name = fixExtractAssetsQuery(name);
|
|
169
178
|
if (fixGlob) {
|
|
170
179
|
name = workaroundGlob(name);
|
|
171
180
|
}
|
|
172
181
|
name = replaceNonLatinCharacters(name);
|
|
173
182
|
if (removePathSep) {
|
|
174
|
-
name = removePathSeparators(name);
|
|
183
|
+
name = removePathSeparators(name, userRootDir);
|
|
175
184
|
}
|
|
176
185
|
name = removeLeadingUnderscoreInFilename(name);
|
|
177
186
|
name = removeUnderscoreDoublets(name);
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
* require() of dist/server/pageFiles.js from node_modules/vike/dist/esm/node/runtime/page-files/setup.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
|
|
7
7
|
* Reproduction: https://github.com/brillout/vite-plugin-ssr-server-import-syntax
|
|
8
8
|
*/
|
|
9
|
-
// TODO/refactor: prefix all other plugins with `plugin` as well?
|
|
10
9
|
export { pluginDistPackageJsonFile };
|
|
11
10
|
import { rollupIsEsm } from '../../shared/rollupIsEsm.js';
|
|
12
11
|
import { isViteServerBuild } from '../../shared/isViteServerBuild.js';
|
|
@@ -14,7 +14,7 @@ import pc from '@brillout/picocolors';
|
|
|
14
14
|
// - @vitejs/plugin-vue2
|
|
15
15
|
// - https://github.com/vikejs/vike/issues/1329
|
|
16
16
|
function assertResolveAlias(config) {
|
|
17
|
-
//
|
|
17
|
+
// TO-DO/eventually: re-implement warning https://github.com/vikejs/vike/issues/1567
|
|
18
18
|
return;
|
|
19
19
|
const aliases = getAliases(config);
|
|
20
20
|
const errPrefix = config.configFile || 'Your Vite configuration';
|
|
@@ -11,6 +11,7 @@ import { getVikeConfigInternal, setVikeConfigContext } from '../shared/resolveVi
|
|
|
11
11
|
import { assertViteRoot, getViteRoot, normalizeViteRoot } from '../../api/prepareViteApiCall.js';
|
|
12
12
|
import { temp_disablePrerenderAutoRun } from '../../prerender/context.js';
|
|
13
13
|
const pluginName = 'vike:pluginCommon';
|
|
14
|
+
globalThis.__VIKE__IS_PROCESS_SHARED_WITH_VITE = true;
|
|
14
15
|
function pluginCommon(vikeVitePluginOptions) {
|
|
15
16
|
return [
|
|
16
17
|
{
|
|
@@ -25,13 +26,13 @@ function pluginCommon(vikeVitePluginOptions) {
|
|
|
25
26
|
? normalizeViteRoot(configFromUser.root)
|
|
26
27
|
: await getViteRoot(operation);
|
|
27
28
|
assert(rootResolvedEarly);
|
|
28
|
-
//
|
|
29
|
+
// TO-DO/next-major-release: we can remove setVikeConfigContext() call here since with Vike's CLI it's already called at vike/node/api/prepareViteApiCall.ts
|
|
29
30
|
setVikeConfigContext({ userRootDir: rootResolvedEarly, isDev, vikeVitePluginOptions });
|
|
30
31
|
const vikeConfig = await getVikeConfigInternal();
|
|
31
32
|
return {
|
|
32
33
|
_isDev: isDev,
|
|
33
34
|
_rootResolvedEarly: rootResolvedEarly,
|
|
34
|
-
//
|
|
35
|
+
// TO-DO/next-major-release: remove https://github.com/vikejs/vike/issues/2122
|
|
35
36
|
configVikePromise: Promise.resolve({
|
|
36
37
|
prerender: vikeConfig.prerenderContext.isPrerenderingEnabled,
|
|
37
38
|
}),
|
|
@@ -53,7 +54,11 @@ function pluginCommon(vikeVitePluginOptions) {
|
|
|
53
54
|
configResolved: {
|
|
54
55
|
order: 'post',
|
|
55
56
|
async handler(config) {
|
|
56
|
-
/*
|
|
57
|
+
/* Also externalize linked dependencies by default?
|
|
58
|
+
* - Can this be done while the user sets ssr.external to `string[]`? I guess not?
|
|
59
|
+
* - If not then it's a problem: it makes the default inconsistent.
|
|
60
|
+
* - https://vite.dev/config/ssr-options.html#ssr-external
|
|
61
|
+
* - New setting +transpileLinkedDependencies ?
|
|
57
62
|
overrideViteDefaultSsrExternal(config)
|
|
58
63
|
//*/
|
|
59
64
|
workaroundCI(config);
|
|
@@ -157,7 +162,7 @@ function assertVikeCliOrApi(config) {
|
|
|
157
162
|
onlyOnce: true,
|
|
158
163
|
});
|
|
159
164
|
}
|
|
160
|
-
//
|
|
165
|
+
// TO-DO/next-major-release: remove https://github.com/vikejs/vike/issues/2122
|
|
161
166
|
function temp_supportOldInterface(config) {
|
|
162
167
|
if (!('vitePluginSsr' in config))
|
|
163
168
|
return;
|
|
@@ -20,7 +20,7 @@ function pluginDev() {
|
|
|
20
20
|
config() {
|
|
21
21
|
return {
|
|
22
22
|
appType: 'custom',
|
|
23
|
-
//
|
|
23
|
+
// TO-DO/next-major-release: remove (AFAICT we only need to use config.optimizeDeps for the old design)
|
|
24
24
|
optimizeDeps: {
|
|
25
25
|
exclude: [
|
|
26
26
|
// We exclude Vike's client runtime to be able to use Vite's import.meta.glob()
|
|
@@ -6,7 +6,7 @@ import { getModuleFilePathAbsolute } from '../shared/getFilePath.js';
|
|
|
6
6
|
import { normalizeId } from '../shared/normalizeId.js';
|
|
7
7
|
import { isViteServerBuild_safe } from '../shared/isViteServerBuild.js';
|
|
8
8
|
import { applyRegExpWithMagicString } from '../shared/applyRegExWithMagicString.js';
|
|
9
|
-
//
|
|
9
|
+
// TO-DO/eventually:
|
|
10
10
|
// - Make import.meta.env work inside +config.js
|
|
11
11
|
// - For it to work, we'll probably need the user to define the settings (e.g. `envDir`) for loadEnv() inside vike.config.js instead of vite.config.js
|
|
12
12
|
// - Or stop using Vite's `mode` implementation and have Vike implement its own `mode` feature? (So that the only dependencies are `$ vike build --mode staging` and `$ MODE=staging vike build`.)
|
|
@@ -119,7 +119,7 @@ function pluginFileEnv() {
|
|
|
119
119
|
return modulePath.includes(suffixWrong);
|
|
120
120
|
}
|
|
121
121
|
function skip(id) {
|
|
122
|
-
//
|
|
122
|
+
// TO-DO/next-major-release: remove
|
|
123
123
|
if (extractAssetsRE.test(id) || extractExportNamesRE.test(id))
|
|
124
124
|
return true;
|
|
125
125
|
if (!id.includes(getSuffix('client')) && !id.includes(getSuffix('server')))
|
|
@@ -20,7 +20,7 @@ function pluginVirtualFiles() {
|
|
|
20
20
|
name: 'vike:pluginVirtualFiles',
|
|
21
21
|
async configResolved(config_) {
|
|
22
22
|
config = config_;
|
|
23
|
-
//
|
|
23
|
+
// TO-DO/next-major-release: remove
|
|
24
24
|
if (!isV1Design())
|
|
25
25
|
config.experimental.importGlobRestoreExtension = true;
|
|
26
26
|
},
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export { pluginViteRPC };
|
|
2
|
+
import type { Plugin, ViteDevServer } from 'vite';
|
|
3
|
+
import type { ClientDependency } from '../../../shared/getPageFiles/analyzePageClientSide/ClientDependency.js';
|
|
4
|
+
export type ViteRPC = ReturnType<typeof getViteRpcFunctions>;
|
|
5
|
+
declare function getViteRpcFunctions(viteDevServer: ViteDevServer): {
|
|
6
|
+
transformIndexHtmlRPC(html: string): Promise<string>;
|
|
7
|
+
retrievePageAssetsDevRPC(clientDependencies: ClientDependency[], clientEntries: string[]): Promise<{
|
|
8
|
+
clientEntriesSrc: string[];
|
|
9
|
+
assetUrls: string[];
|
|
10
|
+
}>;
|
|
11
|
+
getViteConfigRuntimeRPC(): Promise<{
|
|
12
|
+
root: string;
|
|
13
|
+
build: {
|
|
14
|
+
outDir: string;
|
|
15
|
+
};
|
|
16
|
+
_baseViteOriginal: string;
|
|
17
|
+
vitePluginServerEntry: {
|
|
18
|
+
inject: boolean | undefined;
|
|
19
|
+
};
|
|
20
|
+
}>;
|
|
21
|
+
};
|
|
22
|
+
declare global {
|
|
23
|
+
var __VIKE__DYNAMIC_IMPORT: (module: string) => Promise<Record<string, unknown>>;
|
|
24
|
+
}
|
|
25
|
+
declare function pluginViteRPC(): Plugin;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export { pluginViteRPC };
|
|
2
|
+
import { createViteRPC, assertIsNotProductionRuntime, requireResolveVikeDistFile } from '../utils.js';
|
|
3
|
+
import { resolveClientEntriesDev } from '../shared/resolveClientEntriesDev.js';
|
|
4
|
+
import { retrieveAssetsDev } from '../../runtime/renderPage/getPageAssets/retrieveAssetsDev.js';
|
|
5
|
+
import { getViteConfigRuntime } from '../shared/getViteConfigRuntime.js';
|
|
6
|
+
assertIsNotProductionRuntime();
|
|
7
|
+
function getViteRpcFunctions(viteDevServer) {
|
|
8
|
+
return {
|
|
9
|
+
async transformIndexHtmlRPC(html) {
|
|
10
|
+
return await viteDevServer.transformIndexHtml('/', html);
|
|
11
|
+
},
|
|
12
|
+
async retrievePageAssetsDevRPC(clientDependencies, clientEntries) {
|
|
13
|
+
const clientEntriesSrc = clientEntries.map((clientEntry) => resolveClientEntriesDev(clientEntry, viteDevServer));
|
|
14
|
+
const assetUrls = await retrieveAssetsDev(clientDependencies, viteDevServer);
|
|
15
|
+
return { clientEntriesSrc, assetUrls };
|
|
16
|
+
},
|
|
17
|
+
async getViteConfigRuntimeRPC() {
|
|
18
|
+
const viteConfigRuntime = getViteConfigRuntime(viteDevServer.config);
|
|
19
|
+
return viteConfigRuntime;
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function pluginViteRPC() {
|
|
24
|
+
const runtimeFileWithDynamicImport = requireResolveVikeDistFile('dist/esm/node/runtime/globalContext.js');
|
|
25
|
+
return {
|
|
26
|
+
name: 'vike:pluginViteRPC',
|
|
27
|
+
configureServer(viteDevServer) {
|
|
28
|
+
createViteRPC(viteDevServer, getViteRpcFunctions);
|
|
29
|
+
},
|
|
30
|
+
transform(code, id) {
|
|
31
|
+
if (id !== runtimeFileWithDynamicImport)
|
|
32
|
+
return;
|
|
33
|
+
const envName = this.environment?.name;
|
|
34
|
+
if (!envName || ['client', 'ssr'].includes(envName))
|
|
35
|
+
return;
|
|
36
|
+
// TODO/now use magic-string
|
|
37
|
+
return code.replaceAll('__VIKE__DYNAMIC_IMPORT', 'import');
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -16,7 +16,7 @@ function addSsrMiddleware(middlewares, config, isPreview, isPrerenderingEnabled)
|
|
|
16
16
|
};
|
|
17
17
|
Object.defineProperty(pageContextInit, 'userAgent', {
|
|
18
18
|
get() {
|
|
19
|
-
//
|
|
19
|
+
// TO-DO/next-major-release: assertUsage() instead of assertWarning()
|
|
20
20
|
assertWarning(false, `${pc.cyan('pageContext.userAgent')} is deprecated: use ${pc.cyan("pageContext.headers['user-agent']")} instead.`, {
|
|
21
21
|
showStackTrace: true,
|
|
22
22
|
onlyOnce: true,
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
// TO-DO/eventually:
|
|
2
|
+
// - New hook onLog(): https://github.com/vikejs/vike/issues/1438
|
|
3
|
+
// - Exact same logs between prod and dev, only difference is that some log objects have:
|
|
4
|
+
// - `isDevLog: true`
|
|
5
|
+
// - `willBeLogged: false` in production
|
|
6
|
+
// - `showTimestamp: true`
|
|
7
|
+
// - Never clear screen (it's complex with little benefit)
|
|
8
|
+
// - Add shortcut to clear screen
|
|
9
|
+
// - Maybe rotate colors upon no requests within 30s?
|
|
10
|
+
// - Only show a one-liner init log (instead of Vite's multi-line log)
|
|
1
11
|
// Non-production logger used for:
|
|
2
12
|
// - Development
|
|
3
13
|
// - Preview
|
|
@@ -85,7 +85,7 @@ const configDefinitionsBuiltIn = {
|
|
|
85
85
|
env: { client: true },
|
|
86
86
|
eager: true,
|
|
87
87
|
},
|
|
88
|
-
//
|
|
88
|
+
// TO-DO/next-major-release: remove
|
|
89
89
|
prefetchStaticAssets: {
|
|
90
90
|
env: { client: true },
|
|
91
91
|
},
|
|
@@ -210,6 +210,10 @@ const configDefinitionsBuiltIn = {
|
|
|
210
210
|
env: { server: true },
|
|
211
211
|
global: true,
|
|
212
212
|
},
|
|
213
|
+
headersResponse: {
|
|
214
|
+
env: { server: true },
|
|
215
|
+
cumulative: true,
|
|
216
|
+
},
|
|
213
217
|
};
|
|
214
218
|
function getConfigEnv(configValueSources, configName) {
|
|
215
219
|
const configValueSource = getConfigValueSource(configValueSources, configName);
|
|
@@ -30,9 +30,7 @@ async function crawlPlusFiles(userRootDir) {
|
|
|
30
30
|
: // Fallback to tinyglobby for users that dynamically generate plus files. (Assuming that no plus file is found because of the user's .gitignore list.)
|
|
31
31
|
filesGlob;
|
|
32
32
|
assert(files);
|
|
33
|
-
if (debug.isActivated) {
|
|
34
|
-
assert(filesGit);
|
|
35
|
-
assert(filesGlob);
|
|
33
|
+
if (debug.isActivated && filesGit && filesGlob) {
|
|
36
34
|
assertWarning(deepEqual(filesGlob.slice().sort(), filesGit.slice().sort()), "Git and glob results aren't matching.", { onlyOnce: false });
|
|
37
35
|
}
|
|
38
36
|
// Filter build files
|
|
@@ -32,12 +32,10 @@ function getFilesystemRouteString(locationId) {
|
|
|
32
32
|
function getInheritanceRoot(locationId) {
|
|
33
33
|
return getLogicalPath(locationId, [
|
|
34
34
|
'renderer',
|
|
35
|
-
//
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
//
|
|
39
|
-
// - Not sure if it's a good idea? Could it make config inheritance confusing? Let's try for now and see how it goes.
|
|
40
|
-
// - TO-DO/eventually: update docs https://github.com/vikejs/vike/blob/5fcdc4d5094f1a4dcbefc0b481cdd30a205aef2d/docs/pages/filesystem-routing/%2BPage.mdx?plain=1#L98
|
|
35
|
+
// Enable hooks defined by vike-{react,vue,solid} such as +onBeforeRenderClient to be defined at the root directory. In other words, avoid following error:
|
|
36
|
+
// ```bash
|
|
37
|
+
// [11:09:43.072][/test-preview.test.ts][npm run preview][stderr] Error: [vike][Wrong Usage] /+onBeforeRenderClient.ts sets the value of the config onBeforeRenderClient which is a custom config that is defined with https://vike.dev/meta at a path that doesn't apply to / — see https://vike.dev/config#inheritance
|
|
38
|
+
// ```
|
|
41
39
|
'pages',
|
|
42
40
|
]);
|
|
43
41
|
}
|
|
@@ -347,7 +347,7 @@ function isTemporaryBuildFile(filePath) {
|
|
|
347
347
|
const fileName = path.posix.basename(filePath);
|
|
348
348
|
return /\.build-[a-z0-9]{12}\.mjs$/.test(fileName);
|
|
349
349
|
}
|
|
350
|
-
//
|
|
350
|
+
// TO-DO/next-major-release: remove
|
|
351
351
|
function isHeaderFile(filePath) {
|
|
352
352
|
assertPosixPath(filePath);
|
|
353
353
|
const fileExtensions = getFileExtensions(filePath);
|