vike 0.4.240-commit-8ce2cbd → 0.4.240-commit-95fc969
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/renderPageClientSide.js +5 -4
- package/dist/esm/node/cli/parseCli.js +1 -1
- package/dist/esm/node/prerender/runPrerender.js +1 -0
- package/dist/esm/node/runtime/globalContext.js +5 -3
- package/dist/esm/node/runtime/renderPage.js +6 -5
- package/dist/esm/node/vite/plugins/build/handleAssetsManifest.js +0 -1
- package/dist/esm/node/vite/plugins/pluginCommon.js +8 -2
- package/dist/esm/node/vite/plugins/pluginFileEnv.js +4 -2
- package/dist/esm/node/vite/plugins/pluginReplaceConstantsEnvVars.js +3 -1
- package/dist/esm/node/vite/plugins/pluginReplaceConstantsGlobalThis.d.ts +5 -12
- package/dist/esm/node/vite/plugins/pluginReplaceConstantsGlobalThis.js +50 -25
- 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/shared/isViteServerSide.d.ts +6 -3
- package/dist/esm/node/vite/shared/isViteServerSide.js +13 -4
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/isVikeReactApp.js +2 -1
- package/package.json +1 -1
|
@@ -241,7 +241,7 @@ async function renderPageClientSide(renderArgs) {
|
|
|
241
241
|
// We don't swallow 404 errors:
|
|
242
242
|
// - On the server-side, Vike swallows / doesn't show any 404 error log because it's expected that a user may go to some random non-existent URL. (We don't want to flood the app's error tracking with 404 logs.)
|
|
243
243
|
// - On the client-side, if the user navigates to a 404 then it means that the UI has a broken link. (It isn't expected that users can go to some random URL using the client-side router, as it would require, for example, the user to manually change the URL of a link by manually manipulating the DOM which highly unlikely.)
|
|
244
|
-
|
|
244
|
+
logErrorClient(err);
|
|
245
245
|
}
|
|
246
246
|
else {
|
|
247
247
|
// We swallow throw redirect()/render() called by client-side hooks onBeforeRender()/data()/guard()
|
|
@@ -272,7 +272,7 @@ async function renderPageClientSide(renderArgs) {
|
|
|
272
272
|
- An infinite reloading page is a even worse UX than a blank page.
|
|
273
273
|
redirectHard(urlOriginal)
|
|
274
274
|
*/
|
|
275
|
-
|
|
275
|
+
logErrorClient(err);
|
|
276
276
|
};
|
|
277
277
|
const errorPageId = getErrorPageId(pageContext._pageFilesAll, pageContext._globalContext._pageConfigs);
|
|
278
278
|
if (!errorPageId)
|
|
@@ -384,7 +384,7 @@ async function renderPageClientSide(renderArgs) {
|
|
|
384
384
|
await handleError({ err });
|
|
385
385
|
}
|
|
386
386
|
else {
|
|
387
|
-
|
|
387
|
+
logErrorClient(err);
|
|
388
388
|
}
|
|
389
389
|
};
|
|
390
390
|
// We use globalObject.onRenderClientPreviousPromise in order to ensure that there is never two concurrent onRenderClient() calls
|
|
@@ -665,9 +665,10 @@ if (import.meta.env.DEV && import.meta.hot)
|
|
|
665
665
|
});
|
|
666
666
|
}
|
|
667
667
|
});
|
|
668
|
-
function
|
|
668
|
+
function logErrorClient(err) {
|
|
669
669
|
if (isObject(err) &&
|
|
670
670
|
// Set by vike-react
|
|
671
|
+
// https://github.com/vikejs/vike-react/blob/195a208c6b77e7f34496e1f637278a36c60fbe07/packages/vike-react/src/integration/onRenderClient.tsx#L109
|
|
671
672
|
err.isAlreadyLogged) {
|
|
672
673
|
return;
|
|
673
674
|
}
|
|
@@ -5,7 +5,7 @@ import { parseJson5 } from '../vite/shared/getEnvVarObject.js';
|
|
|
5
5
|
const commands = [
|
|
6
6
|
{ name: 'dev', desc: 'Start development server' },
|
|
7
7
|
{ name: 'build', desc: 'Build for production' },
|
|
8
|
-
{ name: 'preview', desc: 'Start preview server using production build
|
|
8
|
+
{ name: 'preview', desc: 'Start preview server using production build' },
|
|
9
9
|
{ name: 'prerender', desc: 'Pre-render pages (only needed when prerender.disableAutoRun is true)' },
|
|
10
10
|
];
|
|
11
11
|
function parseCli() {
|
|
@@ -556,7 +556,8 @@ function isProdOptional() {
|
|
|
556
556
|
const yes5 = globalObject.isProductionAccordingToUser === true;
|
|
557
557
|
// vite-plugin-vercel
|
|
558
558
|
const yes6 = globalObject.isProductionAccordingToPhotonVercel === true;
|
|
559
|
-
const
|
|
559
|
+
const yes7 = globalThis.__VIKE__IS_DEV === false;
|
|
560
|
+
const yes = yes1 || yes2 || yes3 || yes4 || yes5 || yes6 || yes7;
|
|
560
561
|
const no1 = !!globalObject.viteDevServer;
|
|
561
562
|
// Vike CLI & Vike API
|
|
562
563
|
const no2 = vikeApiOperation === 'dev';
|
|
@@ -566,8 +567,9 @@ function isProdOptional() {
|
|
|
566
567
|
const no4 = globalObject.isProductionAccordingToUser === false;
|
|
567
568
|
// @cloudflare/vite-plugin
|
|
568
569
|
const no5 = isNonRunnableDev();
|
|
569
|
-
const
|
|
570
|
-
const
|
|
570
|
+
const no6 = globalThis.__VIKE__IS_DEV === true;
|
|
571
|
+
const no = no1 || no2 || no3 || no4 || no5 || no6;
|
|
572
|
+
const debug = { yes1, yes2, yes3, yes4, yes5, yes6, yes7, no1, no2, no3, no4, no5, no6 };
|
|
571
573
|
assert(typeof yes === 'boolean', debug);
|
|
572
574
|
assert(typeof no === 'boolean', debug);
|
|
573
575
|
if (yes) {
|
|
@@ -64,11 +64,12 @@ async function renderPagePrepare(pageContextInit, httpRequestId) {
|
|
|
64
64
|
await initGlobalContext_renderPage();
|
|
65
65
|
}
|
|
66
66
|
catch (err) {
|
|
67
|
-
// Errors are expected
|
|
68
|
-
//
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
//
|
|
67
|
+
// Errors are expected:
|
|
68
|
+
// - assertUsage() such as:
|
|
69
|
+
// ```bash
|
|
70
|
+
// Re-build your app (you're using 1.2.3 but your app was built with 1.2.2)
|
|
71
|
+
// ```
|
|
72
|
+
// - initGlobalContext_renderPage() depends on +onCreateGlobalContext hooks
|
|
72
73
|
assert(!isAbortError(err));
|
|
73
74
|
logRuntimeError(err, httpRequestId);
|
|
74
75
|
const pageContextWithError = getPageContextHttpResponseErrorWithoutGlobalContext(err, pageContextInit);
|
|
@@ -310,7 +310,6 @@ async function handleAssetsManifest_getBuildConfig() {
|
|
|
310
310
|
async function handleAssetsManifest(config, viteEnv, options, bundle) {
|
|
311
311
|
const isSsrEnv = isViteServerSide_onlySsrEnv(config, viteEnv);
|
|
312
312
|
if (isSsrEnv) {
|
|
313
|
-
assert(!globalObject.assetsJsonFilePath);
|
|
314
313
|
const outDirs = getOutDirs(config, viteEnv);
|
|
315
314
|
globalObject.assetsJsonFilePath = path.posix.join(outDirs.outDirRoot, 'assets.json');
|
|
316
315
|
await writeAssetsManifestFile(globalObject.assetsJsonFilePath, config);
|
|
@@ -131,10 +131,16 @@ function assertVikeCliOrApi(config) {
|
|
|
131
131
|
assert(!isVitest());
|
|
132
132
|
return;
|
|
133
133
|
}
|
|
134
|
+
/* This warning is always shown: Vitest loads Vite *before* any Vike JavaScript API can be invoked.
|
|
134
135
|
if (isVitest()) {
|
|
135
|
-
|
|
136
|
-
|
|
136
|
+
assertWarning(
|
|
137
|
+
false,
|
|
138
|
+
`Unexpected Vitest setup: you seem to be using Vitest together with Vike's Vite plugin but without using Vike's JavaScript API which is unexpected, see ${pc.underline('https://vike.dev/vitest')}`,
|
|
139
|
+
{ onlyOnce: true },
|
|
140
|
+
)
|
|
141
|
+
return
|
|
137
142
|
}
|
|
143
|
+
*/
|
|
138
144
|
if (config.server.middlewareMode) {
|
|
139
145
|
assertWarning(false, `${pc.cyan('vite.createServer()')} is deprecated ${pc.underline('https://vike.dev/migration/cli#api')}`, {
|
|
140
146
|
onlyOnce: true,
|
|
@@ -42,8 +42,10 @@ function pluginFileEnv() {
|
|
|
42
42
|
if (id.endsWith('?direct'))
|
|
43
43
|
id = id.slice(0, -1 * '?direct'.length);
|
|
44
44
|
const moduleInfo = viteDevServer.moduleGraph.getModuleById(id);
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
/* It can fail, no clue why — https://github.com/vikejs/vike/issues/2740
|
|
46
|
+
assert(moduleInfo, { moduleId })
|
|
47
|
+
*/
|
|
48
|
+
const importers = (!moduleInfo ? [] : Array.from(moduleInfo.importers))
|
|
47
49
|
.map((m) => m.id)
|
|
48
50
|
.filter((id) => id !== null);
|
|
49
51
|
assertFileEnv(id, isViteServerSide_extraSafe(config, this.environment, options), importers,
|
|
@@ -61,8 +61,10 @@ function pluginReplaceConstantsEnvVars() {
|
|
|
61
61
|
const { magicString, getMagicStringResult } = getMagicString(code, id);
|
|
62
62
|
// Get regex operations
|
|
63
63
|
const replacements = Object.entries(envVarsAll)
|
|
64
|
-
// Skip env vars that start with [`config.envPrefix`](https://vite.dev/config/shared-options.html#envprefix)
|
|
64
|
+
// Skip env vars that start with [`config.envPrefix`](https://vite.dev/config/shared-options.html#envprefix) — they are already handled by Vite
|
|
65
65
|
.filter(([envName]) => !envPrefix.some((prefix) => envName.startsWith(prefix)))
|
|
66
|
+
// Skip constants like import.meta.env.DEV which are already handled by Vite
|
|
67
|
+
.filter(([envName]) => !['DEV', 'PROD', 'SSR', 'MODE', 'BASE_URL'].includes(envName))
|
|
66
68
|
.map(([envName, envVal]) => {
|
|
67
69
|
const envStatement = `import.meta.env.${envName}`;
|
|
68
70
|
const envStatementRegExpStr = escapeRegex(envStatement) + '\\b';
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
export { pluginReplaceConstantsGlobalThis };
|
|
2
2
|
import type { Plugin } from 'vite';
|
|
3
3
|
declare global {
|
|
4
|
-
/** Like `import.meta.env.DEV` but works
|
|
5
|
-
var __VIKE__IS_DEV: boolean
|
|
6
|
-
/** Like `import.meta.env.SSR` but works
|
|
7
|
-
var __VIKE__IS_CLIENT: boolean
|
|
8
|
-
|
|
9
|
-
* Whether a debug flag is enabled (either the global flag `DEBUG=vike` or a specific flag `DEBUG=vike:some-flag`).
|
|
10
|
-
*
|
|
11
|
-
* WARNING: must be used ONLY on the client-side. (The value is always `undefined` on the server-side.)
|
|
12
|
-
*
|
|
13
|
-
* In isomorhpic code, use `globalThis.__VIKE__IS_CLIENT` to make sure it's only used on the client-side.
|
|
14
|
-
*/
|
|
15
|
-
var __VIKE__IS_DEBUG: boolean | undefined;
|
|
4
|
+
/** Like `import.meta.env.DEV` but works for `node_modules/` packages with `ssr.external` */
|
|
5
|
+
var __VIKE__IS_DEV: boolean;
|
|
6
|
+
/** Like `import.meta.env.SSR` but works for `node_modules/` packages with `ssr.external` */
|
|
7
|
+
var __VIKE__IS_CLIENT: boolean;
|
|
8
|
+
var __VIKE__IS_DEBUG: boolean;
|
|
16
9
|
}
|
|
17
10
|
declare function pluginReplaceConstantsGlobalThis(): Plugin[];
|
|
@@ -1,52 +1,77 @@
|
|
|
1
1
|
export { pluginReplaceConstantsGlobalThis };
|
|
2
|
-
import { assert, isDebug } from '../utils.js';
|
|
3
|
-
|
|
4
|
-
|
|
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`).
|
|
2
|
+
import { assert, isDebug, addVirtualFileIdPrefix, escapeRegex } from '../utils.js';
|
|
3
|
+
import { isViteServerSide_applyToEnvironment, isViteServerSide_configEnvironment, isViteServerSide_extraSafe, } from '../shared/isViteServerSide.js';
|
|
4
|
+
const isDebugVal = isDebug();
|
|
15
5
|
globalThis.__VIKE__IS_CLIENT = false;
|
|
6
|
+
globalThis.__VIKE__IS_DEBUG = isDebugVal;
|
|
7
|
+
const VIRTUAL_FILE_ID = 'virtual:vike:server:globalThis-constants';
|
|
8
|
+
const filterRolldown = {
|
|
9
|
+
id: {
|
|
10
|
+
include: new RegExp(escapeRegex(VIRTUAL_FILE_ID)),
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
const filterFunction = (id) => id === VIRTUAL_FILE_ID || id === addVirtualFileIdPrefix(VIRTUAL_FILE_ID);
|
|
16
14
|
function pluginReplaceConstantsGlobalThis() {
|
|
15
|
+
let config;
|
|
16
|
+
let isDev;
|
|
17
17
|
return [
|
|
18
18
|
{
|
|
19
|
-
name: 'vike:pluginReplaceConstantsGlobalThis',
|
|
19
|
+
name: 'vike:pluginReplaceConstantsGlobalThis:define',
|
|
20
20
|
config: {
|
|
21
21
|
handler(config) {
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
assert(typeof config._isDev === 'boolean');
|
|
23
|
+
isDev = config._isDev;
|
|
24
24
|
globalThis.__VIKE__IS_DEV = isDev;
|
|
25
25
|
return {
|
|
26
26
|
define: {
|
|
27
27
|
'globalThis.__VIKE__IS_DEV': JSON.stringify(isDev),
|
|
28
|
+
'globalThis.__VIKE__IS_DEBUG': JSON.stringify(isDebugVal),
|
|
28
29
|
},
|
|
29
30
|
};
|
|
30
31
|
},
|
|
31
32
|
},
|
|
32
33
|
configEnvironment: {
|
|
33
34
|
handler(name, config) {
|
|
34
|
-
const
|
|
35
|
-
const isClientSide = consumer === 'client';
|
|
36
|
-
const defineIsDebug = !isClientSide
|
|
37
|
-
? {}
|
|
38
|
-
: {
|
|
39
|
-
// We purposely only define it on the client-side, because we cannot know the value in server-side ssr.external production.
|
|
40
|
-
'globalThis.__VIKE__IS_DEBUG': JSON.stringify(isDebug()),
|
|
41
|
-
};
|
|
35
|
+
const isClientSide = !isViteServerSide_configEnvironment(name, config);
|
|
42
36
|
return {
|
|
43
37
|
define: {
|
|
44
38
|
'globalThis.__VIKE__IS_CLIENT': JSON.stringify(isClientSide),
|
|
45
|
-
...defineIsDebug,
|
|
46
39
|
},
|
|
47
40
|
};
|
|
48
41
|
},
|
|
49
42
|
},
|
|
43
|
+
configResolved(config_) {
|
|
44
|
+
config = config_;
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'vike:pluginReplaceConstantsGlobalThis:virtual-file',
|
|
49
|
+
// We only need the virtual file for the server-side (for node_modules/ packages with ssr.external) — the `define` values above always apply to the client-side.
|
|
50
|
+
applyToEnvironment(env) {
|
|
51
|
+
return isViteServerSide_applyToEnvironment(env);
|
|
52
|
+
},
|
|
53
|
+
resolveId: {
|
|
54
|
+
filter: filterRolldown,
|
|
55
|
+
handler(id) {
|
|
56
|
+
assert(filterFunction(id));
|
|
57
|
+
assert(id === VIRTUAL_FILE_ID);
|
|
58
|
+
return addVirtualFileIdPrefix(id);
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
load: {
|
|
62
|
+
filter: filterRolldown,
|
|
63
|
+
handler(id, options) {
|
|
64
|
+
assert(filterFunction(id));
|
|
65
|
+
assert(isViteServerSide_extraSafe(config, this.environment, options));
|
|
66
|
+
assert(typeof isDev === 'boolean');
|
|
67
|
+
const code = [
|
|
68
|
+
`globalThis.__VIKE__IS_DEV = ${JSON.stringify(isDev)};`,
|
|
69
|
+
`globalThis.__VIKE__IS_CLIENT = false;`,
|
|
70
|
+
`globalThis.__VIKE__IS_DEBUG = ${JSON.stringify(isDebugVal)};`,
|
|
71
|
+
].join('\n');
|
|
72
|
+
return code;
|
|
73
|
+
},
|
|
74
|
+
},
|
|
50
75
|
},
|
|
51
76
|
];
|
|
52
77
|
}
|
|
@@ -12,6 +12,9 @@ function getCode(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isCl
|
|
|
12
12
|
const lines = [];
|
|
13
13
|
const importStatements = [];
|
|
14
14
|
const filesEnv = new Map();
|
|
15
|
+
if (!isForClientSide) {
|
|
16
|
+
importStatements.push("import 'virtual:vike:server:globalThis-constants';");
|
|
17
|
+
}
|
|
15
18
|
lines.push('export const pageConfigsSerialized = [');
|
|
16
19
|
lines.push(getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRouting, isDev, importStatements, filesEnv));
|
|
17
20
|
lines.push('];');
|
|
@@ -22,7 +25,10 @@ function getCode(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isCl
|
|
|
22
25
|
// https://vite.dev/guide/api-environment-frameworks.html
|
|
23
26
|
lines.push('if (import.meta.hot) import.meta.hot.accept();');
|
|
24
27
|
}
|
|
25
|
-
|
|
28
|
+
let code = [...importStatements, ...lines].join('\n');
|
|
29
|
+
if (!isForClientSide) {
|
|
30
|
+
code = "import 'virtual:vike:server:globalThis-constants';\n" + code;
|
|
31
|
+
}
|
|
26
32
|
debug(id, isForClientSide ? 'CLIENT-SIDE' : 'SERVER-SIDE', code);
|
|
27
33
|
return code;
|
|
28
34
|
}
|
package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js
CHANGED
|
@@ -23,6 +23,9 @@ async function getCode(config, isForClientSide, isClientRouting, isDev, id) {
|
|
|
23
23
|
const isBuild = command === 'build';
|
|
24
24
|
assert(isDev === !isBuild);
|
|
25
25
|
let content = '';
|
|
26
|
+
if (!isForClientSide) {
|
|
27
|
+
content += "import 'virtual:vike:server:globalThis-constants';\n";
|
|
28
|
+
}
|
|
26
29
|
{
|
|
27
30
|
const globRoots = getGlobRoots(config);
|
|
28
31
|
debugGlob('Glob roots: ', globRoots);
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
export { isViteServerSide };
|
|
2
|
-
export { isViteClientSide };
|
|
3
2
|
export { isViteServerSide_viteEnvOptional };
|
|
4
3
|
export { isViteServerSide_onlySsrEnv };
|
|
5
4
|
export { isViteServerSide_extraSafe };
|
|
5
|
+
export { isViteServerSide_applyToEnvironment };
|
|
6
|
+
export { isViteServerSide_configEnvironment };
|
|
6
7
|
export type { ViteEnv };
|
|
7
|
-
import type { Environment, EnvironmentOptions, ResolvedConfig, UserConfig } from 'vite';
|
|
8
|
+
import type { Environment, EnvironmentOptions, ResolvedConfig, UserConfig, Plugin } from 'vite';
|
|
8
9
|
type ViteEnv = {
|
|
9
10
|
name?: string;
|
|
10
11
|
config: EnvironmentOptions | Environment['config'];
|
|
11
12
|
};
|
|
12
13
|
declare function isViteServerSide(configGlobal: ResolvedConfig | UserConfig, viteEnv: ViteEnv): boolean;
|
|
13
14
|
declare function isViteServerSide_viteEnvOptional(configGlobal: ResolvedConfig | UserConfig, viteEnv?: ViteEnv | undefined): boolean;
|
|
14
|
-
declare function isViteClientSide(configGlobal: ResolvedConfig, viteEnv: ViteEnv): boolean;
|
|
15
15
|
declare function isViteServerSide_onlySsrEnv(configGlobal: ResolvedConfig, viteEnv: ViteEnv): boolean;
|
|
16
16
|
declare function isViteServerSide_extraSafe(config: ResolvedConfig, viteEnv: ViteEnv, options: {
|
|
17
17
|
ssr?: boolean;
|
|
18
18
|
} | undefined): boolean;
|
|
19
|
+
type PartialEnvironment = Parameters<NonNullable<Plugin['applyToEnvironment']>>[0];
|
|
20
|
+
declare function isViteServerSide_applyToEnvironment(env: PartialEnvironment): boolean;
|
|
21
|
+
declare function isViteServerSide_configEnvironment(name: string, config: EnvironmentOptions): boolean;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { isViteServerSide };
|
|
2
|
-
export { isViteClientSide };
|
|
3
2
|
export { isViteServerSide_viteEnvOptional };
|
|
4
3
|
export { isViteServerSide_onlySsrEnv };
|
|
5
4
|
export { isViteServerSide_extraSafe };
|
|
5
|
+
export { isViteServerSide_applyToEnvironment };
|
|
6
|
+
export { isViteServerSide_configEnvironment };
|
|
6
7
|
import { assert } from '../../../utils/assert.js';
|
|
7
8
|
function isViteServerSide_impl(configGlobal, viteEnv) {
|
|
8
9
|
assert(!('consumer' in configGlobal)); // make sure configGlobal isn't viteEnv.config
|
|
@@ -42,9 +43,6 @@ function isViteServerSide(configGlobal, viteEnv) {
|
|
|
42
43
|
function isViteServerSide_viteEnvOptional(configGlobal, viteEnv) {
|
|
43
44
|
return isViteServerSide_impl(configGlobal, viteEnv);
|
|
44
45
|
}
|
|
45
|
-
function isViteClientSide(configGlobal, viteEnv) {
|
|
46
|
-
return !isViteServerSide(configGlobal, viteEnv);
|
|
47
|
-
}
|
|
48
46
|
// Only `ssr` env: for example don't include `vercel_edge` nor `vercel_node`.
|
|
49
47
|
function isViteServerSide_onlySsrEnv(configGlobal, viteEnv) {
|
|
50
48
|
return viteEnv.name ? viteEnv.name === 'ssr' : isViteServerSide(configGlobal, viteEnv);
|
|
@@ -64,3 +62,14 @@ function isViteServerSide_extraSafe(config, viteEnv, options) {
|
|
|
64
62
|
assert(options.ssr === isServerSide, debug);
|
|
65
63
|
return isServerSide;
|
|
66
64
|
}
|
|
65
|
+
function isViteServerSide_applyToEnvironment(env) {
|
|
66
|
+
const { consumer } = env.config;
|
|
67
|
+
return isViteServerSide_consumer(consumer);
|
|
68
|
+
}
|
|
69
|
+
function isViteServerSide_configEnvironment(name, config) {
|
|
70
|
+
const consumer = config.consumer ?? (name === 'client' ? 'client' : 'server');
|
|
71
|
+
return isViteServerSide_consumer(consumer);
|
|
72
|
+
}
|
|
73
|
+
function isViteServerSide_consumer(consumer) {
|
|
74
|
+
return consumer !== 'client';
|
|
75
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.240-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.240-commit-95fc969";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.240-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.240-commit-95fc969';
|
|
@@ -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
|
}
|