vike 0.4.239-commit-4d0d950 → 0.4.239-commit-86a0513
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/esm/client/index.d.ts +1 -1
- package/dist/esm/client/index.js +1 -1
- package/dist/esm/client/runtime-client-routing/createPageContextClientSide.js +1 -1
- package/dist/esm/client/runtime-client-routing/entry.js +3 -6
- package/dist/esm/client/runtime-client-routing/getBaseServer.js +0 -1
- package/dist/esm/client/runtime-client-routing/{globalContext.js → getGlobalContextClientInternal.js} +2 -4
- package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.d.ts +4 -4
- package/dist/esm/client/runtime-client-routing/isClientSideRoutable.d.ts +1 -1
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.d.ts +1 -1
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.js +2 -5
- package/dist/esm/client/runtime-server-routing/createPageContextClientSide.js +1 -1
- package/dist/esm/client/runtime-server-routing/entry.js +3 -6
- package/dist/esm/client/runtime-server-routing/getGlobalContextClientInternal.js +6 -0
- package/dist/esm/client/shared/execHookOnRenderClient.d.ts +1 -1
- package/dist/esm/client/shared/{createGetGlobalContextClient.d.ts → getGlobalContextClientInternalShared.d.ts} +9 -7
- package/dist/esm/client/shared/{createGetGlobalContextClient.js → getGlobalContextClientInternalShared.js} +12 -15
- package/dist/esm/client/shared/loadPageConfigsLazyClientSide.js +1 -3
- package/dist/esm/node/prerender/runPrerender.js +3 -1
- package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +39 -24
- package/dist/esm/node/vite/shared/getMagicString.js +3 -0
- package/dist/esm/shared/createGlobalContextShared.d.ts +1 -1
- package/dist/esm/shared/createGlobalContextShared.js +0 -1
- package/dist/esm/types/PageContext.d.ts +8 -8
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/package.json +2 -2
- package/dist/esm/client/runtime-server-routing/globalContext.js +0 -9
- /package/dist/esm/client/runtime-client-routing/{globalContext.d.ts → getGlobalContextClientInternal.d.ts} +0 -0
- /package/dist/esm/client/runtime-server-routing/{globalContext.d.ts → getGlobalContextClientInternal.d.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
export { getGlobalContext, getGlobalContext as getGlobalContextAsync, getGlobalContextSync, } from './shared/
|
|
1
|
+
export { getGlobalContext, getGlobalContext as getGlobalContextAsync, getGlobalContextSync, } from './shared/getGlobalContextClientInternalShared.js';
|
package/dist/esm/client/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { isBrowser } from '../utils/isBrowser.js';
|
|
2
2
|
import { assert } from '../utils/assert.js';
|
|
3
3
|
assert(isBrowser());
|
|
4
|
-
export { getGlobalContext, getGlobalContext as getGlobalContextAsync, getGlobalContextSync, } from './shared/
|
|
4
|
+
export { getGlobalContext, getGlobalContext as getGlobalContextAsync, getGlobalContextSync, } from './shared/getGlobalContextClientInternalShared.js';
|
|
@@ -2,7 +2,7 @@ export { createPageContextClientSide };
|
|
|
2
2
|
import { createPageContextObject, createPageContextShared } from '../../shared/createPageContextShared.js';
|
|
3
3
|
import { getPageContextUrlComputed } from '../../shared/getPageContextUrlComputed.js';
|
|
4
4
|
import { getBaseServer } from './getBaseServer.js';
|
|
5
|
-
import { getGlobalContextClientInternal } from './
|
|
5
|
+
import { getGlobalContextClientInternal } from './getGlobalContextClientInternal.js';
|
|
6
6
|
import { assert, updateType, isBaseServer, objectAssign } from './utils.js';
|
|
7
7
|
async function createPageContextClientSide(urlOriginal) {
|
|
8
8
|
const globalContext = await getGlobalContextClientInternal();
|
|
@@ -3,14 +3,11 @@ assertClientRouting();
|
|
|
3
3
|
import { initClientRouter } from './initClientRouter.js';
|
|
4
4
|
import { assertSingleInstance_onClientEntryClientRouting } from './utils.js';
|
|
5
5
|
import { removeFoucBuster } from '../shared/removeFoucBuster.js';
|
|
6
|
-
import { setVirtualFileExportsGlobalEntry } from '../shared/
|
|
6
|
+
import { setVirtualFileExportsGlobalEntry } from '../shared/getGlobalContextClientInternalShared.js';
|
|
7
7
|
// @ts-expect-error
|
|
8
8
|
import * as virtualFileExportsGlobalEntry from 'virtual:vike:global-entry:client:client-routing';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const isProd = import.meta.env.PROD;
|
|
12
|
-
assertSingleInstance_onClientEntryClientRouting(isProd);
|
|
13
|
-
setVirtualFileExportsGlobalEntry(virtualFileExportsGlobalEntry, true);
|
|
9
|
+
assertSingleInstance_onClientEntryClientRouting(import.meta.env.PROD);
|
|
10
|
+
setVirtualFileExportsGlobalEntry(virtualFileExportsGlobalEntry);
|
|
14
11
|
initClientRouter();
|
|
15
12
|
if (import.meta.env.DEV)
|
|
16
13
|
removeFoucBuster();
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { getBaseServer };
|
|
2
2
|
import { assert } from '../runtime-server-routing/utils.js';
|
|
3
3
|
function getBaseServer() {
|
|
4
|
-
// @ts-ignore Since dist/cjs/client/ is never used, we can ignore this error.
|
|
5
4
|
const baseServer = import.meta.env.BASE_SERVER;
|
|
6
5
|
assert(isBaseServer(baseServer));
|
|
7
6
|
return baseServer;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
// TODO/now: rename file
|
|
2
|
-
// TODO/now: rename export
|
|
3
1
|
export { getGlobalContextClientInternal };
|
|
4
|
-
import {
|
|
2
|
+
import { getGlobalContextClientInternalShared } from '../shared/getGlobalContextClientInternalShared.js';
|
|
5
3
|
import { loadPageRoutes } from '../../shared/route/loadPageRoutes.js';
|
|
6
4
|
import { objectAssign } from './utils.js';
|
|
7
5
|
async function getGlobalContextClientInternal() {
|
|
8
|
-
const globalContext = await
|
|
6
|
+
const globalContext = await getGlobalContextClientInternalShared();
|
|
9
7
|
objectAssign(globalContext, await addGlobalContext(globalContext));
|
|
10
8
|
return globalContext;
|
|
11
9
|
}
|
|
@@ -145,7 +145,7 @@ declare function getPageContextFromHooks_isHydration(pageContext: PageContextSer
|
|
|
145
145
|
isHydration: boolean;
|
|
146
146
|
isBackwardNavigation: boolean | null;
|
|
147
147
|
previousPageContext: import("../../types/PageContext.js").PageContextClient<unknown> | null;
|
|
148
|
-
globalContext: import("./
|
|
148
|
+
globalContext: import("./getGlobalContextClientInternal.js").GlobalContextClient;
|
|
149
149
|
} & {
|
|
150
150
|
urlOriginal: string;
|
|
151
151
|
} & {
|
|
@@ -210,7 +210,7 @@ declare function getPageContextFromHooks_isHydration(pageContext: PageContextSer
|
|
|
210
210
|
isHydration: boolean;
|
|
211
211
|
isBackwardNavigation: boolean | null;
|
|
212
212
|
previousPageContext: import("../../types/PageContext.js").PageContextClient<unknown> | null;
|
|
213
|
-
globalContext: import("./
|
|
213
|
+
globalContext: import("./getGlobalContextClientInternal.js").GlobalContextClient;
|
|
214
214
|
} & {
|
|
215
215
|
urlOriginal: string;
|
|
216
216
|
} & {
|
|
@@ -366,7 +366,7 @@ declare function getPageContextFromClientHooks(pageContext: {
|
|
|
366
366
|
isHydration: boolean;
|
|
367
367
|
isBackwardNavigation: boolean | null;
|
|
368
368
|
previousPageContext: import("../../types/PageContext.js").PageContextClient<unknown> | null;
|
|
369
|
-
globalContext: import("./
|
|
369
|
+
globalContext: import("./getGlobalContextClientInternal.js").GlobalContextClient;
|
|
370
370
|
} & {
|
|
371
371
|
urlOriginal: string;
|
|
372
372
|
} & {
|
|
@@ -429,7 +429,7 @@ declare function getPageContextFromClientHooks(pageContext: {
|
|
|
429
429
|
isHydration: boolean;
|
|
430
430
|
isBackwardNavigation: boolean | null;
|
|
431
431
|
previousPageContext: import("../../types/PageContext.js").PageContextClient<unknown> | null;
|
|
432
|
-
globalContext: import("./
|
|
432
|
+
globalContext: import("./getGlobalContextClientInternal.js").GlobalContextClient;
|
|
433
433
|
} & {
|
|
434
434
|
urlOriginal: string;
|
|
435
435
|
} & {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { isClientSideRoutable };
|
|
2
|
-
import type { GlobalContextClientInternal } from './
|
|
2
|
+
import type { GlobalContextClientInternal } from './getGlobalContextClientInternal.js';
|
|
3
3
|
import type { PageFile } from '../../shared/getPageFiles.js';
|
|
4
4
|
declare function isClientSideRoutable(pageId: string, pageContext: {
|
|
5
5
|
_globalContext: GlobalContextClientInternal;
|
|
@@ -156,7 +156,7 @@ declare function getPageContextBegin(isForErrorPage: boolean, { urlOriginal, isB
|
|
|
156
156
|
isHydration: boolean;
|
|
157
157
|
isBackwardNavigation: boolean | null;
|
|
158
158
|
previousPageContext: PageContextClient<unknown> | null;
|
|
159
|
-
globalContext: import("./
|
|
159
|
+
globalContext: import("./getGlobalContextClientInternal.js").GlobalContextClient;
|
|
160
160
|
} & {
|
|
161
161
|
urlOriginal: string;
|
|
162
162
|
} & {
|
|
@@ -511,11 +511,9 @@ function disableClientRouting(err, log) {
|
|
|
511
511
|
// We don't use console.error() to avoid flooding error trackers such as Sentry
|
|
512
512
|
console.log(err);
|
|
513
513
|
}
|
|
514
|
-
// @ts-ignore Since dist/cjs/client/ is never used, we can ignore this error.
|
|
515
|
-
const isProd = import.meta.env.PROD;
|
|
516
514
|
assertInfo(false, [
|
|
517
515
|
'Failed to fetch static asset.',
|
|
518
|
-
|
|
516
|
+
import.meta.env.PROD ? 'This usually happens when a new frontend is deployed.' : null,
|
|
519
517
|
'Falling back to Server Routing.',
|
|
520
518
|
'(The next page navigation will use Server Routing instead of Client Routing.)',
|
|
521
519
|
]
|
|
@@ -646,8 +644,7 @@ function handleErrorFetchingStaticAssets(err, pageContext, isFirstRender) {
|
|
|
646
644
|
}
|
|
647
645
|
// [HMR] If error page is shown => re-render whole page
|
|
648
646
|
if (import.meta.env.DEV && import.meta.hot)
|
|
649
|
-
|
|
650
|
-
import.meta.hot.on('vite:beforeUpdate', () => {
|
|
647
|
+
import.meta.hot.on('vite:afterUpdate', () => {
|
|
651
648
|
const pageContext = globalObject.renderedPageContext;
|
|
652
649
|
if (pageContext?.pageId && isErrorPage(pageContext.pageId, pageContext._globalContext._pageConfigs)) {
|
|
653
650
|
renderPageClientSide({
|
|
@@ -4,7 +4,7 @@ import { getPageContextSerializedInHtml } from '../shared/getJsonSerializedInHtm
|
|
|
4
4
|
import { loadPageConfigsLazyClientSide, } from '../shared/loadPageConfigsLazyClientSide.js';
|
|
5
5
|
import { getCurrentUrl } from '../shared/getCurrentUrl.js';
|
|
6
6
|
import { createPageContextObject, createPageContextShared } from '../../shared/createPageContextShared.js';
|
|
7
|
-
import { getGlobalContextClientInternal } from './
|
|
7
|
+
import { getGlobalContextClientInternal } from './getGlobalContextClientInternal.js';
|
|
8
8
|
import { preparePageContextForPublicUsageClient, } from './preparePageContextForPublicUsageClient.js';
|
|
9
9
|
import { execHook } from '../../shared/hooks/execHook.js';
|
|
10
10
|
const urlFirst = getCurrentUrl({ withoutHash: true });
|
|
@@ -6,14 +6,11 @@ import { assertSingleInstance_onClientEntryServerRouting } from './utils.js';
|
|
|
6
6
|
import { removeFoucBuster } from '../shared/removeFoucBuster.js';
|
|
7
7
|
import { execHook } from '../../shared/hooks/execHook.js';
|
|
8
8
|
import { preparePageContextForPublicUsageClient } from './preparePageContextForPublicUsageClient.js';
|
|
9
|
-
import { setVirtualFileExportsGlobalEntry } from '../shared/
|
|
9
|
+
import { setVirtualFileExportsGlobalEntry } from '../shared/getGlobalContextClientInternalShared.js';
|
|
10
10
|
// @ts-expect-error
|
|
11
11
|
import * as virtualFileExportsGlobalEntry from 'virtual:vike:global-entry:client:server-routing';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const isProd = import.meta.env.PROD;
|
|
15
|
-
assertSingleInstance_onClientEntryServerRouting(isProd);
|
|
16
|
-
setVirtualFileExportsGlobalEntry(virtualFileExportsGlobalEntry, false);
|
|
12
|
+
assertSingleInstance_onClientEntryServerRouting(import.meta.env.PROD);
|
|
13
|
+
setVirtualFileExportsGlobalEntry(virtualFileExportsGlobalEntry);
|
|
17
14
|
if (import.meta.env.DEV)
|
|
18
15
|
removeFoucBuster();
|
|
19
16
|
hydrate();
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { getGlobalContextClientInternal };
|
|
2
|
+
import { getGlobalContextClientInternalShared } from '../shared/getGlobalContextClientInternalShared.js';
|
|
3
|
+
async function getGlobalContextClientInternal() {
|
|
4
|
+
const globalContext = await getGlobalContextClientInternalShared();
|
|
5
|
+
return globalContext;
|
|
6
|
+
}
|
|
@@ -2,7 +2,7 @@ export { execHookOnRenderClient };
|
|
|
2
2
|
export type { PageContextBeforeRenderClient };
|
|
3
3
|
import type { PageFile, PageContextConfig } from '../../shared/getPageFiles.js';
|
|
4
4
|
import type { PageContextForPublicUsageClientShared } from './preparePageContextForPublicUsageClientShared.js';
|
|
5
|
-
import type { GlobalContextClientInternalShared } from './
|
|
5
|
+
import type { GlobalContextClientInternalShared } from './getGlobalContextClientInternalShared.js';
|
|
6
6
|
type PageContextBeforeRenderClient = {
|
|
7
7
|
_pageFilesLoaded: PageFile[];
|
|
8
8
|
urlOriginal?: string;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { getGlobalContext };
|
|
2
2
|
export { getGlobalContextSync };
|
|
3
3
|
export { setVirtualFileExportsGlobalEntry };
|
|
4
|
-
export {
|
|
4
|
+
export { getGlobalContextClientInternalShared };
|
|
5
5
|
export type GlobalContextClientInternalShared = GlobalContextClientInternal | GlobalContextClientInternalWithServerRouting;
|
|
6
|
-
import type { GlobalContextClientInternal } from '../runtime-client-routing/
|
|
7
|
-
import type { GlobalContextClientInternalWithServerRouting } from '../runtime-server-routing/
|
|
8
|
-
declare function
|
|
6
|
+
import type { GlobalContextClientInternal } from '../runtime-client-routing/getGlobalContextClientInternal.js';
|
|
7
|
+
import type { GlobalContextClientInternalWithServerRouting } from '../runtime-server-routing/getGlobalContextClientInternal.js';
|
|
8
|
+
declare function getGlobalContextClientInternalShared(): Promise<{
|
|
9
9
|
_globalConfigPublic: {
|
|
10
10
|
pages: {
|
|
11
11
|
[k: string]: {
|
|
@@ -53,13 +53,15 @@ declare function createGetGlobalContextClient(): Promise<{
|
|
|
53
53
|
_allPageIds: string[];
|
|
54
54
|
} & {
|
|
55
55
|
/**
|
|
56
|
-
* Whether the environment is client-side
|
|
56
|
+
* Whether the environment is the client-side:
|
|
57
|
+
* - In the browser, the value is `true`.
|
|
58
|
+
* - Upon SSR and pre-rendering, the value is `false`.
|
|
57
59
|
*
|
|
58
|
-
*
|
|
60
|
+
* https://vike.dev/globalContext#isClientSide
|
|
59
61
|
*/
|
|
60
62
|
isClientSide: true;
|
|
61
63
|
}>;
|
|
62
64
|
type NeverExported = never;
|
|
63
65
|
declare function getGlobalContext(): Promise<NeverExported>;
|
|
64
66
|
declare function getGlobalContextSync(): NeverExported;
|
|
65
|
-
declare function setVirtualFileExportsGlobalEntry(virtualFileExportsGlobalEntry: unknown
|
|
67
|
+
declare function setVirtualFileExportsGlobalEntry(virtualFileExportsGlobalEntry: unknown): Promise<void>;
|
|
@@ -3,32 +3,32 @@ export { getGlobalContext };
|
|
|
3
3
|
export { getGlobalContextSync };
|
|
4
4
|
export { setVirtualFileExportsGlobalEntry };
|
|
5
5
|
// Internal usage
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export { createGetGlobalContextClient };
|
|
9
|
-
import { createGlobalContextShared, getGlobalContextSyncErrMsg, } from '../../shared/createGlobalContextShared.js';
|
|
6
|
+
export { getGlobalContextClientInternalShared };
|
|
7
|
+
import { createGlobalContextShared, getGlobalContextSyncErrMsg } from '../../shared/createGlobalContextShared.js';
|
|
10
8
|
import { getGlobalContextSerializedInHtml } from './getJsonSerializedInHtml.js';
|
|
11
9
|
import { assert, assertUsage, genPromise, getGlobalObject, objectAssign, checkType } from './utils.js';
|
|
12
|
-
const globalObject = getGlobalObject('
|
|
10
|
+
const globalObject = getGlobalObject('getGlobalContextClientInternalShared.ts', (() => {
|
|
13
11
|
const { promise: globalContextInitialPromise, resolve: globalContextInitialPromiseResolve } = genPromise();
|
|
14
12
|
return {
|
|
15
13
|
globalContextInitialPromise,
|
|
16
14
|
globalContextInitialPromiseResolve,
|
|
17
15
|
};
|
|
18
16
|
})());
|
|
19
|
-
async function
|
|
17
|
+
async function getGlobalContextClientInternalShared() {
|
|
18
|
+
// Get
|
|
20
19
|
if (globalObject.globalContextPromise) {
|
|
21
20
|
const globalContext = await globalObject.globalContextPromise;
|
|
22
21
|
return globalContext;
|
|
23
22
|
}
|
|
24
23
|
// Create
|
|
25
|
-
const globalContextPromise = createGlobalContextShared(globalObject.virtualFileExportsGlobalEntry, globalObject,
|
|
24
|
+
const globalContextPromise = createGlobalContextShared(globalObject.virtualFileExportsGlobalEntry, globalObject, () => {
|
|
26
25
|
const globalContextAddendum = {
|
|
27
|
-
// TODO/now update JSDocs
|
|
28
26
|
/**
|
|
29
|
-
* Whether the environment is client-side
|
|
27
|
+
* Whether the environment is the client-side:
|
|
28
|
+
* - In the browser, the value is `true`.
|
|
29
|
+
* - Upon SSR and pre-rendering, the value is `false`.
|
|
30
30
|
*
|
|
31
|
-
*
|
|
31
|
+
* https://vike.dev/globalContext#isClientSide
|
|
32
32
|
*/
|
|
33
33
|
isClientSide: true,
|
|
34
34
|
};
|
|
@@ -55,15 +55,12 @@ function getGlobalContextSync() {
|
|
|
55
55
|
checkType(globalContext);
|
|
56
56
|
return globalContext;
|
|
57
57
|
}
|
|
58
|
-
async function setVirtualFileExportsGlobalEntry(virtualFileExportsGlobalEntry
|
|
59
|
-
// TODO/now: remove unused globalObject.isClientRouting
|
|
60
|
-
assert(globalObject.isClientRouting === undefined || globalObject.isClientRouting === isClientRouting);
|
|
61
|
-
globalObject.isClientRouting = isClientRouting;
|
|
58
|
+
async function setVirtualFileExportsGlobalEntry(virtualFileExportsGlobalEntry) {
|
|
62
59
|
// HMR => virtualFileExportsGlobalEntry differ
|
|
63
60
|
if (globalObject.virtualFileExportsGlobalEntry !== virtualFileExportsGlobalEntry) {
|
|
64
61
|
delete globalObject.globalContextPromise;
|
|
65
62
|
globalObject.virtualFileExportsGlobalEntry = virtualFileExportsGlobalEntry;
|
|
66
63
|
// Eagerly call +onCreateGlobalContext() hooks
|
|
67
|
-
await
|
|
64
|
+
await getGlobalContextClientInternalShared();
|
|
68
65
|
}
|
|
69
66
|
}
|
|
@@ -10,13 +10,11 @@ async function loadPageConfigsLazyClientSide(pageId, pageFilesAll, pageConfigs,
|
|
|
10
10
|
const pageFilesClientSide = getPageFilesClientSide(pageFilesAll, pageId);
|
|
11
11
|
const pageConfig = findPageConfig(pageConfigs, pageId);
|
|
12
12
|
let pageConfigLoaded;
|
|
13
|
-
// @ts-ignore Since dist/cjs/client/ is never used, we can ignore this error.
|
|
14
|
-
const isDev = import.meta.env.DEV;
|
|
15
13
|
try {
|
|
16
14
|
// prettier-ignore
|
|
17
15
|
// biome-ignore format:
|
|
18
16
|
const result = await Promise.all([
|
|
19
|
-
pageConfig && loadAndParseVirtualFilePageEntry(pageConfig,
|
|
17
|
+
pageConfig && loadAndParseVirtualFilePageEntry(pageConfig, import.meta.env.DEV),
|
|
20
18
|
...pageFilesClientSide.map((p) => p.loadFile?.()),
|
|
21
19
|
]);
|
|
22
20
|
pageConfigLoaded = result[0];
|
|
@@ -715,12 +715,14 @@ async function prerenderRedirects(globalContext, onComplete, showWarningUponDyna
|
|
|
715
715
|
}
|
|
716
716
|
function getRedirectHtml(urlTarget) {
|
|
717
717
|
const urlTargetSafe = escapeHtml(urlTarget);
|
|
718
|
-
//
|
|
718
|
+
// - Test: /test/playground => http://localhost:3000/download
|
|
719
|
+
// - Adding `<link rel="canonical">` for SEO, see https://github.com/vikejs/vike/pull/2711
|
|
719
720
|
const htmlString = `<!DOCTYPE html>
|
|
720
721
|
<html lang="en">
|
|
721
722
|
<head>
|
|
722
723
|
<meta charset="UTF-8">
|
|
723
724
|
<meta http-equiv="refresh" content="0;url=${urlTargetSafe}">
|
|
725
|
+
<link rel="canonical" href="${urlTargetSafe}" />
|
|
724
726
|
<title>Redirect ${urlTargetSafe}</title>
|
|
725
727
|
<style>body{opacity:0}</style>
|
|
726
728
|
<noscript>
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
export { pluginNonRunnableDev };
|
|
2
|
-
import { createViteRPC, assertIsNotProductionRuntime,
|
|
2
|
+
import { createViteRPC, assertIsNotProductionRuntime, isRunnableDevEnvironment, assert, isDevCheck } from '../utils.js';
|
|
3
3
|
import { retrievePageAssetsDev } from '../../runtime/renderPage/getPageAssets/retrievePageAssetsDev.js';
|
|
4
4
|
import { getViteConfigRuntime } from '../shared/getViteConfigRuntime.js';
|
|
5
5
|
import { getMagicString } from '../shared/getMagicString.js';
|
|
6
6
|
assertIsNotProductionRuntime();
|
|
7
|
-
|
|
8
|
-
const
|
|
7
|
+
/* We cannot use [`filter.id`](https://rolldown.rs/plugins/hook-filters) because Vite's optimizeDeps bundles the package `vike` into node_modules/.vite/deps_ssr/chunk-WBC5FHD7.js
|
|
8
|
+
const distFileIsNonRunnableDev = requireResolveDistFile('dist/esm/utils/isNonRunnableDev.js')
|
|
9
|
+
const distFileGlobalContext = requireResolveDistFile('dist/esm/node/runtime/globalContext.js')
|
|
9
10
|
const filterRolldown = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
id: {
|
|
12
|
+
include: [distFileIsNonRunnableDev, distFileGlobalContext].map(
|
|
13
|
+
(filePath) => new RegExp(`^${escapeRegex(filePath)}($|${escapeRegex('?')}.*)`),
|
|
14
|
+
),
|
|
15
|
+
},
|
|
16
|
+
}
|
|
17
|
+
*/
|
|
18
|
+
const __VIKE__DYNAMIC_IMPORT = '__VIKE__DYNAMIC_IMPORT';
|
|
19
|
+
const __VIKE__IS_NON_RUNNABLE_DEV = '__VIKE__IS_NON_RUNNABLE_DEV';
|
|
18
20
|
function getViteRpcFunctions(viteDevServer) {
|
|
19
21
|
return {
|
|
20
22
|
async transformIndexHtmlRPC(html) {
|
|
@@ -32,7 +34,7 @@ function pluginNonRunnableDev() {
|
|
|
32
34
|
let config;
|
|
33
35
|
return [
|
|
34
36
|
{
|
|
35
|
-
name: 'vike:pluginNonRunnableDev',
|
|
37
|
+
name: 'vike:pluginNonRunnableDev:1',
|
|
36
38
|
apply: (_, configEnv) => isDevCheck(configEnv),
|
|
37
39
|
configureServer: {
|
|
38
40
|
handler(viteDevServer) {
|
|
@@ -45,26 +47,39 @@ function pluginNonRunnableDev() {
|
|
|
45
47
|
},
|
|
46
48
|
},
|
|
47
49
|
transform: {
|
|
48
|
-
filter:
|
|
50
|
+
filter: {
|
|
51
|
+
code: {
|
|
52
|
+
include: __VIKE__IS_NON_RUNNABLE_DEV,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
handler(code, id) {
|
|
56
|
+
assert(config._isDev);
|
|
57
|
+
if (isRunnableDevEnvironment(this.environment))
|
|
58
|
+
return;
|
|
59
|
+
const { magicString, getMagicStringResult } = getMagicString(code, id);
|
|
60
|
+
magicString.replaceAll(__VIKE__IS_NON_RUNNABLE_DEV, JSON.stringify(true));
|
|
61
|
+
return getMagicStringResult();
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'vike:pluginNonRunnableDev:2',
|
|
67
|
+
apply: (_, configEnv) => isDevCheck(configEnv),
|
|
68
|
+
transform: {
|
|
69
|
+
filter: {
|
|
70
|
+
code: {
|
|
71
|
+
include: __VIKE__DYNAMIC_IMPORT,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
49
74
|
handler(code, id) {
|
|
50
75
|
assert(config._isDev);
|
|
51
|
-
assert(filterFunction(id));
|
|
52
|
-
const idWithoutQuery = getIdWithoutQuery(id);
|
|
53
76
|
if (isRunnableDevEnvironment(this.environment))
|
|
54
77
|
return;
|
|
55
78
|
const { magicString, getMagicStringResult } = getMagicString(code, id);
|
|
56
|
-
|
|
57
|
-
magicString.replaceAll('__VIKE__IS_NON_RUNNABLE_DEV', JSON.stringify(true));
|
|
58
|
-
}
|
|
59
|
-
if (idWithoutQuery === distFileGlobalContext) {
|
|
60
|
-
magicString.replaceAll('__VIKE__DYNAMIC_IMPORT', 'import');
|
|
61
|
-
}
|
|
79
|
+
magicString.replaceAll(__VIKE__DYNAMIC_IMPORT, 'import');
|
|
62
80
|
return getMagicStringResult();
|
|
63
81
|
},
|
|
64
82
|
},
|
|
65
83
|
},
|
|
66
84
|
];
|
|
67
85
|
}
|
|
68
|
-
function getIdWithoutQuery(id) {
|
|
69
|
-
return id.split('?')[0];
|
|
70
|
-
}
|
|
@@ -4,6 +4,9 @@ import MagicString from 'magic-string';
|
|
|
4
4
|
function getMagicString(code, id) {
|
|
5
5
|
const magicString = new MagicString(code);
|
|
6
6
|
const getMagicStringResult = () => {
|
|
7
|
+
/* TODO/now uncomment + dedupe
|
|
8
|
+
if (!magicString.hasChanged()) return undefined
|
|
9
|
+
*/
|
|
7
10
|
return {
|
|
8
11
|
code: magicString.toString(),
|
|
9
12
|
map: magicString.generateMap({ hires: true, source: id }),
|
|
@@ -6,7 +6,7 @@ export type GlobalContextInternal = GlobalContextServerInternal | GlobalContextC
|
|
|
6
6
|
import type { PageFile } from './getPageFiles.js';
|
|
7
7
|
import type { PageConfigRuntime } from '../types/PageConfig.js';
|
|
8
8
|
import type { GlobalContextServerInternal } from '../node/runtime/globalContext.js';
|
|
9
|
-
import type { GlobalContextClientInternal } from '../client/runtime-client-routing/
|
|
9
|
+
import type { GlobalContextClientInternal } from '../client/runtime-client-routing/getGlobalContextClientInternal.js';
|
|
10
10
|
import { type Hook } from './hooks/getHook.js';
|
|
11
11
|
declare const getGlobalContextSyncErrMsg = "The global context isn't set yet, call getGlobalContextSync() later or use getGlobalContext() instead.";
|
|
12
12
|
declare function createGlobalContextShared<GlobalContextAdded extends {}, GlobalContextAddedAsync extends {}>(virtualFileExportsGlobalEntry: unknown, globalObject: {
|
|
@@ -9,7 +9,6 @@ import { getHookFromPageConfigGlobalCumulative } from './hooks/getHook.js';
|
|
|
9
9
|
const getGlobalContextSyncErrMsg = "The global context isn't set yet, call getGlobalContextSync() later or use getGlobalContext() instead.";
|
|
10
10
|
// TO-DO/eventually use flat globalContext — like flat pageContext
|
|
11
11
|
async function createGlobalContextShared(virtualFileExportsGlobalEntry, globalObject, addGlobalContext,
|
|
12
|
-
// TODO/now can we remove it now?
|
|
13
12
|
// TO-DO/next-major-release: we'll be able to remove addGlobalContextTmp after loadPageRoutes() is sync (it will be sync after we remove the old design)
|
|
14
13
|
addGlobalContextTmp, addGlobalContextAsync) {
|
|
15
14
|
const { previousCreateGlobalContextPromise } = globalObject;
|
|
@@ -19,8 +19,8 @@ import type { From, PageContextConfig, Source, Sources } from '../shared/page-co
|
|
|
19
19
|
import type { Config } from './Config.js';
|
|
20
20
|
import type { AbortStatusCode } from '../shared/route/abort.js';
|
|
21
21
|
import type { GlobalContextServer } from '../node/runtime/globalContext.js';
|
|
22
|
-
import type { GlobalContextClient } from '../client/runtime-client-routing/
|
|
23
|
-
import type { GlobalContextClientWithServerRouting } from '../client/runtime-server-routing/
|
|
22
|
+
import type { GlobalContextClient } from '../client/runtime-client-routing/getGlobalContextClientInternal.js';
|
|
23
|
+
import type { GlobalContextClientWithServerRouting } from '../client/runtime-server-routing/getGlobalContextClientInternal.js';
|
|
24
24
|
type PageContextServer<Data = unknown> = PageContextBuiltInServer<Data> & Vike.PageContext & Vike.PageContextServer;
|
|
25
25
|
type PageContext<Data = unknown> = PageContextClient<Data> | PageContextServer<Data>;
|
|
26
26
|
type PageContextClient<Data = unknown> = PageContextBuiltInClientWithClientRouting<Data> & Vike.PageContext & Vike.PageContextClient;
|
|
@@ -137,9 +137,9 @@ type PageContextBuiltInCommon<Data> = PageContextConfig & {
|
|
|
137
137
|
};
|
|
138
138
|
type PageContextBuiltInServer<Data> = PageContextBuiltInCommon<Data> & PageContextUrlServer & {
|
|
139
139
|
/**
|
|
140
|
-
* Whether the
|
|
141
|
-
*
|
|
142
|
-
*
|
|
140
|
+
* Whether the environment is the client-side:
|
|
141
|
+
* - In the browser, the value is `true`.
|
|
142
|
+
* - Upon SSR and pre-rendering, the value is `false`.
|
|
143
143
|
*
|
|
144
144
|
* https://vike.dev/pageContext#isClientSide
|
|
145
145
|
*/
|
|
@@ -210,9 +210,9 @@ type PageContextBuiltInClientWithServerRouting<Data> = Partial<PageContextBuiltI
|
|
|
210
210
|
};
|
|
211
211
|
type PageContextClientCommon = {
|
|
212
212
|
/**
|
|
213
|
-
* Whether the
|
|
214
|
-
*
|
|
215
|
-
*
|
|
213
|
+
* Whether the environment is the client-side:
|
|
214
|
+
* - In the browser, the value is `true`.
|
|
215
|
+
* - Upon SSR and pre-rendering, the value is `false`.
|
|
216
216
|
*
|
|
217
217
|
* https://vike.dev/pageContext#isClientSide
|
|
218
218
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.239-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.239-commit-86a0513";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.239-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.239-commit-86a0513';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.239-commit-
|
|
3
|
+
"version": "0.4.239-commit-86a0513",
|
|
4
4
|
"repository": "https://github.com/vikejs/vike",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": {
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
"@brillout/json-serializer": "^0.5.20",
|
|
118
118
|
"@brillout/picocolors": "^1.0.26",
|
|
119
119
|
"@brillout/require-shim": "^0.1.2",
|
|
120
|
-
"@brillout/vite-plugin-server-entry": "
|
|
120
|
+
"@brillout/vite-plugin-server-entry": "0.7.14-commit-9aaa9d4",
|
|
121
121
|
"acorn": "^8.0.0",
|
|
122
122
|
"cac": "^6.0.0",
|
|
123
123
|
"es-module-lexer": "^1.0.0",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// TODO/now: rename file
|
|
2
|
-
// TODO/now: rename export
|
|
3
|
-
export { getGlobalContextClientInternal };
|
|
4
|
-
import { createGetGlobalContextClient } from '../shared/createGetGlobalContextClient.js';
|
|
5
|
-
// TODO/now: remove this useless function and re-export instead?
|
|
6
|
-
async function getGlobalContextClientInternal() {
|
|
7
|
-
const globalContext = await createGetGlobalContextClient();
|
|
8
|
-
return globalContext;
|
|
9
|
-
}
|
|
File without changes
|
|
File without changes
|