vike 0.4.240 → 0.4.241-commit-60b0676
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/runtime-client-routing/getPageContextFromHooks.d.ts +1 -1
- package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.js +1 -1
- package/dist/esm/client/runtime-client-routing/logErrorClient.d.ts +2 -0
- package/dist/esm/client/runtime-client-routing/logErrorClient.js +11 -0
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.js +95 -84
- package/dist/esm/client/runtime-client-routing/utils.d.ts +0 -1
- package/dist/esm/client/runtime-client-routing/utils.js +0 -1
- package/dist/esm/node/api/build.js +6 -6
- package/dist/esm/node/api/dev.js +2 -2
- package/dist/esm/node/api/prepareViteApiCall.d.ts +2 -9
- package/dist/esm/node/api/prepareViteApiCall.js +4 -156
- package/dist/esm/node/api/prerender.js +2 -2
- package/dist/esm/node/api/preview.js +2 -2
- package/dist/esm/node/api/resolveViteConfigFromUser.d.ts +20 -0
- package/dist/esm/node/api/resolveViteConfigFromUser.js +207 -0
- package/dist/esm/node/cli/parseCli.js +10 -6
- package/dist/esm/node/prerender/runPrerender.js +2 -1
- package/dist/esm/node/prerender/runPrerenderEntry.js +4 -4
- package/dist/esm/node/runtime/globalContext.d.ts +92 -0
- package/dist/esm/node/runtime/globalContext.js +12 -3
- package/dist/esm/node/runtime/logErrorServer.d.ts +2 -0
- package/dist/esm/node/runtime/logErrorServer.js +18 -0
- package/dist/esm/node/runtime/renderPage/execHookOnError.d.ts +2 -0
- package/dist/esm/node/runtime/renderPage/execHookOnError.js +26 -0
- package/dist/esm/node/runtime/renderPage/execHookServer.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/loggerProd.js +3 -5
- package/dist/esm/node/runtime/renderPage.js +8 -7
- package/dist/esm/node/runtime-dev/createDevMiddleware.js +2 -2
- package/dist/esm/node/vite/index.d.ts +1 -1
- package/dist/esm/node/vite/index.js +55 -24
- package/dist/esm/node/vite/onLoad.js +3 -8
- package/dist/esm/node/vite/plugins/build/handleAssetsManifest.js +0 -1
- package/dist/esm/node/vite/plugins/build/pluginBuildApp.js +6 -6
- package/dist/esm/node/vite/plugins/build/pluginDistFileNames.js +2 -2
- package/dist/esm/node/vite/plugins/pluginCommon.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginCommon.js +22 -9
- package/dist/esm/node/vite/plugins/pluginFileEnv.js +9 -6
- package/dist/esm/node/vite/plugins/pluginReplaceConstantsEnvVars.d.ts +3 -0
- package/dist/esm/node/vite/plugins/pluginReplaceConstantsEnvVars.js +129 -0
- package/dist/esm/node/vite/plugins/pluginReplaceConstantsGlobalThis.d.ts +10 -0
- package/dist/esm/node/vite/plugins/pluginReplaceConstantsGlobalThis.js +77 -0
- package/dist/esm/node/vite/plugins/pluginReplaceConstantsPageContext.d.ts +3 -0
- package/dist/esm/node/vite/plugins/{pluginReplaceIsClientSide.js → pluginReplaceConstantsPageContext.js} +5 -3
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntry.js +7 -1
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +3 -0
- package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +2 -2
- package/dist/esm/node/vite/plugins/pluginViteConfigVikeExtensions.d.ts +3 -0
- package/dist/esm/node/vite/plugins/pluginViteConfigVikeExtensions.js +32 -0
- package/dist/esm/node/vite/shared/getFilePath.d.ts +4 -6
- package/dist/esm/node/vite/shared/getFilePath.js +6 -11
- package/dist/esm/node/vite/shared/isViteCli.d.ts +13 -0
- package/dist/esm/node/vite/shared/isViteCli.js +143 -0
- package/dist/esm/node/vite/shared/isViteServerSide.d.ts +6 -3
- package/dist/esm/node/vite/shared/isViteServerSide.js +13 -4
- package/dist/esm/node/vite/shared/loggerNotProd/errorWithCodeSnippet.js +2 -2
- package/dist/esm/node/vite/shared/loggerNotProd/log.js +8 -2
- package/dist/esm/node/vite/shared/loggerNotProd.d.ts +1 -1
- package/dist/esm/node/vite/shared/loggerNotProd.js +11 -11
- package/dist/esm/node/vite/shared/loggerVite.js +4 -2
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +12 -2
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/transpileAndExecuteFile.js +12 -8
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal.d.ts +2 -0
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal.js +4 -0
- package/dist/esm/node/vite/utils.d.ts +1 -0
- package/dist/esm/node/vite/utils.js +1 -0
- package/dist/esm/shared/createGlobalContextShared.d.ts +2 -1
- package/dist/esm/shared/createGlobalContextShared.js +1 -1
- package/dist/esm/shared/hooks/execHook.d.ts +1 -1
- package/dist/esm/shared/hooks/getHook.d.ts +5 -4
- package/dist/esm/shared/route/abort.d.ts +1 -0
- package/dist/esm/shared/route/abort.js +12 -4
- package/dist/esm/shared/route/index.js +13 -4
- package/dist/esm/shared/route/utils.d.ts +1 -0
- package/dist/esm/shared/route/utils.js +1 -0
- package/dist/esm/types/Config.d.ts +14 -3
- 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 -0
- package/dist/esm/utils/assertNodeVersion.js +1 -1
- package/dist/esm/utils/assertViteVersion.d.ts +2 -0
- package/dist/esm/utils/assertViteVersion.js +11 -0
- package/dist/esm/utils/debug.d.ts +5 -3
- package/dist/esm/utils/debug.js +20 -16
- package/dist/esm/utils/getGlobalObject.d.ts +5 -1
- package/dist/esm/utils/getGlobalObject.js +5 -1
- package/dist/esm/utils/isExactlyOneTruthy.d.ts +1 -0
- package/dist/esm/utils/isExactlyOneTruthy.js +4 -0
- package/dist/esm/utils/isVikeReactApp.js +2 -1
- package/dist/esm/utils/requireResolve.js +1 -1
- package/package.json +3 -3
- package/dist/esm/node/vite/plugins/pluginEnvVars.d.ts +0 -3
- package/dist/esm/node/vite/plugins/pluginEnvVars.js +0 -110
- package/dist/esm/node/vite/plugins/pluginReplaceGlobalThisConstants.d.ts +0 -9
- package/dist/esm/node/vite/plugins/pluginReplaceGlobalThisConstants.js +0 -45
- package/dist/esm/node/vite/plugins/pluginReplaceIsClientSide.d.ts +0 -3
- package/dist/esm/node/vite/shared/isViteCliCall.d.ts +0 -10
- package/dist/esm/node/vite/shared/isViteCliCall.js +0 -81
- package/dist/esm/shared/route/debug.d.ts +0 -6
- package/dist/esm/shared/route/debug.js +0 -21
|
@@ -5,13 +5,14 @@ export type { GlobalContextBasePublic };
|
|
|
5
5
|
export type GlobalContextInternal = GlobalContextServerInternal | GlobalContextClientInternal;
|
|
6
6
|
import type { PageFile } from './getPageFiles.js';
|
|
7
7
|
import type { PageConfigRuntime } from '../types/PageConfig.js';
|
|
8
|
+
import { type GlobalContextPrepareMinimum } from './prepareGlobalContextForPublicUsage.js';
|
|
8
9
|
import type { GlobalContextServerInternal } from '../node/runtime/globalContext.js';
|
|
9
10
|
import type { GlobalContextClientInternal } from '../client/runtime-client-routing/getGlobalContextClientInternal.js';
|
|
10
11
|
import { type Hook } from './hooks/getHook.js';
|
|
11
12
|
declare const getGlobalContextSyncErrMsg = "The global context isn't set yet, call getGlobalContextSync() later or use getGlobalContext() instead.";
|
|
12
13
|
declare function createGlobalContextShared<GlobalContextAdded extends {}, GlobalContextAddedAsync extends {}>(virtualFileExportsGlobalEntry: unknown, globalObject: {
|
|
13
14
|
globalContext?: {};
|
|
14
|
-
onCreateGlobalContextHooks?: Hook[];
|
|
15
|
+
onCreateGlobalContextHooks?: Hook<GlobalContextPrepareMinimum>[];
|
|
15
16
|
previousCreateGlobalContextPromise?: Promise<void>;
|
|
16
17
|
}, addGlobalContext?: (globalContext: GlobalContextBase) => GlobalContextAdded, addGlobalContextTmp?: (globalContext: GlobalContextBase) => Promise<GlobalContextAdded>, addGlobalContextAsync?: (globalContext: GlobalContextBase) => Promise<GlobalContextAddedAsync>): Promise<{
|
|
17
18
|
_globalConfigPublic: {
|
|
@@ -4,7 +4,7 @@ import { assert, changeEnumerable, genPromise, objectAssign, objectReplace, uniq
|
|
|
4
4
|
import { parseVirtualFileExportsGlobalEntry } from './getPageFiles/parseVirtualFileExportsGlobalEntry.js';
|
|
5
5
|
import { resolveGlobalContextConfig } from './page-configs/resolveVikeConfigPublic.js';
|
|
6
6
|
import { execHookGlobal } from './hooks/execHook.js';
|
|
7
|
-
import { prepareGlobalContextForPublicUsage } from './prepareGlobalContextForPublicUsage.js';
|
|
7
|
+
import { prepareGlobalContextForPublicUsage, } from './prepareGlobalContextForPublicUsage.js';
|
|
8
8
|
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
|
|
@@ -24,7 +24,7 @@ type HookWithResult = Hook & {
|
|
|
24
24
|
hookReturn: unknown;
|
|
25
25
|
};
|
|
26
26
|
declare function execHook<PageContext extends PageContextExecHook>(hookName: HookName, pageContext: PageContext, preparePageContextForPublicUsage: (pageContext: PageContext) => PageContext): Promise<HookWithResult[]>;
|
|
27
|
-
declare function execHookGlobal<HookArg extends
|
|
27
|
+
declare function execHookGlobal<HookArg extends GlobalContextPrepareMinimum>(hookName: HookNameGlobal, pageConfigGlobal: PageConfigGlobalRuntime, pageContext: PageContextPrepareMinimum | null, hookArg: HookArg, prepareForPublicUsage: (hookArg: HookArg) => HookArg): Promise<void>;
|
|
28
28
|
declare function execHookDirect<PageContext extends PageContextPrepareMinimum>(hooks: Hook[], pageContext: PageContext, preparePageContextForPublicUsage: (pageContext: PageContext) => PageContext): Promise<HookWithResult[]>;
|
|
29
29
|
declare function execHookDirectSingle<PageContext extends PageContextExecHook>(hook: Hook, pageContext: PageContext, preparePageContextForPublicUsage: (pageContext: PageContext) => PageContext): Promise<void>;
|
|
30
30
|
declare function execHookDirectSingleWithReturn<PageContext extends PageContextExecHook>(hook: Hook, pageContext: PageContext, preparePageContextForPublicUsage: (pageContext: PageContext) => PageContext): Promise<{
|
|
@@ -14,15 +14,16 @@ import type { HookNameOld, HookNamePage, HookNameGlobal, HookName } from '../../
|
|
|
14
14
|
import type { PageConfigGlobalRuntime, PageConfigRuntime } from '../../types/PageConfig.js';
|
|
15
15
|
import type { GlobalContextPrepareMinimum } from '../prepareGlobalContextForPublicUsage.js';
|
|
16
16
|
import type { PageContextPrepareMinimum } from '../preparePageContextForPublicUsage.js';
|
|
17
|
-
type
|
|
18
|
-
|
|
17
|
+
type HookArgDefault = PageContextPrepareMinimum;
|
|
18
|
+
type Hook<HookArg = HookArgDefault> = HookLoc & {
|
|
19
|
+
hookFn: HookFn<HookArg>;
|
|
19
20
|
hookTimeout: HookTimeout;
|
|
20
21
|
};
|
|
21
22
|
type HookLoc = {
|
|
22
23
|
hookName: HookNameOld;
|
|
23
24
|
hookFilePath: string;
|
|
24
25
|
};
|
|
25
|
-
type HookFn = (arg:
|
|
26
|
+
type HookFn<HookArg = HookArgDefault> = (arg: HookArg) => unknown;
|
|
26
27
|
type HookTimeout = {
|
|
27
28
|
error: number | false;
|
|
28
29
|
warning: number | false;
|
|
@@ -32,6 +33,6 @@ declare function getHookFromPageContext(pageContext: PageContextConfig, hookName
|
|
|
32
33
|
declare function getHookFromPageContextNew(hookName: HookName, pageContext: PageContextConfig): Hook[];
|
|
33
34
|
declare function getHookFromPageConfig(pageConfig: PageConfigRuntime, hookName: HookNamePage): null | Hook;
|
|
34
35
|
declare function getHookFromPageConfigGlobal(pageConfigGlobal: PageConfigGlobalRuntime, hookName: HookNameGlobal): null | Hook;
|
|
35
|
-
declare function getHookFromPageConfigGlobalCumulative(pageConfigGlobal: PageConfigGlobalRuntime, hookName: HookNameGlobal): Hook[];
|
|
36
|
+
declare function getHookFromPageConfigGlobalCumulative<HookArg = GlobalContextPrepareMinimum>(pageConfigGlobal: PageConfigGlobalRuntime, hookName: HookNameGlobal): Hook<HookArg>[];
|
|
36
37
|
declare function getHookTimeoutDefault(hookName: HookNameOld): HookTimeout;
|
|
37
38
|
declare function getHook_setIsPrerenderering(): void;
|
|
@@ -12,6 +12,7 @@ export type { AbortStatusCode };
|
|
|
12
12
|
export type { ErrorAbort };
|
|
13
13
|
export type { PageContextFromRewrite };
|
|
14
14
|
export type { UrlRedirect };
|
|
15
|
+
export type { PageContextAbort };
|
|
15
16
|
type RedirectStatusCode = number & Parameters<typeof redirect>[1];
|
|
16
17
|
type AbortStatusCode = number & Parameters<InferTwoOverloads<typeof render>[0]>[0];
|
|
17
18
|
type UrlRedirect = {
|
|
@@ -26,7 +26,11 @@ function redirect(url, statusCode) {
|
|
|
26
26
|
statusCode = 302;
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
29
|
-
if (
|
|
29
|
+
if (
|
|
30
|
+
// Tree-shaking to save client-side KBs
|
|
31
|
+
!globalThis.__VIKE__IS_CLIENT ||
|
|
32
|
+
globalThis.__VIKE__IS_DEV ||
|
|
33
|
+
globalThis.__VIKE__IS_DEBUG) {
|
|
30
34
|
assertStatusCode(statusCode, [301, 302], 'redirect');
|
|
31
35
|
}
|
|
32
36
|
args.push(String(statusCode));
|
|
@@ -69,7 +73,11 @@ function render_(urlOrStatusCode, abortReason, abortCall, abortCaller, pageConte
|
|
|
69
73
|
return AbortRender(pageContextAbort);
|
|
70
74
|
}
|
|
71
75
|
else {
|
|
72
|
-
if (
|
|
76
|
+
if (
|
|
77
|
+
// Tree-shaking to save client-side KBs
|
|
78
|
+
!globalThis.__VIKE__IS_CLIENT ||
|
|
79
|
+
globalThis.__VIKE__IS_DEV ||
|
|
80
|
+
globalThis.__VIKE__IS_DEBUG) {
|
|
73
81
|
assertStatusCode(urlOrStatusCode, [401, 403, 404, 410, 429, 500, 503], 'render');
|
|
74
82
|
}
|
|
75
83
|
const abortStatusCode = urlOrStatusCode;
|
|
@@ -136,8 +144,8 @@ function logAbortErrorHandled(err, isProduction, pageContext) {
|
|
|
136
144
|
});
|
|
137
145
|
}
|
|
138
146
|
function assertStatusCode(statusCode, expected, caller) {
|
|
139
|
-
assert(!globalThis.__VIKE__IS_CLIENT || globalThis.__VIKE__IS_DEV); //
|
|
140
|
-
// double check vike:
|
|
147
|
+
assert(!globalThis.__VIKE__IS_CLIENT || globalThis.__VIKE__IS_DEV || globalThis.__VIKE__IS_DEBUG); // assert tree-shaking
|
|
148
|
+
// double check vike:pluginReplaceConstantsGlobalThis
|
|
141
149
|
if (globalThis.__VIKE__IS_CLIENT) {
|
|
142
150
|
assert(isBrowser());
|
|
143
151
|
assert(typeof globalThis.__VIKE__IS_DEV === 'boolean');
|
|
@@ -5,17 +5,21 @@ import { isBrowser } from '../../utils/isBrowser.js';
|
|
|
5
5
|
if (isBrowser()) {
|
|
6
6
|
assertClientRouting();
|
|
7
7
|
}
|
|
8
|
-
import { assert, assertUsage, isPlainObject, objectAssign } from './utils.js';
|
|
8
|
+
import { assert, assertUsage, isPlainObject, objectAssign, debug } from './utils.js';
|
|
9
9
|
import { resolvePrecedence } from './resolvePrecedence.js';
|
|
10
10
|
import { resolveRouteString } from './resolveRouteString.js';
|
|
11
11
|
import { resolveRouteFunction } from './resolveRouteFunction.js';
|
|
12
12
|
import { execHookOnBeforeRoute } from './execHookOnBeforeRoute.js';
|
|
13
|
-
import { debug } from './debug.js';
|
|
14
13
|
import pc from '@brillout/picocolors';
|
|
15
14
|
// TO-DO/next-major-release: make it sync
|
|
16
15
|
async function route(pageContext, skipOnBeforeRouteHook) {
|
|
17
|
-
debug('Pages routes:', pageContext._globalContext._pageRoutes);
|
|
18
16
|
const pageContextFromRoute = {};
|
|
17
|
+
if (
|
|
18
|
+
// Tree-shaking to save client-side KBs
|
|
19
|
+
!globalThis.__VIKE__IS_CLIENT ||
|
|
20
|
+
globalThis.__VIKE__IS_DEBUG) {
|
|
21
|
+
debug('vike:routing', 'Pages routes:', pageContext._globalContext._pageRoutes);
|
|
22
|
+
}
|
|
19
23
|
// onBeforeRoute()
|
|
20
24
|
if (!skipOnBeforeRouteHook) {
|
|
21
25
|
const pageContextFromOnBeforeRouteHook = await execHookOnBeforeRoute(pageContext);
|
|
@@ -80,7 +84,12 @@ async function route(pageContext, skipOnBeforeRouteHook) {
|
|
|
80
84
|
}));
|
|
81
85
|
resolvePrecedence(routeMatches);
|
|
82
86
|
const winner = routeMatches[0] ?? null;
|
|
83
|
-
|
|
87
|
+
if (
|
|
88
|
+
// Tree-shaking to save client-side KBs
|
|
89
|
+
!globalThis.__VIKE__IS_CLIENT ||
|
|
90
|
+
globalThis.__VIKE__IS_DEBUG) {
|
|
91
|
+
debug('vike:routing', `Route matches for URL ${pc.cyan(urlPathname)} (in precedence order):`, routeMatches);
|
|
92
|
+
}
|
|
84
93
|
// For vite-plugin-vercel https://github.com/magne4000/vite-plugin-vercel/blob/main/packages/vike-integration/vike.ts#L173
|
|
85
94
|
objectAssign(pageContextFromRoute, { _routeMatch: winner });
|
|
86
95
|
if (!winner) {
|
|
@@ -48,9 +48,9 @@ import type { PassToClientPublic } from '../node/runtime/renderPage/html/seriali
|
|
|
48
48
|
type HookNameOld = HookName | HookNameOldDesign;
|
|
49
49
|
type HookName = HookNamePage | HookNameGlobal;
|
|
50
50
|
type HookNamePage = 'onHydrationEnd' | 'onBeforePrerenderStart' | 'onBeforeRender' | 'onPageTransitionStart' | 'onPageTransitionEnd' | 'onRenderHtml' | 'onRenderClient' | 'guard' | 'data' | 'onData' | 'route';
|
|
51
|
-
type HookNameGlobal = 'onBeforeRoute' | 'onPrerenderStart' | 'onCreatePageContext' | 'onCreateGlobalContext';
|
|
51
|
+
type HookNameGlobal = 'onBeforeRoute' | 'onPrerenderStart' | 'onCreatePageContext' | 'onCreateGlobalContext' | 'onError';
|
|
52
52
|
type HookNameOldDesign = 'render' | 'prerender' | 'onBeforePrerender';
|
|
53
|
-
type ConfigNameBuiltIn = Exclude<keyof ConfigBuiltIn, keyof VikeVitePluginOptions | 'onBeforeRoute' | 'onPrerenderStart' | 'vite' | 'redirects'> | 'prerender' | '
|
|
53
|
+
type ConfigNameBuiltIn = Exclude<keyof ConfigBuiltIn, keyof VikeVitePluginOptions | 'onBeforeRoute' | 'onPrerenderStart' | 'vite' | 'redirects'> | 'prerender' | 'hasServerOnlyHook' | 'isClientRuntimeLoaded' | 'onBeforeRenderEnv' | 'dataEnv' | 'hooksTimeout' | 'clientHooks' | 'middleware';
|
|
54
54
|
type ConfigNameGlobal = 'onPrerenderStart' | 'onBeforeRoute' | 'prerender' | 'disableAutoFullBuild' | 'includeAssetsImportedByServer' | 'baseAssets' | 'baseServer' | 'redirects' | 'trailingSlash' | 'disableUrlNormalization' | 'vite';
|
|
55
55
|
type Config = ConfigBuiltIn & Vike.Config;
|
|
56
56
|
/** @deprecated This type is deprecated, see https://vike.dev/data */
|
|
@@ -268,7 +268,7 @@ type ConfigBuiltIn = {
|
|
|
268
268
|
*
|
|
269
269
|
* https://vike.dev/extends
|
|
270
270
|
*/
|
|
271
|
-
extends?: Config |
|
|
271
|
+
extends?: Config | ImportString | (Config | ImportString)[];
|
|
272
272
|
/** Hook called before the page is rendered.
|
|
273
273
|
*
|
|
274
274
|
* https://vike.dev/onBeforeRender
|
|
@@ -279,6 +279,11 @@ type ConfigBuiltIn = {
|
|
|
279
279
|
* https://vike.dev/onCreatePageContext
|
|
280
280
|
*/
|
|
281
281
|
onCreatePageContext?: ((pageContext: PageContextServer) => void) | ImportString | null;
|
|
282
|
+
/** Hook called when an error occurs during server-side rendering.
|
|
283
|
+
*
|
|
284
|
+
* https://vike.dev/onError
|
|
285
|
+
*/
|
|
286
|
+
onError?: ((error: unknown) => void) | ImportString | null;
|
|
282
287
|
/** Hook called when the `globalContext` object is created.
|
|
283
288
|
*
|
|
284
289
|
* https://vike.dev/onCreateGlobalContext
|
|
@@ -468,6 +473,12 @@ type ConfigBuiltIn = {
|
|
|
468
473
|
* https://vike.dev/mode
|
|
469
474
|
*/
|
|
470
475
|
mode?: string;
|
|
476
|
+
/**
|
|
477
|
+
* Disable Vite's cache.
|
|
478
|
+
*
|
|
479
|
+
* https://vike.dev/force
|
|
480
|
+
*/
|
|
481
|
+
force?: boolean;
|
|
471
482
|
/**
|
|
472
483
|
* Content Security Policy (CSP).
|
|
473
484
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.241-commit-60b0676";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.
|
|
2
|
+
export const PROJECT_VERSION = '0.4.241-commit-60b0676';
|
package/dist/esm/utils/assert.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { assertNodeVersion };
|
|
2
2
|
import { isNodeJS } from './isNodeJS.js';
|
|
3
3
|
import { assertVersion } from './assertVersion.js';
|
|
4
|
-
// node_modules/vike/package.json#engines.node isn't enough as users
|
|
4
|
+
// node_modules/vike/package.json#engines.node isn't enough, as users often ignore it
|
|
5
5
|
function assertNodeVersion() {
|
|
6
6
|
if (!isNodeJS())
|
|
7
7
|
return;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { assertViteVersion };
|
|
2
|
+
import { assertVersion } from './assertVersion.js';
|
|
3
|
+
// node_modules/vike/package.json#peerDependencies isn't enough, as users often ignore it
|
|
4
|
+
function assertViteVersion(viteVersion) {
|
|
5
|
+
// - This assertion isn't reliable: the user may still use a Vite version older than 6.0.0 — see https://github.com/vitejs/vite/pull/19355
|
|
6
|
+
// - TO-DO/eventually: let's also use this.meta.viteVersion
|
|
7
|
+
// - this.meta.viteVersion was released in vite@7.0.0 => let's use it only after Vike requires a Vite version above 7.0.0
|
|
8
|
+
// - https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md#700-2025-06-24
|
|
9
|
+
// - https://github.com/vitejs/vite/pull/20088
|
|
10
|
+
assertVersion('Vite', viteVersion, ['6.3.0']);
|
|
11
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
export { debug };
|
|
1
2
|
export { createDebugger };
|
|
3
|
+
export { isDebug };
|
|
2
4
|
export { isDebugActivated };
|
|
3
|
-
|
|
4
|
-
declare const flags: readonly ["vike:crawl", "vike:error", "vike:esbuild-resolve", "vike:pluginExtractAssets", "vike:pluginExtractExportNames", "vike:glob", "vike:globalContext", "vike:log", "vike:optimizeDeps", "vike:outDir", "vike:pageFiles", "vike:pointer-imports", "vike:resolve", "vike:routing", "vike:setup", "vike:stream", "vike:virtualFiles", "vike:vite-rpc"];
|
|
5
|
+
declare const flags: ["vike", "vike:crawl", "vike:error", "vike:esbuild-resolve", "vike:pluginExtractAssets", "vike:pluginExtractExportNames", "vike:glob", "vike:globalContext", "vike:log", "vike:optimizeDeps", "vike:outDir", "vike:pageFiles", "vike:pointer-imports", "vike:requireResolve", "vike:routing", "vike:setup", "vike:stream", "vike:virtualFiles", "vike:vite-rpc"];
|
|
5
6
|
type Flag = (typeof flags)[number];
|
|
6
|
-
type Debug = ReturnType<typeof createDebugger>;
|
|
7
7
|
type Options = {
|
|
8
8
|
serialization?: {
|
|
9
9
|
emptyArray?: string;
|
|
@@ -13,4 +13,6 @@ declare function createDebugger(flag: Flag, optionsGlobal?: Options): ((...msgs:
|
|
|
13
13
|
options: (optionsLocal: Options) => (...msgs: unknown[]) => void;
|
|
14
14
|
isActivated: boolean;
|
|
15
15
|
};
|
|
16
|
+
declare function debug(flag: Flag, ...msgs: unknown[]): void;
|
|
16
17
|
declare function isDebugActivated(flag: Flag): boolean;
|
|
18
|
+
declare function isDebug(): boolean;
|
package/dist/esm/utils/debug.js
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
+
export { debug };
|
|
1
2
|
export { createDebugger };
|
|
3
|
+
export { isDebug };
|
|
2
4
|
export { isDebugActivated };
|
|
3
5
|
import { isCallable } from './isCallable.js';
|
|
4
6
|
import { objectAssign } from './objectAssign.js';
|
|
5
7
|
import { assert, assertUsage } from './assert.js';
|
|
6
|
-
import { checkType } from './checkType.js';
|
|
7
8
|
import { getTerminalWidth } from './getTerminalWidth.js';
|
|
8
9
|
import pc from '@brillout/picocolors';
|
|
9
10
|
import { isArray } from './isArray.js';
|
|
10
11
|
import { isObject } from './isObject.js';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
// Assert tree-shaking (ensure this module is loaded on the client-side only if debug is enabled).
|
|
13
|
+
assert(!globalThis.__VIKE__IS_CLIENT ||
|
|
14
|
+
globalThis.__VIKE__IS_DEBUG ||
|
|
15
|
+
// Vite doesn't do tree-shaking in dev (maybe it will with Rolldown?)
|
|
16
|
+
import.meta.env.DEV);
|
|
15
17
|
const flags = [
|
|
18
|
+
'vike',
|
|
16
19
|
'vike:crawl',
|
|
17
20
|
'vike:error',
|
|
18
21
|
'vike:esbuild-resolve',
|
|
@@ -25,7 +28,7 @@ const flags = [
|
|
|
25
28
|
'vike:outDir',
|
|
26
29
|
'vike:pageFiles',
|
|
27
30
|
'vike:pointer-imports',
|
|
28
|
-
'vike:
|
|
31
|
+
'vike:requireResolve',
|
|
29
32
|
'vike:routing',
|
|
30
33
|
'vike:setup',
|
|
31
34
|
'vike:stream',
|
|
@@ -33,14 +36,12 @@ const flags = [
|
|
|
33
36
|
'vike:vite-rpc',
|
|
34
37
|
];
|
|
35
38
|
const flagsSkipWildcard = ['vike:log'];
|
|
36
|
-
const flagRegex = /\bvike:[a-zA-Z-]+/g;
|
|
37
39
|
// We purposely read process.env.DEBUG early, in order to avoid users from the temptation to set process.env.DEBUG with JavaScript, since reading & writing process.env.DEBUG dynamically leads to inconsistencies such as https://github.com/vikejs/vike/issues/2239
|
|
38
40
|
const DEBUG = getDEBUG() ?? '';
|
|
39
41
|
if (isDebug())
|
|
40
42
|
Error.stackTraceLimit = Infinity;
|
|
41
43
|
assertFlagsActivated();
|
|
42
44
|
function createDebugger(flag, optionsGlobal) {
|
|
43
|
-
checkType(flag);
|
|
44
45
|
assert(flags.includes(flag));
|
|
45
46
|
const debugWithOptions = (optionsLocal) => {
|
|
46
47
|
return (...msgs) => {
|
|
@@ -52,6 +53,9 @@ function createDebugger(flag, optionsGlobal) {
|
|
|
52
53
|
objectAssign(debug, { options: debugWithOptions, isActivated: isDebugActivated(flag) });
|
|
53
54
|
return debug;
|
|
54
55
|
}
|
|
56
|
+
function debug(flag, ...msgs) {
|
|
57
|
+
return debug_(flag, {}, ...msgs);
|
|
58
|
+
}
|
|
55
59
|
function debug_(flag, options, ...msgs) {
|
|
56
60
|
if (!isDebugActivated(flag))
|
|
57
61
|
return;
|
|
@@ -80,10 +84,9 @@ function debug_(flag, options, ...msgs) {
|
|
|
80
84
|
});
|
|
81
85
|
}
|
|
82
86
|
function isDebugActivated(flag) {
|
|
83
|
-
checkType(flag);
|
|
84
87
|
assert(flags.includes(flag));
|
|
85
|
-
const { flagsActivated,
|
|
86
|
-
const isActivated = flagsActivated.includes(flag) || (
|
|
88
|
+
const { flagsActivated, isAll } = getFlagsActivated();
|
|
89
|
+
const isActivated = flagsActivated.includes(flag) || (isAll && !flagsSkipWildcard.includes(flag));
|
|
87
90
|
return isActivated;
|
|
88
91
|
}
|
|
89
92
|
function formatMsg(info, options, padding, position) {
|
|
@@ -153,13 +156,14 @@ function assertFlagsActivated() {
|
|
|
153
156
|
});
|
|
154
157
|
}
|
|
155
158
|
function getFlagsActivated() {
|
|
156
|
-
const flagsActivated = DEBUG.match(
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
+
const flagsActivated = DEBUG.match(/\bvike:[a-zA-Z-]+/g) ?? [];
|
|
160
|
+
const isAll = DEBUG.includes('vike:*');
|
|
161
|
+
const isGlobal = /\bvike\b([^:]|$)/.test(DEBUG);
|
|
162
|
+
return { flagsActivated, isAll, isGlobal };
|
|
159
163
|
}
|
|
160
164
|
function isDebug() {
|
|
161
|
-
const { flagsActivated,
|
|
162
|
-
return
|
|
165
|
+
const { flagsActivated, isAll, isGlobal } = getFlagsActivated();
|
|
166
|
+
return isAll || flagsActivated.length > 0 || isGlobal;
|
|
163
167
|
}
|
|
164
168
|
function getDEBUG() {
|
|
165
169
|
let DEBUG;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export { getGlobalObject };
|
|
2
2
|
import type { VikeGlobalInternal } from '../types/VikeGlobalInternal.js';
|
|
3
3
|
type ModuleId = `${string}.ts`;
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Share information across module instances.
|
|
6
|
+
*
|
|
7
|
+
* @__NO_SIDE_EFFECTS__
|
|
8
|
+
*/
|
|
5
9
|
declare function getGlobalObject<T extends Record<string, unknown> = never>(moduleId: ModuleId, defaultValue: T): T;
|
|
6
10
|
declare global {
|
|
7
11
|
var _vike: VikeGlobalInternal;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export { getGlobalObject };
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Share information across module instances.
|
|
4
|
+
*
|
|
5
|
+
* @__NO_SIDE_EFFECTS__
|
|
6
|
+
*/
|
|
3
7
|
function getGlobalObject(moduleId, defaultValue) {
|
|
4
8
|
const globals = getGlobals();
|
|
5
9
|
const globalObject = (globals[moduleId] ?? (globals[moduleId] = defaultValue));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isExactlyOneTruthy(...values: unknown[]): boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export function isVikeReactApp() {
|
|
2
2
|
const g = globalThis;
|
|
3
|
-
// Set by vike-react
|
|
3
|
+
// Set by vike-react
|
|
4
|
+
// https://github.com/vikejs/vike-react/blob/23e92434424f10e7e742b6bf587edee5aa8832df/packages/vike-react/src/renderer/onRenderHtml.tsx#L75
|
|
4
5
|
return !!g._isVikeReactApp;
|
|
5
6
|
}
|
|
@@ -17,7 +17,7 @@ const importMetaUrl = import.meta.url;
|
|
|
17
17
|
assertPosixPath(importMetaUrl);
|
|
18
18
|
assertIsNotBrowser();
|
|
19
19
|
assertIsNotProductionRuntime();
|
|
20
|
-
const debug = createDebugger('vike:
|
|
20
|
+
const debug = createDebugger('vike:requireResolve');
|
|
21
21
|
// - We still can't use import.meta.resolve() as of 23.1.0 (November 2024) because `parent` argument requires an experimental flag.
|
|
22
22
|
// - https://stackoverflow.com/questions/54977743/do-require-resolve-for-es-modules#comment139581675_62272600
|
|
23
23
|
// - Passing context to createRequire(context) isn't equivalent to passing it to the `paths` argument of require.resolve()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.241-commit-60b0676",
|
|
4
4
|
"repository": "https://github.com/vikejs/vike",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": {
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
},
|
|
115
115
|
"dependencies": {
|
|
116
116
|
"@brillout/import": "^0.2.6",
|
|
117
|
-
"@brillout/json-serializer": "^0.5.
|
|
117
|
+
"@brillout/json-serializer": "^0.5.21",
|
|
118
118
|
"@brillout/picocolors": "^1.0.26",
|
|
119
119
|
"@brillout/require-shim": "^0.1.2",
|
|
120
120
|
"@brillout/vite-plugin-server-entry": "^0.7.15",
|
|
@@ -247,7 +247,7 @@
|
|
|
247
247
|
"@types/source-map-support": "^0.5.10",
|
|
248
248
|
"react-streaming": "^0.4.3",
|
|
249
249
|
"rimraf": "^5.0.5",
|
|
250
|
-
"typescript": "^5.
|
|
250
|
+
"typescript": "^5.9.2",
|
|
251
251
|
"vite": "^7.1.5"
|
|
252
252
|
},
|
|
253
253
|
"scripts": {
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
export { pluginEnvVars };
|
|
2
|
-
import { loadEnv } from 'vite';
|
|
3
|
-
import { assert, assertPosixPath, assertUsage, assertWarning, escapeRegex, isArray, isNotNullish, lowerFirst, } from '../utils.js';
|
|
4
|
-
import { getModuleFilePathAbsolute } from '../shared/getFilePath.js';
|
|
5
|
-
import { normalizeId } from '../shared/normalizeId.js';
|
|
6
|
-
import { isViteServerSide_extraSafe } from '../shared/isViteServerSide.js';
|
|
7
|
-
import { getMagicString } from '../shared/getMagicString.js';
|
|
8
|
-
// TO-DO/eventually:
|
|
9
|
-
// - Make import.meta.env work inside +config.js
|
|
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
|
|
11
|
-
// - 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`.)
|
|
12
|
-
const PUBLIC_ENV_PREFIX = 'PUBLIC_ENV__';
|
|
13
|
-
const PUBLIC_ENV_ALLOWLIST = [
|
|
14
|
-
// https://github.com/vikejs/vike/issues/1724
|
|
15
|
-
'STORYBOOK',
|
|
16
|
-
];
|
|
17
|
-
const skipNodeModules = '/node_modules/';
|
|
18
|
-
const skipIrrelevant = 'import.meta.env.';
|
|
19
|
-
const filterRolldown = {
|
|
20
|
-
id: {
|
|
21
|
-
exclude: `**${skipNodeModules}**`,
|
|
22
|
-
},
|
|
23
|
-
code: {
|
|
24
|
-
include: skipIrrelevant,
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
const filterFunction = (id, code) => {
|
|
28
|
-
if (id.includes(skipNodeModules))
|
|
29
|
-
return false;
|
|
30
|
-
if (!code.includes(skipIrrelevant))
|
|
31
|
-
return false;
|
|
32
|
-
return true;
|
|
33
|
-
};
|
|
34
|
-
function pluginEnvVars() {
|
|
35
|
-
let envsAll;
|
|
36
|
-
let config;
|
|
37
|
-
return [
|
|
38
|
-
{
|
|
39
|
-
name: 'vike:pluginEnvVars',
|
|
40
|
-
enforce: 'post',
|
|
41
|
-
configResolved: {
|
|
42
|
-
handler(config_) {
|
|
43
|
-
config = config_;
|
|
44
|
-
envsAll = loadEnv(config.mode, config.envDir || config.root, '');
|
|
45
|
-
config.plugins.sort(lowerFirst((plugin) => (plugin.name === 'vite:define' ? 1 : 0)));
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
transform: {
|
|
49
|
-
filter: filterRolldown,
|
|
50
|
-
handler(code, id, options) {
|
|
51
|
-
id = normalizeId(id);
|
|
52
|
-
assertPosixPath(id);
|
|
53
|
-
assertPosixPath(config.root);
|
|
54
|
-
if (!id.startsWith(config.root))
|
|
55
|
-
return; // skip linked dependencies
|
|
56
|
-
assert(filterFunction(id, code));
|
|
57
|
-
const isBuild = config.command === 'build';
|
|
58
|
-
const isClientSide = !isViteServerSide_extraSafe(config, this.environment, options);
|
|
59
|
-
const { magicString, getMagicStringResult } = getMagicString(code, id);
|
|
60
|
-
// Find & check
|
|
61
|
-
const replacements = Object.entries(envsAll)
|
|
62
|
-
.filter(([key]) => {
|
|
63
|
-
// Already handled by Vite
|
|
64
|
-
const envPrefix = !config.envPrefix
|
|
65
|
-
? []
|
|
66
|
-
: isArray(config.envPrefix)
|
|
67
|
-
? config.envPrefix
|
|
68
|
-
: [config.envPrefix];
|
|
69
|
-
return !envPrefix.some((prefix) => key.startsWith(prefix));
|
|
70
|
-
})
|
|
71
|
-
.map(([envName, envVal]) => {
|
|
72
|
-
const envStatement = `import.meta.env.${envName}`;
|
|
73
|
-
const envStatementRegExpStr = escapeRegex(envStatement) + '\\b';
|
|
74
|
-
// Security check
|
|
75
|
-
{
|
|
76
|
-
const isPrivate = !envName.startsWith(PUBLIC_ENV_PREFIX) && !PUBLIC_ENV_ALLOWLIST.includes(envName);
|
|
77
|
-
if (isPrivate && isClientSide) {
|
|
78
|
-
if (!new RegExp(envStatementRegExpStr).test(code))
|
|
79
|
-
return;
|
|
80
|
-
const modulePath = getModuleFilePathAbsolute(id, config);
|
|
81
|
-
const errMsgAddendum = isBuild
|
|
82
|
-
? ''
|
|
83
|
-
: ' (Vike will prevent your app from building for production)';
|
|
84
|
-
const keyPublic = `${PUBLIC_ENV_PREFIX}${envName}`;
|
|
85
|
-
const errMsg = `${envStatement} is used in client-side file ${modulePath} which means that the environment variable ${envName} will be included in client-side bundles and, therefore, ${envName} will be publicly exposed which can be a security leak${errMsgAddendum}. Use ${envStatement} only in server-side files, or rename ${envName} to ${keyPublic}, see https://vike.dev/env`;
|
|
86
|
-
if (isBuild) {
|
|
87
|
-
assertUsage(false, errMsg);
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
// - Only a warning for faster development DX (e.g. when user toggles `ssr: boolean` or `onBeforeRenderIsomorph: boolean`).
|
|
91
|
-
// - But only showing a warning can be confusing: https://github.com/vikejs/vike/issues/1641
|
|
92
|
-
assertWarning(false, errMsg, { onlyOnce: true });
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
// Double check
|
|
96
|
-
assert(!(isPrivate && isClientSide) || !isBuild);
|
|
97
|
-
}
|
|
98
|
-
return { regExpStr: envStatementRegExpStr, replacement: envVal };
|
|
99
|
-
})
|
|
100
|
-
.filter(isNotNullish);
|
|
101
|
-
// Apply
|
|
102
|
-
replacements.forEach(({ regExpStr, replacement }) => {
|
|
103
|
-
magicString.replaceAll(new RegExp(regExpStr, 'g'), JSON.stringify(replacement));
|
|
104
|
-
});
|
|
105
|
-
return getMagicStringResult();
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
];
|
|
110
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export { pluginReplaceGlobalThisConstants };
|
|
2
|
-
import type { Plugin } from 'vite';
|
|
3
|
-
declare global {
|
|
4
|
-
/** Like `import.meta.env.DEV` but works inside `node_modules/` (even if package is `ssr.external`). The value `undefined` is to be interpreted as `false`. */
|
|
5
|
-
var __VIKE__IS_DEV: boolean | undefined;
|
|
6
|
-
/** Like `import.meta.env.SSR` but works inside `node_modules/` (even if package is `ssr.external`). The value `undefined` is to be interpreted as `false`. */
|
|
7
|
-
var __VIKE__IS_CLIENT: boolean | undefined;
|
|
8
|
-
}
|
|
9
|
-
declare function pluginReplaceGlobalThisConstants(): Plugin[];
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
export { pluginReplaceGlobalThisConstants };
|
|
2
|
-
import { assert } from '../utils.js';
|
|
3
|
-
// === Explanation: globalThis.__VIKE__IS_DEV
|
|
4
|
-
// If client-side => always noExternal => globalThis.__VIKE__IS_DEV is set by the `define` config below.
|
|
5
|
-
// If server-side:
|
|
6
|
-
// If ssr.noExternal => globalThis.__VIKE__IS_DEV is set by the `define` config below.
|
|
7
|
-
// If `ssr.external`:
|
|
8
|
-
// If not RunnableDevEnvironment (e.g. `@cloudflare/vite-plugin`) => always ssr.noExternal => globalThis.__VIKE__IS_DEV is set by the `define` config below.
|
|
9
|
-
// If RunnableDevEnvironment (the default setup):
|
|
10
|
-
// If dev/preview/pre-rendering => Vite is loaded, and server and Vite run inside the same process (because RunnableDevEnvironment) => globalThis.__VIKE__IS_DEV is set by the assignment below.
|
|
11
|
-
// If production => Vite isn't loaded => globalThis.__VIKE__IS_DEV is `undefined` (it's never set) => value `undefined` is to be interpreted as `false`.
|
|
12
|
-
// === Explanation: globalThis.__VIKE__IS_CLIENT
|
|
13
|
-
// If client-side => always noExternal => globalThis.__VIKE__IS_CLIENT is set to `true` by the `define` config below.
|
|
14
|
-
// If server-side => globalThis.__VIKE__IS_CLIENT is either `false` or `undefined` (the value `undefined` is to be interpreted as `false`).
|
|
15
|
-
globalThis.__VIKE__IS_CLIENT = false;
|
|
16
|
-
function pluginReplaceGlobalThisConstants() {
|
|
17
|
-
return [
|
|
18
|
-
{
|
|
19
|
-
name: 'vike:pluginReplaceGlobalThisConstants',
|
|
20
|
-
config: {
|
|
21
|
-
handler(config) {
|
|
22
|
-
const isDev = config._isDev;
|
|
23
|
-
assert(typeof isDev === 'boolean');
|
|
24
|
-
globalThis.__VIKE__IS_DEV = isDev;
|
|
25
|
-
return {
|
|
26
|
-
define: {
|
|
27
|
-
'globalThis.__VIKE__IS_DEV': JSON.stringify(isDev),
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
configEnvironment: {
|
|
33
|
-
handler(name, config) {
|
|
34
|
-
const consumer = config.consumer ?? (name === 'client' ? 'client' : 'server');
|
|
35
|
-
const isClientSide = consumer === 'client';
|
|
36
|
-
return {
|
|
37
|
-
define: {
|
|
38
|
-
'globalThis.__VIKE__IS_CLIENT': JSON.stringify(isClientSide),
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
];
|
|
45
|
-
}
|