vike 0.4.222 → 0.4.223
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/shared/getPageContextProxyForUser.js +1 -1
- package/dist/cjs/node/api/prepareViteApiCall.js +1 -1
- package/dist/cjs/node/plugin/index.js +1 -1
- package/dist/cjs/node/plugin/plugins/baseUrls.js +6 -1
- package/dist/cjs/node/plugin/plugins/buildApp.js +9 -5
- package/dist/cjs/node/plugin/plugins/buildConfig.js +3 -0
- package/dist/cjs/node/plugin/plugins/envVars.js +2 -18
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +2 -2
- package/dist/cjs/node/plugin/plugins/extractExportNamesPlugin.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +16 -41
- package/dist/cjs/node/plugin/shared/getHttpRequestAsyncStore.js +1 -1
- package/dist/cjs/node/plugin/shared/viteIsSSR.js +19 -10
- package/dist/cjs/node/runtime/globalContext.js +19 -8
- package/dist/cjs/node/runtime/renderPage/createHttpResponse/assertNoInfiniteHttpRedirect.js +1 -1
- package/dist/cjs/node/runtime/renderPage/createHttpResponse.js +24 -0
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +1 -1
- package/dist/cjs/node/runtime/renderPage/handlePageContextRequestUrl.js +1 -1
- package/dist/cjs/node/runtime/renderPage/isNewError.js +1 -1
- package/dist/cjs/node/runtime/renderPage/isVikeConfigInvalid.js +10 -0
- package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +1 -1
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +2 -4
- package/dist/cjs/node/runtime/renderPage.js +63 -49
- package/dist/cjs/node/runtime/universal-middleware.js +14 -0
- package/dist/cjs/node/shared/resolveBase.js +0 -13
- package/dist/cjs/shared/getPageConfigsRuntime.js +2 -8
- package/dist/cjs/shared/getPageContextRequestUrl.js +1 -1
- package/dist/cjs/shared/getPageContextUrlComputed.js +12 -9
- package/dist/cjs/shared/hooks/getHook.js +1 -1
- package/dist/cjs/shared/page-configs/getPageConfigUserFriendly.js +44 -12
- package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +2 -8
- package/dist/cjs/shared/route/loadPageRoutes.js +1 -1
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assert.js +1 -1
- package/dist/cjs/utils/assertSetup.js +1 -1
- package/dist/cjs/utils/assertSingleInstance.js +2 -2
- package/dist/cjs/utils/getGlobalObject.js +2 -6
- package/dist/cjs/utils/parseUrl-extras.js +2 -2
- package/dist/cjs/utils/parseUrl.js +5 -5
- package/dist/esm/client/client-routing-runtime/getPageContextCurrent.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/getPageContextCurrent.js +1 -1
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.d.ts +4 -4
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +1 -1
- package/dist/esm/client/client-routing-runtime/history.js +1 -1
- package/dist/esm/client/client-routing-runtime/prefetch/getPrefetchSettings.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/prefetch.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/prefetch.js +3 -3
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +2 -2
- package/dist/esm/client/client-routing-runtime/scrollRestoration.js +1 -1
- package/dist/esm/client/client-routing-runtime/skipLink.js +2 -2
- package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +1 -1
- package/dist/esm/client/shared/executeOnRenderClientHook.d.ts +2 -2
- package/dist/esm/client/shared/getPageContextProxyForUser.js +1 -1
- package/dist/esm/client/shared/loadUserFilesClientSide.d.ts +2 -2
- package/dist/esm/client/shared/loadUserFilesClientSide.js +2 -2
- package/dist/esm/client/shared/preparePageContextForUserConsumptionClientSide.d.ts +2 -2
- package/dist/esm/node/api/prepareViteApiCall.js +1 -1
- package/dist/esm/node/plugin/index.d.ts +4 -1
- package/dist/esm/node/plugin/index.js +1 -1
- package/dist/esm/node/plugin/plugins/baseUrls.js +6 -1
- package/dist/esm/node/plugin/plugins/buildApp.js +9 -5
- package/dist/esm/node/plugin/plugins/buildConfig.js +3 -0
- package/dist/esm/node/plugin/plugins/envVars.js +2 -18
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +3 -3
- package/dist/esm/node/plugin/plugins/extractExportNamesPlugin.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +17 -42
- package/dist/esm/node/plugin/shared/getHttpRequestAsyncStore.js +2 -2
- package/dist/esm/node/plugin/shared/viteIsSSR.d.ts +7 -4
- package/dist/esm/node/plugin/shared/viteIsSSR.js +20 -11
- package/dist/esm/node/runtime/globalContext.d.ts +9 -8
- package/dist/esm/node/runtime/globalContext.js +19 -8
- package/dist/esm/node/runtime/html/injectAssets/getViteDevScript.d.ts +2 -2
- package/dist/esm/node/runtime/html/injectAssets.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/analyzePage.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/createHttpResponse/assertNoInfiniteHttpRedirect.js +1 -1
- package/dist/esm/node/runtime/renderPage/createHttpResponse.d.ts +2 -0
- package/dist/esm/node/runtime/renderPage/createHttpResponse.js +24 -0
- package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +1 -1
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/handlePageContextRequestUrl.js +1 -1
- package/dist/esm/node/runtime/renderPage/isNewError.js +1 -1
- package/dist/esm/node/runtime/renderPage/isVikeConfigInvalid.d.ts +6 -0
- package/dist/esm/node/runtime/renderPage/isVikeConfigInvalid.js +8 -0
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +3 -3
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +2 -2
- package/dist/esm/node/runtime/renderPage/log404/index.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +4 -4
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +12 -12
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +2 -4
- package/dist/esm/node/runtime/renderPage.d.ts +5 -5
- package/dist/esm/node/runtime/renderPage.js +64 -49
- package/dist/esm/node/runtime/universal-middleware.d.ts +1 -0
- package/dist/esm/node/runtime/universal-middleware.js +11 -0
- package/dist/esm/node/shared/resolveBase.d.ts +1 -9
- package/dist/esm/node/shared/resolveBase.js +0 -13
- package/dist/esm/shared/getPageConfigsRuntime.d.ts +2 -2
- package/dist/esm/shared/getPageConfigsRuntime.js +3 -9
- package/dist/esm/shared/getPageContextRequestUrl.js +1 -1
- package/dist/esm/shared/getPageContextUrlComputed.js +12 -9
- package/dist/esm/shared/getPageFiles.d.ts +1 -1
- package/dist/esm/shared/hooks/getHook.d.ts +3 -3
- package/dist/esm/shared/hooks/getHook.js +1 -1
- package/dist/esm/shared/page-configs/Config.d.ts +3 -1
- package/dist/esm/shared/page-configs/PageConfig.d.ts +9 -2
- package/dist/esm/shared/page-configs/getPageConfigUserFriendly.d.ts +24 -16
- package/dist/esm/shared/page-configs/getPageConfigUserFriendly.js +44 -12
- package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.d.ts +3 -2
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +2 -8
- package/dist/esm/shared/route/executeGuardHook.d.ts +2 -2
- package/dist/esm/shared/route/loadPageRoutes.js +1 -1
- package/dist/esm/shared/types.d.ts +6 -0
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/assert.js +1 -1
- package/dist/esm/utils/assertSetup.js +1 -1
- package/dist/esm/utils/assertSingleInstance.js +2 -2
- package/dist/esm/utils/getGlobalObject.d.ts +3 -2
- package/dist/esm/utils/getGlobalObject.js +2 -6
- package/dist/esm/utils/parseUrl-extras.js +2 -2
- package/dist/esm/utils/parseUrl.d.ts +3 -4
- package/dist/esm/utils/parseUrl.js +5 -5
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +15 -2
- package/universal-middleware.js +3 -0
- package/dist/cjs/node/runtime/renderPage/isConfigInvalid.js +0 -10
- package/dist/esm/node/runtime/renderPage/isConfigInvalid.d.ts +0 -6
- package/dist/esm/node/runtime/renderPage/isConfigInvalid.js +0 -8
|
@@ -18,7 +18,7 @@ import { executeGuardHook } from '../../shared/route/executeGuardHook.js';
|
|
|
18
18
|
import { AbortRender, isAbortPageContext } from '../../shared/route/abort.js';
|
|
19
19
|
import { pageContextInitIsPassedToClient } from '../../shared/misc/pageContextInitIsPassedToClient.js';
|
|
20
20
|
import { isServerSideError } from '../../shared/misc/isServerSideError.js';
|
|
21
|
-
const globalObject = getGlobalObject('
|
|
21
|
+
const globalObject = getGlobalObject('client-routing-runtime/getPageContextFromHooks.ts', {});
|
|
22
22
|
// TODO/eventually: rename
|
|
23
23
|
function getPageContextFromHooks_serialized() {
|
|
24
24
|
const pageContextSerialized = getPageContextSerializedInHtml();
|
|
@@ -7,7 +7,7 @@ export { monkeyPatchHistoryAPI };
|
|
|
7
7
|
import { getCurrentUrl } from '../shared/getCurrentUrl.js';
|
|
8
8
|
import { assert, assertUsage, getGlobalObject, isObject } from './utils.js';
|
|
9
9
|
initHistoryState(); // we redundantly call initHistoryState() to ensure it's called early
|
|
10
|
-
const globalObject = getGlobalObject('history.ts', { previous: getHistoryInfo() });
|
|
10
|
+
const globalObject = getGlobalObject('client-routing-runtime/history.ts', { previous: getHistoryInfo() });
|
|
11
11
|
// `window.history.state === null` when:
|
|
12
12
|
// - The very first render
|
|
13
13
|
// - Click on `<a href="#some-hash" />`
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { getPrefetchSettings };
|
|
2
2
|
export { PAGE_CONTEXT_MAX_AGE_DEFAULT };
|
|
3
3
|
export type { PrefetchSettingResolved };
|
|
4
|
-
import type {
|
|
4
|
+
import type { PageConfigUserFriendlyOld } from '../../../shared/getPageFiles.js';
|
|
5
5
|
declare const PAGE_CONTEXT_MAX_AGE_DEFAULT = 5000;
|
|
6
6
|
type PrefetchSettingResolved = {
|
|
7
7
|
staticAssets: false | 'hover' | 'viewport';
|
|
8
8
|
pageContext: false | number;
|
|
9
9
|
};
|
|
10
|
-
declare function getPrefetchSettings(pageContext:
|
|
10
|
+
declare function getPrefetchSettings(pageContext: PageConfigUserFriendlyOld, linkTag: null | HTMLElement): PrefetchSettingResolved;
|
|
@@ -6,7 +6,7 @@ export { addLinkPrefetchHandlers };
|
|
|
6
6
|
export { addLinkPrefetchHandlers_watch };
|
|
7
7
|
export { addLinkPrefetchHandlers_unwatch };
|
|
8
8
|
import { type PageContextFromServerHooks, getPageContextFromServerHooks } from './getPageContextFromHooks.js';
|
|
9
|
-
import type {
|
|
9
|
+
import type { PageConfigUserFriendlyOld, PageFile } from '../../shared/getPageFiles.js';
|
|
10
10
|
import { type PageConfigRuntime } from '../../shared/page-configs/PageConfig.js';
|
|
11
11
|
type ResultPageContextFromServer = Awaited<ReturnType<typeof getPageContextFromServerHooks>>;
|
|
12
12
|
type PageContextForPrefetch = {
|
|
@@ -19,7 +19,7 @@ type PageContextForPrefetch = {
|
|
|
19
19
|
};
|
|
20
20
|
declare function getPageContextPrefetched(pageContext: {
|
|
21
21
|
urlPathname: string;
|
|
22
|
-
} &
|
|
22
|
+
} & PageConfigUserFriendlyOld): null | PageContextFromServerHooks;
|
|
23
23
|
declare function populatePageContextPrefetchCache(pageContext: PageContextForPrefetch, result: ResultPageContextFromServer): void;
|
|
24
24
|
/**
|
|
25
25
|
* Programmatically prefetch client assets.
|
|
@@ -19,7 +19,7 @@ import { PAGE_CONTEXT_MAX_AGE_DEFAULT, getPrefetchSettings } from './prefetch/ge
|
|
|
19
19
|
import pc from '@brillout/picocolors';
|
|
20
20
|
import { normalizeUrlArgument } from './normalizeUrlArgument.js';
|
|
21
21
|
assertClientRouting();
|
|
22
|
-
const globalObject = getGlobalObject('prefetch.ts', {
|
|
22
|
+
const globalObject = getGlobalObject('client-routing-runtime/prefetch.ts', {
|
|
23
23
|
linkPrefetchHandlerAdded: new WeakSet(),
|
|
24
24
|
addLinkPrefetchHandlers_debounce: null,
|
|
25
25
|
mutationObserver: new MutationObserver(addLinkPrefetchHandlers),
|
|
@@ -60,8 +60,8 @@ async function prefetchPageContextFromServerHooks(pageContextLink, resultMaxAge)
|
|
|
60
60
|
const result = await getPageContextFromServerHooks(pageContextLink, false);
|
|
61
61
|
setPageContextPrefetchCache(pageContextLink, result, resultMaxAge);
|
|
62
62
|
}
|
|
63
|
-
function populatePageContextPrefetchCache(pageContext /*&
|
|
64
|
-
// TODO/pageContext-prefetch: replace with using pageContext.config.prerender instead. (For being able to do that: eager configs need to be accessible without have to use
|
|
63
|
+
function populatePageContextPrefetchCache(pageContext /*& PageConfigUserFriendlyOld*/, result) {
|
|
64
|
+
// TODO/pageContext-prefetch: replace with using pageContext.config.prerender instead. (For being able to do that: eager configs need to be accessible without have to use PageConfigUserFriendlyOld as it isn't available here.)
|
|
65
65
|
if (!isBrilloutDocpress())
|
|
66
66
|
return;
|
|
67
67
|
setPageContextPrefetchCache(pageContext, result, null);
|
|
@@ -20,7 +20,7 @@ import { getErrorPageId } from '../../shared/error-page.js';
|
|
|
20
20
|
import { setPageContextCurrent } from './getPageContextCurrent.js';
|
|
21
21
|
import { getRouteStringParameterList } from '../../shared/route/resolveRouteString.js';
|
|
22
22
|
import { getCurrentUrl } from '../shared/getCurrentUrl.js';
|
|
23
|
-
const globalObject = getGlobalObject('renderPageClientSide.ts', (() => {
|
|
23
|
+
const globalObject = getGlobalObject('client-routing-runtime/renderPageClientSide.ts', (() => {
|
|
24
24
|
const { promise: firstRenderStartPromise, resolve: firstRenderStartPromiseResolve } = genPromise();
|
|
25
25
|
return {
|
|
26
26
|
previousPageContext: null,
|
|
@@ -488,7 +488,7 @@ async function renderPageClientSide(renderArgs) {
|
|
|
488
488
|
}
|
|
489
489
|
}
|
|
490
490
|
// For Vike tests (but also potentially for Vike users)
|
|
491
|
-
//
|
|
491
|
+
// https://github.com/vikejs/vike/blob/ffbc5cf16407bcc075f414447e50d997c87c0c94/test/playground/pages/nested-layout/e2e-test.ts#L59
|
|
492
492
|
function stampFinished(urlOriginal) {
|
|
493
493
|
window._vike ?? (window._vike = {});
|
|
494
494
|
window._vike.fullyRenderedUrl = urlOriginal;
|
|
@@ -6,7 +6,7 @@ export { scrollRestoration_initialRenderIsDone };
|
|
|
6
6
|
// - Firefox doesn't restore the scroll position upon page reload but does upon Cmd-Shift-T
|
|
7
7
|
// See also: https://github.com/cyco130/knave/blob/e9e1bc7687848504293197f1b314b7d12ad0d228/design.md#scroll-restoration
|
|
8
8
|
import { getGlobalObject, onPageHide, onPageShow } from './utils.js';
|
|
9
|
-
const globalObject = getGlobalObject('scrollRestoration.ts', {});
|
|
9
|
+
const globalObject = getGlobalObject('client-routing-runtime/scrollRestoration.ts', {});
|
|
10
10
|
function scrollRestoration_init() {
|
|
11
11
|
// Use the native scroll restoration mechanism only for the first render
|
|
12
12
|
scrollRestoration_enable();
|
|
@@ -49,8 +49,8 @@ function isSameAsCurrentUrl(href) {
|
|
|
49
49
|
function hasBaseServer(href) {
|
|
50
50
|
const baseServer = getBaseServer();
|
|
51
51
|
assert(isBaseServer(baseServer));
|
|
52
|
-
const {
|
|
53
|
-
return
|
|
52
|
+
const { isBaseMissing } = parseUrl(href, baseServer);
|
|
53
|
+
return !isBaseMissing;
|
|
54
54
|
}
|
|
55
55
|
function isDisableAutomaticLinkInterception() {
|
|
56
56
|
// @ts-ignore
|
|
@@ -11,6 +11,6 @@ declare function getPageContext(): Promise<{
|
|
|
11
11
|
_pageFilesAll: import("../../shared/getPageFiles.js").PageFile[];
|
|
12
12
|
_pageConfigs: import("../../__internal/index.js").PageConfig[];
|
|
13
13
|
_pageConfigGlobal: import("../../shared/page-configs/PageConfig.js").PageConfigGlobalRuntime;
|
|
14
|
-
} & import("../../shared/getPageFiles.js").
|
|
14
|
+
} & import("../../shared/getPageFiles.js").PageConfigUserFriendlyOld & {
|
|
15
15
|
_pageFilesLoaded: import("../../shared/getPageFiles.js").PageFile[];
|
|
16
16
|
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { executeOnRenderClientHook };
|
|
2
2
|
export type { PageContextBeforeRenderClient };
|
|
3
|
-
import type { PageFile,
|
|
3
|
+
import type { PageFile, PageConfigUserFriendlyOld } from '../../shared/getPageFiles.js';
|
|
4
4
|
import { type PageContextForUserConsumptionClientSide } from './preparePageContextForUserConsumptionClientSide.js';
|
|
5
5
|
import type { PageConfigRuntime } from '../../shared/page-configs/PageConfig.js';
|
|
6
6
|
type PageContextBeforeRenderClient = {
|
|
@@ -9,5 +9,5 @@ type PageContextBeforeRenderClient = {
|
|
|
9
9
|
urlPathname?: string;
|
|
10
10
|
pageId: string;
|
|
11
11
|
_pageConfigs: PageConfigRuntime[];
|
|
12
|
-
} &
|
|
12
|
+
} & PageConfigUserFriendlyOld & PageContextForUserConsumptionClientSide;
|
|
13
13
|
declare function executeOnRenderClientHook<PC extends PageContextBeforeRenderClient>(pageContext: PC, isClientRouting: boolean): Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { getPageContextProxyForUser };
|
|
2
2
|
import { assert, assertUsage, assertWarning, getGlobalObject, getPropAccessNotation } from '../server-routing-runtime/utils.js';
|
|
3
3
|
import { notSerializable } from '../../shared/notSerializable.js';
|
|
4
|
-
const globalObject = getGlobalObject('getPageContextProxyForUser.ts', {});
|
|
4
|
+
const globalObject = getGlobalObject('shared/getPageContextProxyForUser.ts', {});
|
|
5
5
|
/**
|
|
6
6
|
* Throw error when pageContext value isn't:
|
|
7
7
|
* - serializable, or
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { loadUserFilesClientSide };
|
|
2
2
|
export { isErrorFetchingStaticAssets };
|
|
3
3
|
export type { PageContextUserFiles };
|
|
4
|
-
import { type PageFile, type
|
|
4
|
+
import { type PageFile, type PageConfigUserFriendlyOld } from '../../shared/getPageFiles.js';
|
|
5
5
|
import type { PageConfigGlobalRuntime, PageConfigRuntime } from '../../shared/page-configs/PageConfig.js';
|
|
6
|
-
type PageContextUserFilesLoaded =
|
|
6
|
+
type PageContextUserFilesLoaded = PageConfigUserFriendlyOld & {
|
|
7
7
|
_pageFilesLoaded: PageFile[];
|
|
8
8
|
};
|
|
9
9
|
type PageContextUserFiles = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { loadUserFilesClientSide };
|
|
2
2
|
export { isErrorFetchingStaticAssets };
|
|
3
3
|
import { getPageFilesClientSide } from '../../shared/getPageFiles.js';
|
|
4
|
-
import {
|
|
4
|
+
import { getPageConfigUserFriendly_oldDesign } from '../../shared/page-configs/getPageConfigUserFriendly.js';
|
|
5
5
|
import { findPageConfig } from '../../shared/page-configs/findPageConfig.js';
|
|
6
6
|
import { loadConfigValues } from '../../shared/page-configs/loadConfigValues.js';
|
|
7
7
|
import { objectAssign } from '../server-routing-runtime/utils.js';
|
|
@@ -30,7 +30,7 @@ async function loadUserFilesClientSide(pageId, pageFilesAll, pageConfigs, pageCo
|
|
|
30
30
|
}
|
|
31
31
|
throw err;
|
|
32
32
|
}
|
|
33
|
-
const pageContextExports =
|
|
33
|
+
const pageContextExports = getPageConfigUserFriendly_oldDesign(pageFilesClientSide, pageConfigLoaded, pageConfigGlobal);
|
|
34
34
|
const pageContextAddendum = {};
|
|
35
35
|
objectAssign(pageContextAddendum, pageContextExports);
|
|
36
36
|
objectAssign(pageContextAddendum, { _pageFilesLoaded: pageFilesClientSide });
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { preparePageContextForUserConsumptionClientSide };
|
|
2
2
|
export type { PageContextForUserConsumptionClientSide };
|
|
3
|
-
import type {
|
|
3
|
+
import type { PageConfigUserFriendlyOld } from '../../shared/getPageFiles.js';
|
|
4
4
|
import type { PageConfigRuntime } from '../../shared/page-configs/PageConfig.js';
|
|
5
5
|
import { PageContextForPassToClientWarning } from './getPageContextProxyForUser.js';
|
|
6
|
-
type PageContextForUserConsumptionClientSide =
|
|
6
|
+
type PageContextForUserConsumptionClientSide = PageConfigUserFriendlyOld & PageContextForPassToClientWarning & {
|
|
7
7
|
pageId: string;
|
|
8
8
|
_pageConfigs: PageConfigRuntime[];
|
|
9
9
|
};
|
|
@@ -10,7 +10,7 @@ import path from 'path';
|
|
|
10
10
|
import { assert, assertUsage, getGlobalObject, isObject, toPosixPath } from './utils.js';
|
|
11
11
|
import pc from '@brillout/picocolors';
|
|
12
12
|
import { clearGlobalContext } from '../runtime/globalContext.js';
|
|
13
|
-
const globalObject = getGlobalObject('prepareViteApiCall.ts', {});
|
|
13
|
+
const globalObject = getGlobalObject('api/prepareViteApiCall.ts', {});
|
|
14
14
|
async function prepareViteApiCall(viteConfigFromOptions, operation) {
|
|
15
15
|
clear();
|
|
16
16
|
setContextApiOperation(operation);
|
|
@@ -4,7 +4,10 @@ export { plugin as ssr };
|
|
|
4
4
|
export type { VikeVitePluginOptions as UserConfig };
|
|
5
5
|
export type { VikeVitePluginOptions };
|
|
6
6
|
export { PROJECT_VERSION as version } from './utils.js';
|
|
7
|
-
|
|
7
|
+
type PluginInterop = Record<string, unknown> & {
|
|
8
|
+
name: string;
|
|
9
|
+
};
|
|
10
|
+
declare function plugin(vikeVitePluginOptions?: VikeVitePluginOptions): PluginInterop[];
|
|
8
11
|
/** @deprecated Define Vike settings in +config.js instead of vite.config.js */
|
|
9
12
|
type VikeVitePluginOptions = {
|
|
10
13
|
/** @deprecated Define Vike settings in +config.js instead of vite.config.js */
|
|
@@ -29,7 +29,7 @@ import { workaroundVite6HmrRegression } from './plugins/workaroundVite6HmrRegres
|
|
|
29
29
|
import { buildApp } from './plugins/buildApp.js';
|
|
30
30
|
// We don't call this in ./onLoad.ts to avoid a cyclic dependency with utils.ts
|
|
31
31
|
setResolveClientEntriesDev(resolveClientEntriesDev);
|
|
32
|
-
// Return
|
|
32
|
+
// Return `PluginInterop` instead of `Plugin` to avoid type mismatch upon different Vite versions
|
|
33
33
|
function plugin(vikeVitePluginOptions = {}) {
|
|
34
34
|
const plugins = [
|
|
35
35
|
...commonConfig(vikeVitePluginOptions),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { baseUrls };
|
|
2
|
-
import { resolveBase
|
|
2
|
+
import { resolveBase } from '../../shared/resolveBase.js';
|
|
3
3
|
import { assert } from '../utils.js';
|
|
4
4
|
import { getVikeConfig } from './importUserCode/v1-design/getVikeConfig.js';
|
|
5
5
|
function baseUrls() {
|
|
@@ -38,3 +38,8 @@ function baseUrls() {
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
+
function resolveBaseFromResolvedConfig(baseServer, baseAssets, config) {
|
|
42
|
+
let baseViteOriginal = config._baseViteOriginal;
|
|
43
|
+
assert(baseViteOriginal === null || typeof baseViteOriginal == 'string');
|
|
44
|
+
return resolveBase(baseViteOriginal, baseServer, baseAssets);
|
|
45
|
+
}
|
|
@@ -7,6 +7,9 @@ import { getVikeConfig } from './importUserCode/v1-design/getVikeConfig.js';
|
|
|
7
7
|
import { getFullBuildInlineConfig } from '../shared/getFullBuildInlineConfig.js';
|
|
8
8
|
function buildApp() {
|
|
9
9
|
let config;
|
|
10
|
+
// `builder.buildApp` can be overriden by another plugin e.g vike-vercel https://github.com/vikejs/vike/pull/2184#issuecomment-2659425195
|
|
11
|
+
// In that case, we should'nt `forceExit`.
|
|
12
|
+
let forceExit = false;
|
|
10
13
|
return [
|
|
11
14
|
{
|
|
12
15
|
name: 'vike:buildApp',
|
|
@@ -21,6 +24,10 @@ function buildApp() {
|
|
|
21
24
|
assert(builder.environments.ssr);
|
|
22
25
|
await builder.build(builder.environments.client);
|
|
23
26
|
await builder.build(builder.environments.ssr);
|
|
27
|
+
if (forceExit) {
|
|
28
|
+
runPrerender_forceExit();
|
|
29
|
+
assert(false);
|
|
30
|
+
}
|
|
24
31
|
}
|
|
25
32
|
},
|
|
26
33
|
environments: {
|
|
@@ -59,11 +66,8 @@ function buildApp() {
|
|
|
59
66
|
if (!isPrerenderAutoRunEnabled(vikeConfig))
|
|
60
67
|
return;
|
|
61
68
|
const configInline = getFullBuildInlineConfig(config);
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
runPrerender_forceExit();
|
|
65
|
-
assert(false);
|
|
66
|
-
}
|
|
69
|
+
const res = await runPrerenderFromAutoRun(configInline, config);
|
|
70
|
+
forceExit = res.forceExit;
|
|
67
71
|
}
|
|
68
72
|
}
|
|
69
73
|
];
|
|
@@ -80,6 +80,9 @@ function buildConfig() {
|
|
|
80
80
|
{
|
|
81
81
|
name: 'vike:buildConfig:pre',
|
|
82
82
|
apply: 'build',
|
|
83
|
+
applyToEnvironment(env) {
|
|
84
|
+
return env.name === 'ssr';
|
|
85
|
+
},
|
|
83
86
|
// Make sure other writeBundle() hooks are called after this writeBundle() hook.
|
|
84
87
|
// - set_ASSETS_MANIFEST() needs to be called before dist/server/ code is executed.
|
|
85
88
|
// - For example, the writeBundle() hook of vite-plugin-vercel needs to be called after this writeBundle() hook, otherwise: https://github.com/vikejs/vike/issues/1527
|
|
@@ -4,6 +4,7 @@ import { assert, assertPosixPath, assertUsage, assertWarning, escapeRegex, isArr
|
|
|
4
4
|
import { sourceMapPassthrough } from '../shared/rollupSourceMap.js';
|
|
5
5
|
import { getModuleFilePathAbsolute } from '../shared/getFilePath.js';
|
|
6
6
|
import { normalizeId } from '../shared/normalizeId.js';
|
|
7
|
+
import { viteIsSSR_safe } from '../shared/viteIsSSR.js';
|
|
7
8
|
// TODO/enventually: (after we implemented vike.config.js)
|
|
8
9
|
// - Make import.meta.env work inside +config.js
|
|
9
10
|
// - 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
|
|
@@ -36,7 +37,7 @@ function envVarsPlugin() {
|
|
|
36
37
|
if (!code.includes('import.meta.env.'))
|
|
37
38
|
return;
|
|
38
39
|
const isBuild = config.command === 'build';
|
|
39
|
-
const isClientSide =
|
|
40
|
+
const isClientSide = !viteIsSSR_safe(config, options);
|
|
40
41
|
Object.entries(envsAll)
|
|
41
42
|
.filter(([key]) => {
|
|
42
43
|
// Already handled by Vite
|
|
@@ -82,20 +83,3 @@ function envVarsPlugin() {
|
|
|
82
83
|
function applyEnvVar(envStatementRegEx, envVal, code) {
|
|
83
84
|
return code.replace(envStatementRegEx, JSON.stringify(envVal));
|
|
84
85
|
}
|
|
85
|
-
function getIsClientSide(config, options) {
|
|
86
|
-
const isBuild = config.command === 'build';
|
|
87
|
-
if (isBuild) {
|
|
88
|
-
assert(typeof config.build.ssr === 'boolean');
|
|
89
|
-
const isServerSide = config.build.ssr;
|
|
90
|
-
if (options !== undefined) {
|
|
91
|
-
assert(options.ssr === isServerSide);
|
|
92
|
-
}
|
|
93
|
-
return !isServerSide;
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
assert(config.build.ssr === false);
|
|
97
|
-
assert(typeof options?.ssr === 'boolean');
|
|
98
|
-
const isServerSide = options.ssr;
|
|
99
|
-
return !isServerSide;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
@@ -17,7 +17,7 @@ import { fixServerAssets_isEnabled } from './buildConfig/fixServerAssets.js';
|
|
|
17
17
|
import { getVikeConfig, isV1Design } from './importUserCode/v1-design/getVikeConfig.js';
|
|
18
18
|
import { assertV1Design } from '../../shared/assertV1Design.js';
|
|
19
19
|
import { normalizeId } from '../shared/normalizeId.js';
|
|
20
|
-
import {
|
|
20
|
+
import { viteIsSSR_safe } from '../shared/viteIsSSR.js';
|
|
21
21
|
const extractAssetsRE = /(\?|&)extractAssets(?:&|$)/;
|
|
22
22
|
const rawRE = /(\?|&)raw(?:&|$)/;
|
|
23
23
|
const urlRE = /(\?|&)url(?:&|$)/;
|
|
@@ -46,7 +46,7 @@ function extractAssetsPlugin() {
|
|
|
46
46
|
}
|
|
47
47
|
// TODO/now: add meta.default
|
|
48
48
|
assert(vikeConfig.global.config.includeAssetsImportedByServer ?? true);
|
|
49
|
-
assert(!
|
|
49
|
+
assert(!viteIsSSR_safe(config, options));
|
|
50
50
|
const importStatements = await getImportStatements(src);
|
|
51
51
|
const moduleNames = getImportedModules(importStatements);
|
|
52
52
|
const code = moduleNames.map((moduleName) => `import '${moduleName}';`).join('\n');
|
|
@@ -63,7 +63,7 @@ function extractAssetsPlugin() {
|
|
|
63
63
|
// - Vite's `vite:resolve` plugin; https://github.com/vitejs/vite/blob/d649daba7682791178b711d9a3e44a6b5d00990c/packages/vite/src/node/plugins/resolve.ts#L105
|
|
64
64
|
enforce: 'pre',
|
|
65
65
|
async resolveId(source, importer, options) {
|
|
66
|
-
if (
|
|
66
|
+
if (viteIsSSR_safe(config, options)) {
|
|
67
67
|
// When building for the server, there should never be a `?extractAssets` query
|
|
68
68
|
assert(!extractAssetsRE.test(source));
|
|
69
69
|
assert(importer === undefined || !extractAssetsRE.test(importer));
|
|
@@ -8,7 +8,7 @@ import { normalizeId } from '../shared/normalizeId.js';
|
|
|
8
8
|
import { viteIsSSR_options } from '../shared/viteIsSSR.js';
|
|
9
9
|
const extractExportNamesRE = /(\?|&)extractExportNames(?:&|$)/;
|
|
10
10
|
const debug = createDebugger('vike:extractExportNames');
|
|
11
|
-
const globalObject = getGlobalObject('extractExportNamesPlugin.ts', {});
|
|
11
|
+
const globalObject = getGlobalObject('plugins/extractExportNamesPlugin.ts', {});
|
|
12
12
|
function extractExportNamesPlugin() {
|
|
13
13
|
let isDev = false;
|
|
14
14
|
return {
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -11,7 +11,7 @@ import { getEnvVarObject } from '../../../../shared/getEnvVarObject.js';
|
|
|
11
11
|
const execA = promisify(exec);
|
|
12
12
|
const debug = createDebugger('vike:crawl');
|
|
13
13
|
assertIsNotProductionRuntime();
|
|
14
|
-
assertIsSingleModuleInstance('crawlPlusFiles.ts');
|
|
14
|
+
assertIsSingleModuleInstance('getVikeConfig/crawlPlusFiles.ts');
|
|
15
15
|
let gitIsNotUsable = false;
|
|
16
16
|
async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem) {
|
|
17
17
|
assertPosixPath(userRootDir);
|
|
@@ -9,12 +9,12 @@ export type { VikeConfigObject };
|
|
|
9
9
|
import type { PageConfigGlobalBuildTime, PageConfigBuildTime } from '../../../../../shared/page-configs/PageConfig.js';
|
|
10
10
|
import { type ConfigDefinitions, type ConfigDefinitionInternal } from './getVikeConfig/configDefinitionsBuiltIn.js';
|
|
11
11
|
import type { ResolvedConfig } from 'vite';
|
|
12
|
-
import { type
|
|
12
|
+
import { type PageConfigUserFriendly, type PageConfigsUserFriendly } from '../../../../../shared/page-configs/getPageConfigUserFriendly.js';
|
|
13
13
|
import { type PlusFile } from './getVikeConfig/getPlusFilesAll.js';
|
|
14
14
|
type VikeConfigObject = {
|
|
15
15
|
pageConfigs: PageConfigBuildTime[];
|
|
16
16
|
pageConfigGlobal: PageConfigGlobalBuildTime;
|
|
17
|
-
global:
|
|
17
|
+
global: PageConfigUserFriendly;
|
|
18
18
|
pages: PageConfigsUserFriendly;
|
|
19
19
|
};
|
|
20
20
|
declare const vikeConfigDependencies: Set<string>;
|
|
@@ -8,7 +8,7 @@ export { getConfigDefinitionOptional };
|
|
|
8
8
|
import { assertPosixPath, assert, isObject, assertUsage, assertWarning, objectEntries, hasProp, includes, assertIsNotProductionRuntime, getMostSimilar, joinEnglish, assertKeys, objectKeys, objectFromEntries, unique, isCallable, makeFirst, lowerFirst } from '../../../utils.js';
|
|
9
9
|
import { configDefinitionsBuiltIn } from './getVikeConfig/configDefinitionsBuiltIn.js';
|
|
10
10
|
import { getLocationId, getFilesystemRouteString, getFilesystemRouteDefinedBy, isInherited, sortAfterInheritanceOrder, applyFilesystemRoutingRootEffect } from './getVikeConfig/filesystemRouting.js';
|
|
11
|
-
import {
|
|
11
|
+
import { isVikeConfigInvalid, isVikeConfigInvalid_set } from '../../../../runtime/renderPage/isVikeConfigInvalid.js';
|
|
12
12
|
import { getViteDevServer } from '../../../../runtime/globalContext.js';
|
|
13
13
|
import { logConfigError, logConfigErrorRecover } from '../../../shared/loggerNotProd.js';
|
|
14
14
|
import { removeSuperfluousViteLog_enable, removeSuperfluousViteLog_disable } from '../../../shared/loggerVite/removeSuperfluousViteLog.js';
|
|
@@ -19,7 +19,7 @@ import { resolvePointerImport } from './getVikeConfig/resolvePointerImport.js';
|
|
|
19
19
|
import { getFilePathResolved } from '../../../shared/getFilePath.js';
|
|
20
20
|
import { getConfigValueBuildTime } from '../../../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
21
21
|
import { assertExtensionsRequire } from './getVikeConfig/assertExtensions.js';
|
|
22
|
-
import {
|
|
22
|
+
import { getPageConfigGlobalUserFriendly, getPageConfigUserFriendly } from '../../../../../shared/page-configs/getPageConfigUserFriendly.js';
|
|
23
23
|
import { getConfigValuesBase } from '../../../../../shared/page-configs/serialize/serializeConfigValues.js';
|
|
24
24
|
import { getPlusFilesAll } from './getVikeConfig/getPlusFilesAll.js';
|
|
25
25
|
assertIsNotProductionRuntime();
|
|
@@ -37,7 +37,7 @@ function reloadVikeConfig(config) {
|
|
|
37
37
|
handleReloadSideEffects();
|
|
38
38
|
}
|
|
39
39
|
async function handleReloadSideEffects() {
|
|
40
|
-
wasConfigInvalid = !!
|
|
40
|
+
wasConfigInvalid = !!isVikeConfigInvalid;
|
|
41
41
|
const vikeConfigPromisePrevious = vikeConfigPromise;
|
|
42
42
|
try {
|
|
43
43
|
await vikeConfigPromise;
|
|
@@ -52,7 +52,7 @@ async function handleReloadSideEffects() {
|
|
|
52
52
|
// Let the next handleReloadSideEffects() call handle side effects
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
|
-
if (!
|
|
55
|
+
if (!isVikeConfigInvalid) {
|
|
56
56
|
if (wasConfigInvalid) {
|
|
57
57
|
wasConfigInvalid = false;
|
|
58
58
|
logConfigErrorRecover();
|
|
@@ -105,13 +105,13 @@ async function loadVikeConfig_withErrorHandling(userRootDir, isDev, vikeVitePlug
|
|
|
105
105
|
if (!hasError) {
|
|
106
106
|
assert(ret);
|
|
107
107
|
assert(err === undefined);
|
|
108
|
-
|
|
108
|
+
isVikeConfigInvalid_set(false);
|
|
109
109
|
return ret;
|
|
110
110
|
}
|
|
111
111
|
else {
|
|
112
112
|
assert(ret === undefined);
|
|
113
113
|
assert(err);
|
|
114
|
-
|
|
114
|
+
isVikeConfigInvalid_set({ err });
|
|
115
115
|
if (!isDev) {
|
|
116
116
|
assert(getViteDevServer() === null);
|
|
117
117
|
throw err;
|
|
@@ -127,7 +127,7 @@ async function loadVikeConfig_withErrorHandling(userRootDir, isDev, vikeVitePlug
|
|
|
127
127
|
configDefinitions: {},
|
|
128
128
|
configValueSources: {}
|
|
129
129
|
},
|
|
130
|
-
global:
|
|
130
|
+
global: getPageConfigGlobalUserFriendly({ pageConfigGlobalValues: {} }),
|
|
131
131
|
pages: {}
|
|
132
132
|
};
|
|
133
133
|
return dummyData;
|
|
@@ -143,18 +143,12 @@ async function loadVikeConfig(userRootDir, vikeVitePluginOptions) {
|
|
|
143
143
|
// interop vike(options) in vite.config.js
|
|
144
144
|
temp_interopVikeVitePlugin(pageConfigGlobal, vikeVitePluginOptions, userRootDir);
|
|
145
145
|
// global
|
|
146
|
-
const
|
|
147
|
-
const global =
|
|
148
|
-
// TODO/now DEDUPE
|
|
146
|
+
const pageConfigGlobalValues = getConfigValues(pageConfigGlobal);
|
|
147
|
+
const global = getPageConfigGlobalUserFriendly({ pageConfigGlobalValues });
|
|
149
148
|
// pages
|
|
150
149
|
const pages = objectFromEntries(pageConfigs.map((pageConfig) => {
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
const page = {
|
|
154
|
-
...getPageConfigUserFriendlyNew({ configValues }),
|
|
155
|
-
route: pageConfig.routeFilesystem?.routeString ?? null
|
|
156
|
-
};
|
|
157
|
-
return [pageConfig.pageId, page];
|
|
150
|
+
const pageConfigValues = getConfigValues(pageConfig, true);
|
|
151
|
+
return getPageConfigUserFriendly(pageConfigGlobalValues, pageConfig, pageConfigValues);
|
|
158
152
|
}));
|
|
159
153
|
return { pageConfigs, pageConfigGlobal, global, pages };
|
|
160
154
|
}
|
|
@@ -219,13 +213,12 @@ function getPageConfigsBuildTime(configDefinitionsResolved, plusFilesAll, userRo
|
|
|
219
213
|
return;
|
|
220
214
|
configValueSources[configName] = sources;
|
|
221
215
|
});
|
|
222
|
-
const
|
|
216
|
+
const pageConfigRoute = determineRouteFilesystem(locationId, configValueSources);
|
|
223
217
|
applyEffectsAll(configValueSources, configDefinitionsLocal);
|
|
224
218
|
const configValuesComputed = getComputed(configValueSources, configDefinitionsLocal);
|
|
225
219
|
const pageConfig = {
|
|
226
220
|
pageId: locationId,
|
|
227
|
-
|
|
228
|
-
routeFilesystem,
|
|
221
|
+
...pageConfigRoute,
|
|
229
222
|
configDefinitions: configDefinitionsLocal,
|
|
230
223
|
plusFiles: plusFilesRelevant,
|
|
231
224
|
configValueSources,
|
|
@@ -424,20 +417,10 @@ function getPlusFilesOrdered(configName, plusFilesRelevant) {
|
|
|
424
417
|
const plusFilesConfig = plusFilesForConfigName.filter((plusFile) => plusFile.isConfigFile &&
|
|
425
418
|
// We consider extensions (e.g. vike-react) later (i.e. with less priority)
|
|
426
419
|
!plusFile.isExtensionConfig);
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
const plusFileWinner = plusFilesValue[0] ?? plusFilesConfig[0];
|
|
432
|
-
if (plusFileWinner) {
|
|
433
|
-
const plusFilesOverriden = [...plusFilesValue, ...plusFilesConfig].filter((f) => f !== plusFileWinner);
|
|
434
|
-
// A user-land conflict of plusFiles with the same `locationId` (we are iterating over `plusFilesRelevant: PlusFilesByLocationId`) means that the user has superfluously defined the config twice; the user should remove such redundancy as it makes things unnecessarily ambiguous.
|
|
435
|
-
assertOverwrittenConfigFile(plusFileWinner, plusFilesOverriden, configName);
|
|
436
|
-
[plusFileWinner, ...plusFilesOverriden].forEach((plusFile) => {
|
|
437
|
-
assert(plusFile.filePath.filePathAbsoluteUserRootDir); // ensure it's a user-land plus file
|
|
438
|
-
populate(plusFile);
|
|
439
|
-
});
|
|
440
|
-
}
|
|
420
|
+
[...plusFilesValue, ...plusFilesConfig].forEach((plusFile) => {
|
|
421
|
+
assert(plusFile.filePath.filePathAbsoluteUserRootDir); // ensure it's a user-land plus file
|
|
422
|
+
populate(plusFile);
|
|
423
|
+
});
|
|
441
424
|
}
|
|
442
425
|
// ==========================
|
|
443
426
|
// Side-effect configs (next)
|
|
@@ -589,14 +572,6 @@ function getConfigValueSource(configName, plusFile, configDef, userRootDir, isHi
|
|
|
589
572
|
}
|
|
590
573
|
assert(false);
|
|
591
574
|
}
|
|
592
|
-
function assertOverwrittenConfigFile(plusFileWinner, plusFilesOverriden, configName) {
|
|
593
|
-
plusFilesOverriden.forEach((plusFileLoser) => {
|
|
594
|
-
const loserFilePath = plusFileLoser.filePath.filePathToShowToUser;
|
|
595
|
-
const winnerFilePath = plusFileWinner.filePath.filePathToShowToUser;
|
|
596
|
-
const confName = pc.cyan(configName);
|
|
597
|
-
assertWarning(false, `The value of the config ${confName} defined at ${loserFilePath} is always overwritten by the value defined at ${winnerFilePath}, remove the superfluous value defined at ${loserFilePath}`, { onlyOnce: true });
|
|
598
|
-
});
|
|
599
|
-
}
|
|
600
575
|
function isDefiningPage(plusFiles) {
|
|
601
576
|
for (const plusFile of plusFiles) {
|
|
602
577
|
const configNames = getDefiningConfigNames(plusFile);
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// - We dedupe errors ourself with getHttpRequestAsyncStore().shouldErrorBeSwallowed()
|
|
11
11
|
export { getHttpRequestAsyncStore };
|
|
12
12
|
export { installHttpRequestAsyncStore };
|
|
13
|
-
import {
|
|
13
|
+
import { renderPage_addAsyncHookwrapper } from '../../runtime/renderPage.js';
|
|
14
14
|
import { assert, assertIsNotProductionRuntime, isObject, unique } from '../utils.js';
|
|
15
15
|
import { getConfigBuildErrorFormatted } from '../plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js';
|
|
16
16
|
import { logErrorDebugNote } from './loggerNotProd.js';
|
|
@@ -27,7 +27,7 @@ async function installHttpRequestAsyncStore() {
|
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
asyncLocalStorage = new mod.AsyncLocalStorage();
|
|
30
|
-
|
|
30
|
+
renderPage_addAsyncHookwrapper(async (httpRequestId, renderPage) => {
|
|
31
31
|
assert(asyncLocalStorage);
|
|
32
32
|
const loggedErrors = new Set();
|
|
33
33
|
const markErrorAsLogged = (err) => {
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import type { ResolvedConfig, UserConfig } from 'vite';
|
|
2
1
|
export { viteIsSSR };
|
|
3
2
|
export { viteIsSSR_options };
|
|
3
|
+
export { viteIsSSR_safe };
|
|
4
|
+
import type { ResolvedConfig, UserConfig } from 'vite';
|
|
4
5
|
declare function viteIsSSR(config: ResolvedConfig | UserConfig): boolean;
|
|
5
|
-
|
|
6
|
+
declare function viteIsSSR_options(options: {
|
|
7
|
+
ssr?: boolean;
|
|
8
|
+
} | undefined): boolean;
|
|
9
|
+
declare function viteIsSSR_safe(config: ResolvedConfig, options: {
|
|
6
10
|
ssr?: boolean;
|
|
7
|
-
};
|
|
8
|
-
declare function viteIsSSR_options(options: Options): boolean;
|
|
11
|
+
} | undefined): boolean;
|
|
@@ -1,20 +1,29 @@
|
|
|
1
|
-
import { assert } from '../../../utils/assert.js';
|
|
2
|
-
import { isObject } from '../../../utils/isObject.js';
|
|
3
1
|
export { viteIsSSR };
|
|
4
2
|
export { viteIsSSR_options };
|
|
3
|
+
export { viteIsSSR_safe };
|
|
4
|
+
import { assert } from '../../../utils/assert.js';
|
|
5
5
|
function viteIsSSR(config) {
|
|
6
6
|
return !!config?.build?.ssr;
|
|
7
7
|
}
|
|
8
|
-
// https://github.com/vitejs/vite/discussions/5109#discussioncomment-1450726
|
|
9
8
|
function viteIsSSR_options(options) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
return !!options?.ssr;
|
|
10
|
+
}
|
|
11
|
+
// Vite is quite messy about setting `ssr: boolean`, thus we use an extra safe implemention for security purposes.
|
|
12
|
+
// It's used for .client.js and .server.js guarantee thus we use agressive assert() calls for added safety.
|
|
13
|
+
function viteIsSSR_safe(config, options) {
|
|
14
|
+
if (config.command === 'build') {
|
|
15
|
+
assert(typeof config.build.ssr === 'boolean');
|
|
16
|
+
const val = config.build.ssr;
|
|
17
|
+
if (options?.ssr !== undefined)
|
|
18
|
+
assert(val === options.ssr);
|
|
19
|
+
return val;
|
|
15
20
|
}
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
else {
|
|
22
|
+
assert(typeof options?.ssr === 'boolean');
|
|
23
|
+
const val = options.ssr;
|
|
24
|
+
/* This assert() fails (which is very unexpected).
|
|
25
|
+
if (typeof config.build.ssr === 'boolean') assert(val === config.build.ssr)
|
|
26
|
+
//*/
|
|
27
|
+
return val;
|
|
18
28
|
}
|
|
19
|
-
assert(false);
|
|
20
29
|
}
|