vike 0.4.237-commit-2d6f480 → 0.4.237-commit-cc7f0f6
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/node/api/build.js +1 -1
- package/dist/cjs/node/prerender/runPrerenderEntry.js +1 -1
- package/dist/cjs/node/runtime/globalContext.js +7 -2
- package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +7 -7
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +120 -2
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +4 -124
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginBuild.js +0 -1
- package/dist/cjs/node/vite/plugins/pluginEnvVars.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +3 -3
- package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginFileEnv.js +2 -2
- package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFilePageEntry.js +4 -4
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles.js +1 -1
- package/dist/cjs/node/vite/shared/getOutDirs.js +2 -6
- package/dist/cjs/node/vite/shared/isViteServerSide.js +25 -56
- package/dist/cjs/shared/createGlobalContextShared.js +9 -5
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/node/api/build.js +1 -1
- package/dist/esm/node/prerender/runPrerenderEntry.js +1 -1
- package/dist/esm/node/runtime/globalContext.js +7 -2
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.d.ts +3 -3
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.js +7 -7
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildApp.js +117 -2
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.d.ts +0 -4
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.js +7 -124
- package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild.js +1 -2
- package/dist/esm/node/vite/plugins/pluginEnvVars.js +1 -1
- package/dist/esm/node/vite/plugins/pluginExtractAssets.js +3 -3
- package/dist/esm/node/vite/plugins/pluginExtractExportNames.js +1 -1
- package/dist/esm/node/vite/plugins/pluginFileEnv.js +2 -2
- package/dist/esm/node/vite/plugins/pluginReplaceConstants.js +1 -1
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +1 -1
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFilePageEntry.d.ts +1 -2
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFilePageEntry.js +4 -4
- package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +1 -1
- package/dist/esm/node/vite/shared/getOutDirs.d.ts +1 -1
- package/dist/esm/node/vite/shared/getOutDirs.js +3 -7
- package/dist/esm/node/vite/shared/isViteServerSide.d.ts +4 -4
- package/dist/esm/node/vite/shared/isViteServerSide.js +25 -56
- package/dist/esm/shared/createGlobalContextShared.d.ts +1 -0
- package/dist/esm/shared/createGlobalContextShared.js +10 -6
- package/dist/esm/types/Config.d.ts +1 -3
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/package.json +1 -1
|
@@ -45,7 +45,7 @@ function pluginExtractAssets() {
|
|
|
45
45
|
}
|
|
46
46
|
const includeAssetsImportedByServer = resolveIncludeAssetsImportedByServer(vikeConfig.config);
|
|
47
47
|
assert(includeAssetsImportedByServer);
|
|
48
|
-
assert(!isViteServerSide_extraSafe(config,
|
|
48
|
+
assert(!isViteServerSide_extraSafe(config, this.environment, options));
|
|
49
49
|
const importStatements = await getImportStatements(src);
|
|
50
50
|
const moduleNames = getImportedModules(importStatements);
|
|
51
51
|
const code = moduleNames.map((moduleName) => `import '${moduleName}';`).join('\n');
|
|
@@ -62,7 +62,7 @@ function pluginExtractAssets() {
|
|
|
62
62
|
// - Vite's `vite:resolve` plugin; https://github.com/vitejs/vite/blob/d649daba7682791178b711d9a3e44a6b5d00990c/packages/vite/src/node/plugins/resolve.ts#L105
|
|
63
63
|
enforce: 'pre',
|
|
64
64
|
async resolveId(source, importer, options) {
|
|
65
|
-
if (isViteServerSide_extraSafe(config,
|
|
65
|
+
if (isViteServerSide_extraSafe(config, this.environment, options)) {
|
|
66
66
|
// When building for the server, there should never be a `?extractAssets` query
|
|
67
67
|
assert(!extractAssetsRE.test(source));
|
|
68
68
|
assert(importer === undefined || !extractAssetsRE.test(importer));
|
|
@@ -139,7 +139,7 @@ function pluginExtractAssets() {
|
|
|
139
139
|
async configResolved(config_) {
|
|
140
140
|
config = config_;
|
|
141
141
|
vikeConfig = await getVikeConfigInternal();
|
|
142
|
-
isFixEnabled = handleAssetsManifest_isFixEnabled(
|
|
142
|
+
isFixEnabled = handleAssetsManifest_isFixEnabled();
|
|
143
143
|
if (!isFixEnabled) {
|
|
144
144
|
// https://github.com/vikejs/vike/issues/1060
|
|
145
145
|
assertUsage(!config.plugins.find((p) => p.name === 'vite-tsconfig-paths'), 'vite-tsconfig-paths not supported, remove it and use vite.config.js#resolve.alias instead');
|
|
@@ -16,7 +16,7 @@ function pluginExtractExportNames() {
|
|
|
16
16
|
enforce: 'post',
|
|
17
17
|
async transform(src, id, options) {
|
|
18
18
|
id = normalizeId(id);
|
|
19
|
-
const isClientSide = !isViteServerSide_extraSafe(config,
|
|
19
|
+
const isClientSide = !isViteServerSide_extraSafe(config, this.environment, options);
|
|
20
20
|
if (extractExportNamesRE.test(id)) {
|
|
21
21
|
const code = await getExtractExportNamesCode(src, isClientSide, !isDev, id);
|
|
22
22
|
debug('id ' + id, ['result:\n' + code.code.trim(), 'src:\n' + src.trim()]);
|
|
@@ -29,7 +29,7 @@ function pluginFileEnv() {
|
|
|
29
29
|
const importers = Array.from(moduleInfo.importers)
|
|
30
30
|
.map((m) => m.id)
|
|
31
31
|
.filter((id) => id !== null);
|
|
32
|
-
assertFileEnv(id, isViteServerSide_extraSafe(config,
|
|
32
|
+
assertFileEnv(id, isViteServerSide_extraSafe(config, this.environment, options), importers,
|
|
33
33
|
// In dev, we only show a warning because we don't want to disrupt when the user plays with settings such as [ssr](https://vike.dev/ssr).
|
|
34
34
|
true);
|
|
35
35
|
},
|
|
@@ -41,7 +41,7 @@ function pluginFileEnv() {
|
|
|
41
41
|
return;
|
|
42
42
|
if (skip(id))
|
|
43
43
|
return;
|
|
44
|
-
const isServerSide = isViteServerSide_extraSafe(config,
|
|
44
|
+
const isServerSide = isViteServerSide_extraSafe(config, this.environment, options);
|
|
45
45
|
if (!isWrongEnv(id, isServerSide))
|
|
46
46
|
return;
|
|
47
47
|
const { importers } = this.getModuleInfo(id);
|
|
@@ -33,7 +33,7 @@ function pluginReplaceConstants() {
|
|
|
33
33
|
const constantsMap = [];
|
|
34
34
|
constantsMap.push({
|
|
35
35
|
constants: ['pageContext.isClientSide', 'globalContext.isClientSide', 'pageContext.globalContext.isClientSide'],
|
|
36
|
-
replacement: !isViteServerSide_extraSafe(config,
|
|
36
|
+
replacement: !isViteServerSide_extraSafe(config, this.environment, options),
|
|
37
37
|
});
|
|
38
38
|
constantsMap.forEach(({ constants, replacement }) => {
|
|
39
39
|
if (!constants.some((c) => code.includes(c)))
|
package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js
CHANGED
|
@@ -13,7 +13,7 @@ async function generateVirtualFileGlobalEntryWithOldDesign(id, options, config,
|
|
|
13
13
|
const idParsed = parseVirtualFileId(id);
|
|
14
14
|
assert(idParsed && idParsed.type === 'global-entry');
|
|
15
15
|
const { isForClientSide, isClientRouting } = idParsed;
|
|
16
|
-
assert(isForClientSide === !isViteServerSide_extraSafe(config,
|
|
16
|
+
assert(isForClientSide === !isViteServerSide_extraSafe(config, env, options));
|
|
17
17
|
const code = await getCode(config, isForClientSide, isClientRouting, isDev, id);
|
|
18
18
|
return code;
|
|
19
19
|
}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
export { generateVirtualFilePageEntry };
|
|
2
|
-
|
|
3
|
-
declare function generateVirtualFilePageEntry(id: string, isDev: boolean, config: ResolvedConfig): Promise<string>;
|
|
2
|
+
declare function generateVirtualFilePageEntry(id: string, isDev: boolean): Promise<string>;
|
|
@@ -8,7 +8,7 @@ import { serializeConfigValues } from '../../../../shared/page-configs/serialize
|
|
|
8
8
|
import { handleAssetsManifest_isFixEnabled } from '../pluginBuild/handleAssetsManifest.js';
|
|
9
9
|
import { getConfigValueBuildTime } from '../../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
10
10
|
import { resolveIncludeAssetsImportedByServer } from '../../../runtime/renderPage/getPageAssets/retrievePageAssetsProd.js';
|
|
11
|
-
async function generateVirtualFilePageEntry(id, isDev
|
|
11
|
+
async function generateVirtualFilePageEntry(id, isDev) {
|
|
12
12
|
const result = parseVirtualFileId(id);
|
|
13
13
|
assert(result && result.type === 'page-entry');
|
|
14
14
|
/* This assertion fails when using includeAssetsImportedByServer
|
|
@@ -32,11 +32,11 @@ async function generateVirtualFilePageEntry(id, isDev, config) {
|
|
|
32
32
|
throw getProjectError('Outdated request');
|
|
33
33
|
//*/
|
|
34
34
|
}
|
|
35
|
-
const code = getCode(pageConfig, isForClientSide, pageId, resolveIncludeAssetsImportedByServer(vikeConfig.config),
|
|
35
|
+
const code = getCode(pageConfig, isForClientSide, pageId, resolveIncludeAssetsImportedByServer(vikeConfig.config), isDev);
|
|
36
36
|
debug(id, isForClientSide ? 'CLIENT-SIDE' : 'SERVER-SIDE', code);
|
|
37
37
|
return code;
|
|
38
38
|
}
|
|
39
|
-
function getCode(pageConfig, isForClientSide, pageId, includeAssetsImportedByServer,
|
|
39
|
+
function getCode(pageConfig, isForClientSide, pageId, includeAssetsImportedByServer, isDev) {
|
|
40
40
|
const lines = [];
|
|
41
41
|
const importStatements = [];
|
|
42
42
|
const filesEnv = new Map();
|
|
@@ -44,7 +44,7 @@ function getCode(pageConfig, isForClientSide, pageId, includeAssetsImportedBySer
|
|
|
44
44
|
lines.push('export const configValuesSerialized = {');
|
|
45
45
|
lines.push(...serializeConfigValues(pageConfig, importStatements, filesEnv, { isForClientSide, isClientRouting, isDev }, '', false));
|
|
46
46
|
lines.push('};');
|
|
47
|
-
if (!handleAssetsManifest_isFixEnabled(
|
|
47
|
+
if (!handleAssetsManifest_isFixEnabled() && includeAssetsImportedByServer && isForClientSide && !isDev) {
|
|
48
48
|
importStatements.push(`import '${extractAssetsAddQuery(generateVirtualFileId({ type: 'page-entry', pageId, isForClientSide: false }))}'`);
|
|
49
49
|
}
|
|
50
50
|
const code = [...importStatements, ...lines].join('\n');
|
|
@@ -46,7 +46,7 @@ function pluginVirtualFiles() {
|
|
|
46
46
|
const idParsed = parseVirtualFileId(id);
|
|
47
47
|
if (idParsed) {
|
|
48
48
|
if (idParsed.type === 'page-entry') {
|
|
49
|
-
const code = await generateVirtualFilePageEntry(id, isDev
|
|
49
|
+
const code = await generateVirtualFilePageEntry(id, isDev);
|
|
50
50
|
return code;
|
|
51
51
|
}
|
|
52
52
|
if (idParsed.type === 'global-entry') {
|
|
@@ -2,7 +2,7 @@ export { getOutDirs };
|
|
|
2
2
|
export { resolveOutDir };
|
|
3
3
|
export type { OutDirs };
|
|
4
4
|
import type { UserConfig, ResolvedConfig } from 'vite';
|
|
5
|
-
import { ViteEnv } from './isViteServerSide.js';
|
|
5
|
+
import { type ViteEnv } from './isViteServerSide.js';
|
|
6
6
|
type OutDirs = {
|
|
7
7
|
/** Absolute path to `outDir` */
|
|
8
8
|
outDirRoot: string;
|
|
@@ -2,7 +2,7 @@ export { getOutDirs };
|
|
|
2
2
|
export { resolveOutDir };
|
|
3
3
|
import pc from '@brillout/picocolors';
|
|
4
4
|
import { assert, assertPosixPath, assertUsage, createDebugger, pathJoin, toPosixPath } from '../utils.js';
|
|
5
|
-
import {
|
|
5
|
+
import { isViteServerSide_viteEnvOptional } from './isViteServerSide.js';
|
|
6
6
|
const debug = createDebugger('vike:outDir');
|
|
7
7
|
function getOutDirs(configGlobal, viteEnv) {
|
|
8
8
|
debug('getOutDirs()', new Error().stack);
|
|
@@ -16,13 +16,9 @@ function getOutDirs(configGlobal, viteEnv) {
|
|
|
16
16
|
}
|
|
17
17
|
/** Appends `client/` or `server/` to `config.build.outDir` */
|
|
18
18
|
function resolveOutDir(config, isServerSide) {
|
|
19
|
-
debug('resolveOutDir()'
|
|
20
|
-
debug('isServerSide', isServerSide);
|
|
19
|
+
debug('resolveOutDir()');
|
|
21
20
|
const outDir = getOutDirFromViteUserConfig(config) || 'dist';
|
|
22
21
|
debug('outDir', outDir);
|
|
23
|
-
/* outDir may already be resolved when using Telefunc + Vike (because both Telefunc and Vike use this logic)
|
|
24
|
-
assert(isOutDirRoot(outDir))
|
|
25
|
-
*/
|
|
26
22
|
const { outDirClient, outDirServer } = getOutDirsAll(outDir);
|
|
27
23
|
if (isServerSide) {
|
|
28
24
|
debug('outDirServer', 'outDirServer');
|
|
@@ -107,7 +103,7 @@ function assertOutDirResolved(outDir, configGlobal, viteEnv) {
|
|
|
107
103
|
assert('/client'.length === '/server'.length);
|
|
108
104
|
const outDirCorrected = outDir.slice(0, -1 * '/client'.length);
|
|
109
105
|
const wrongUsage = `You've set Vite's config.build.outDir to ${pc.cyan(outDir)} but you should set it to ${pc.cyan(outDirCorrected)} instead.`;
|
|
110
|
-
const isServerSide =
|
|
106
|
+
const isServerSide = isViteServerSide_viteEnvOptional(configGlobal, viteEnv);
|
|
111
107
|
if (isServerSide) {
|
|
112
108
|
assertUsage(outDir.endsWith('/server'), wrongUsage);
|
|
113
109
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { isViteServerSide };
|
|
2
2
|
export { isViteClientSide };
|
|
3
|
-
export {
|
|
3
|
+
export { isViteServerSide_viteEnvOptional };
|
|
4
4
|
export { isViteServerSide_onlySsrEnv };
|
|
5
5
|
export { isViteServerSide_extraSafe };
|
|
6
6
|
export type { ViteEnv };
|
|
@@ -10,9 +10,9 @@ type ViteEnv = {
|
|
|
10
10
|
config: EnvironmentOptions | Environment['config'];
|
|
11
11
|
};
|
|
12
12
|
declare function isViteServerSide(configGlobal: ResolvedConfig | UserConfig, viteEnv: ViteEnv): boolean;
|
|
13
|
-
declare function
|
|
13
|
+
declare function isViteServerSide_viteEnvOptional(configGlobal: ResolvedConfig | UserConfig, viteEnv?: ViteEnv | undefined): boolean;
|
|
14
14
|
declare function isViteClientSide(configGlobal: ResolvedConfig, viteEnv: ViteEnv): boolean;
|
|
15
15
|
declare function isViteServerSide_onlySsrEnv(configGlobal: ResolvedConfig, viteEnv: ViteEnv): boolean;
|
|
16
|
-
declare function isViteServerSide_extraSafe(config: ResolvedConfig, options: {
|
|
16
|
+
declare function isViteServerSide_extraSafe(config: ResolvedConfig, viteEnv: ViteEnv, options: {
|
|
17
17
|
ssr?: boolean;
|
|
18
|
-
} | undefined
|
|
18
|
+
} | undefined): boolean;
|
|
@@ -1,56 +1,45 @@
|
|
|
1
1
|
export { isViteServerSide };
|
|
2
2
|
export { isViteClientSide };
|
|
3
|
-
export {
|
|
3
|
+
export { isViteServerSide_viteEnvOptional };
|
|
4
4
|
export { isViteServerSide_onlySsrEnv };
|
|
5
5
|
export { isViteServerSide_extraSafe };
|
|
6
6
|
import { assert } from '../../../utils/assert.js';
|
|
7
7
|
function isViteServerSide_impl(configGlobal, viteEnv) {
|
|
8
8
|
assert(!('consumer' in configGlobal)); // make sure configGlobal isn't viteEnv.config
|
|
9
|
-
const isServerSide1 = !viteEnv?.config.consumer ? null : viteEnv.config.consumer !== 'client';
|
|
10
|
-
const isServerSide2 = !viteEnv?.config.build ? null : getBuildSsrValue(viteEnv.config.build.ssr);
|
|
11
|
-
const isServerSide3 = !configGlobal.build ? null : getBuildSsrValue(configGlobal.build.ssr);
|
|
12
|
-
const isServerSide4 = viteEnv?.name === 'ssr' ? true : viteEnv?.name === 'client' ? false : null;
|
|
13
9
|
const debug = {
|
|
14
10
|
viteEnvIsUndefined: !viteEnv,
|
|
15
11
|
viteEnvName: viteEnv?.name ?? null,
|
|
16
12
|
viteEnvConsumer: viteEnv?.config.consumer ?? null,
|
|
17
13
|
configEnvBuildSsr: viteEnv?.config.build?.ssr ?? null,
|
|
18
14
|
configGlobalBuildSsr: configGlobal.build?.ssr ?? null,
|
|
19
|
-
isServerSide1,
|
|
20
|
-
isServerSide2,
|
|
21
|
-
isServerSide3,
|
|
22
|
-
isServerSide4,
|
|
23
15
|
};
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
*/
|
|
29
|
-
return isServerSide1;
|
|
30
|
-
}
|
|
31
|
-
if (isServerSide2 !== null) {
|
|
32
|
-
// assert(isServerSide2 === isServerSide4 || isServerSide4 === null, debug)
|
|
33
|
-
return isServerSide2;
|
|
34
|
-
}
|
|
35
|
-
if (isServerSide3 !== null) {
|
|
36
|
-
// assert(isServerSide3 === isServerSide4 || isServerSide4 === null, debug)
|
|
37
|
-
return isServerSide3;
|
|
16
|
+
if (!viteEnv) {
|
|
17
|
+
const isServerSide = getBuildSsrValue(configGlobal.build?.ssr);
|
|
18
|
+
assert(typeof isServerSide === 'boolean', debug);
|
|
19
|
+
return isServerSide;
|
|
38
20
|
}
|
|
39
|
-
|
|
40
|
-
|
|
21
|
+
else {
|
|
22
|
+
const isServerSide1 = !viteEnv.config.consumer ? null : viteEnv.config.consumer !== 'client';
|
|
23
|
+
const isServerSide2 = getBuildSsrValue(viteEnv.config.build?.ssr);
|
|
24
|
+
const isServerSide3 = viteEnv.name === 'ssr' ? true : viteEnv.name === 'client' ? false : null;
|
|
25
|
+
const isServerSide = isServerSide1 ?? isServerSide2;
|
|
26
|
+
assert(isServerSide === isServerSide1 || isServerSide1 === null, debug);
|
|
27
|
+
assert(isServerSide === isServerSide2 || isServerSide2 === null, debug);
|
|
28
|
+
assert(isServerSide === isServerSide3 || isServerSide3 === null, debug);
|
|
29
|
+
assert(isServerSide !== null);
|
|
30
|
+
return isServerSide;
|
|
41
31
|
}
|
|
42
|
-
assert(!viteEnv);
|
|
43
|
-
return !!configGlobal.build?.ssr;
|
|
44
32
|
}
|
|
45
33
|
function getBuildSsrValue(buildSsr) {
|
|
46
34
|
if (buildSsr === undefined)
|
|
47
35
|
return null;
|
|
36
|
+
assert(typeof buildSsr === 'boolean' || typeof buildSsr === 'string');
|
|
48
37
|
return !!buildSsr;
|
|
49
38
|
}
|
|
50
39
|
function isViteServerSide(configGlobal, viteEnv) {
|
|
51
40
|
return isViteServerSide_impl(configGlobal, viteEnv);
|
|
52
41
|
}
|
|
53
|
-
function
|
|
42
|
+
function isViteServerSide_viteEnvOptional(configGlobal, viteEnv) {
|
|
54
43
|
return isViteServerSide_impl(configGlobal, viteEnv);
|
|
55
44
|
}
|
|
56
45
|
function isViteClientSide(configGlobal, viteEnv) {
|
|
@@ -61,37 +50,17 @@ function isViteServerSide_onlySsrEnv(configGlobal, viteEnv) {
|
|
|
61
50
|
return viteEnv.name ? viteEnv.name === 'ssr' : isViteServerSide(configGlobal, viteEnv);
|
|
62
51
|
}
|
|
63
52
|
// Vite is quite messy about setting config.build.ssr — for security purposes, we use an extra safe implementation with lots of assertions, which is needed for the .client.js and .server.js guarantee.
|
|
64
|
-
function isViteServerSide_extraSafe(config,
|
|
53
|
+
function isViteServerSide_extraSafe(config, viteEnv, options) {
|
|
65
54
|
const isServerSide = isViteServerSide(config, viteEnv);
|
|
66
55
|
const debug = {
|
|
56
|
+
isServerSide,
|
|
67
57
|
configCommand: config.command,
|
|
68
|
-
configBuildSsr: config.build.ssr,
|
|
58
|
+
configBuildSsr: getBuildSsrValue(config.build.ssr),
|
|
69
59
|
optionsIsUndefined: options === undefined,
|
|
70
|
-
optionsSsr: options?.ssr,
|
|
71
|
-
isServerSide,
|
|
60
|
+
optionsSsr: options?.ssr ?? null,
|
|
72
61
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return res;
|
|
78
|
-
}
|
|
79
|
-
return isServerSide;
|
|
80
|
-
}
|
|
81
|
-
if (config.command === 'build') {
|
|
82
|
-
const res = config.build.ssr;
|
|
83
|
-
assert(typeof res === 'boolean', debug);
|
|
84
|
-
assert(res === options?.ssr || options?.ssr === undefined, debug);
|
|
85
|
-
assert(res === isServerSide, debug);
|
|
86
|
-
return res;
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
const res = options?.ssr;
|
|
90
|
-
assert(typeof res === 'boolean', debug);
|
|
91
|
-
/* This assertion can fail, seems to be a Vite bug? It's very unexpected.
|
|
92
|
-
if (typeof config.build.ssr === 'boolean') assert(res === config.build.ssr)
|
|
93
|
-
*/
|
|
94
|
-
assert(res === isServerSide, debug);
|
|
95
|
-
return res;
|
|
96
|
-
}
|
|
62
|
+
assert(options, debug);
|
|
63
|
+
assert(typeof options.ssr === 'boolean', debug);
|
|
64
|
+
assert(options.ssr === isServerSide, debug);
|
|
65
|
+
return isServerSide;
|
|
97
66
|
}
|
|
@@ -12,6 +12,7 @@ declare const getGlobalContextSyncErrMsg = "The global context isn't set yet, ca
|
|
|
12
12
|
declare function createGlobalContextShared<GlobalContextAdded extends Record<string, any>, GlobalContextAddedAsync extends Record<string, any>>(virtualFileExportsGlobalEntry: unknown, globalObject: {
|
|
13
13
|
globalContext?: Record<string, unknown>;
|
|
14
14
|
onCreateGlobalContextHooks?: Hook[];
|
|
15
|
+
previousCallPromise?: Promise<void>;
|
|
15
16
|
}, addGlobalContext?: (globalContext: GlobalContextBase) => GlobalContextAdded, addGlobalContextTmp?: (globalContext: GlobalContextBase) => Promise<GlobalContextAdded>, addGlobalContextAsync?: (globalContext: GlobalContextBase) => Promise<GlobalContextAddedAsync>): Promise<{
|
|
16
17
|
/**
|
|
17
18
|
* Useful for distinguishing `globalContext` from other objects and narrowing down TypeScript unions.
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
export { createGlobalContextShared };
|
|
2
2
|
export { getGlobalContextSyncErrMsg };
|
|
3
|
-
import { changeEnumerable, genPromise,
|
|
3
|
+
import { assert, changeEnumerable, genPromise, objectAssign, objectReplace, unique } from './utils.js';
|
|
4
4
|
import { parseVirtualFileExportsGlobalEntry } from './getPageFiles/parseVirtualFileExportsGlobalEntry.js';
|
|
5
5
|
import { resolveVikeConfigPublicGlobal, resolveVikeConfigPublicPageEagerLoaded, } from './page-configs/resolveVikeConfigPublic.js';
|
|
6
6
|
import { execHookGlobal } from './hooks/execHook.js';
|
|
7
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
|
-
const globalObject_ = getGlobalObject('shared/createGlobalContextShared.ts', {});
|
|
11
10
|
// TO-DO/eventually use flat globalContext — like flat pageContext
|
|
12
|
-
async function createGlobalContextShared(virtualFileExportsGlobalEntry,
|
|
11
|
+
async function createGlobalContextShared(virtualFileExportsGlobalEntry,
|
|
12
|
+
// TODO/now rename previousCallPromise to previousCreateGlobalContextPromise
|
|
13
|
+
globalObject, addGlobalContext,
|
|
13
14
|
// 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
15
|
addGlobalContextTmp, addGlobalContextAsync) {
|
|
15
|
-
const { previousCallPromise } =
|
|
16
|
+
const { previousCallPromise } = globalObject;
|
|
16
17
|
const { promise, resolve } = genPromise({
|
|
17
18
|
// Avoid this Cloudflare Worker error:
|
|
18
19
|
// ```console
|
|
@@ -20,8 +21,11 @@ addGlobalContextTmp, addGlobalContextAsync) {
|
|
|
20
21
|
// ```
|
|
21
22
|
timeout: null,
|
|
22
23
|
});
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
globalObject.previousCallPromise = promise;
|
|
25
|
+
if (previousCallPromise) {
|
|
26
|
+
assert(globalObject.globalContext);
|
|
27
|
+
await previousCallPromise;
|
|
28
|
+
}
|
|
25
29
|
const globalContext = createGlobalContextBase(virtualFileExportsGlobalEntry);
|
|
26
30
|
let isNewGlobalContext;
|
|
27
31
|
if (!globalObject.globalContext) {
|
|
@@ -403,9 +403,7 @@ type ConfigBuiltIn = {
|
|
|
403
403
|
includeAssetsImportedByServer?: boolean;
|
|
404
404
|
/** @deprecated See https://vike.dev/disableAutoFullBuild */
|
|
405
405
|
disableAutoFullBuild?: boolean | 'prerender';
|
|
406
|
-
/**
|
|
407
|
-
* @deprecated It's value is now always true.
|
|
408
|
-
*/
|
|
406
|
+
/** @deprecated It's value is now always true. */
|
|
409
407
|
vite6BuilderApp?: true;
|
|
410
408
|
/** The Base URL of your server.
|
|
411
409
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.237-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.237-commit-cc7f0f6";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.237-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.237-commit-cc7f0f6';
|