vike 0.4.223 → 0.4.224
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 +4 -37
- package/dist/cjs/node/api/prepareViteApiCall.js +9 -3
- package/dist/cjs/node/plugin/index.js +8 -20
- package/dist/cjs/node/plugin/plugins/baseUrls.js +3 -1
- package/dist/cjs/node/plugin/plugins/{buildConfig/fixServerAssets.js → build/handleAssetsManifest.js} +130 -52
- package/dist/cjs/node/plugin/plugins/build/pluginAutoFullBuild.js +145 -0
- package/dist/cjs/node/plugin/plugins/build/pluginBuildApp.js +52 -0
- package/dist/cjs/node/plugin/plugins/{buildConfig.js → build/pluginBuildConfig.js} +22 -84
- package/dist/cjs/node/plugin/plugins/{buildEntry/index.js → build/pluginBuildEntry.js} +9 -9
- package/dist/cjs/node/plugin/plugins/{distFileNames.js → build/pluginDistFileNames.js} +7 -7
- package/dist/cjs/node/plugin/plugins/{packageJsonFile.js → build/pluginDistPackageJsonFile.js} +6 -6
- package/dist/cjs/node/plugin/plugins/{suppressRollupWarning.js → build/pluginSuppressRollupWarning.js} +3 -3
- package/dist/cjs/node/plugin/plugins/build.js +21 -0
- package/dist/cjs/node/plugin/plugins/commonConfig.js +22 -4
- package/dist/cjs/node/plugin/plugins/devConfig/determineFsAllowList.js +1 -1
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +5 -5
- package/dist/cjs/node/plugin/plugins/envVars.js +2 -2
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +9 -9
- package/dist/cjs/node/plugin/plugins/extractExportNamesPlugin.js +2 -2
- package/dist/cjs/node/plugin/plugins/fileEnv.js +5 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +3 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +2 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/assertExtensions.js +5 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +7 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles/ignorePatternsBuiltIn.js +16 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +50 -64
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +2 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.js +3 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +19 -7
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +277 -212
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/virtual-files/getVirtualFilePageConfigValuesAll.js +4 -4
- package/dist/cjs/node/plugin/shared/findPageFiles.js +3 -3
- package/dist/cjs/node/plugin/shared/getOutDirs.js +8 -7
- package/dist/cjs/node/plugin/shared/isViteServerBuild.js +47 -0
- package/dist/cjs/node/plugin/shared/resolveClientEntriesDev.js +1 -1
- package/dist/cjs/node/plugin/utils.js +1 -0
- package/dist/cjs/node/prerender/context.js +3 -8
- package/dist/cjs/node/prerender/resolvePrerenderConfig.js +23 -21
- package/dist/cjs/node/prerender/runPrerender.js +28 -28
- package/dist/cjs/node/prerender/utils.js +1 -0
- package/dist/cjs/node/runtime/renderPage/logErrorHint.js +7 -1
- package/dist/cjs/shared/getPageContextUrlComputed.js +1 -1
- package/dist/cjs/shared/page-configs/getConfigValueBuildTime.js +2 -5
- package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +3 -1
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +20 -9
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/findFile.js +1 -1
- package/dist/cjs/utils/findPackageJson.js +1 -1
- package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +10 -4
- package/dist/cjs/utils/path.js +1 -0
- package/dist/cjs/utils/requireResolve.js +11 -4
- package/dist/cjs/utils/sorter.js +0 -3
- package/dist/esm/client/client-routing-runtime/index.d.ts +1 -0
- package/dist/esm/client/client-routing-runtime/index.js +1 -0
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.d.ts +8 -0
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +10 -1
- package/dist/esm/node/api/build.js +4 -4
- package/dist/esm/node/api/prepareViteApiCall.js +9 -3
- package/dist/esm/node/plugin/index.d.ts +2 -1
- package/dist/esm/node/plugin/index.js +4 -17
- package/dist/esm/node/plugin/plugins/baseUrls.js +3 -1
- package/dist/esm/node/plugin/plugins/build/handleAssetsManifest.d.ts +18 -0
- package/dist/esm/node/plugin/plugins/{buildConfig/fixServerAssets.js → build/handleAssetsManifest.js} +131 -53
- package/dist/esm/node/plugin/plugins/build/pluginAutoFullBuild.d.ts +5 -0
- package/dist/esm/node/plugin/plugins/build/pluginAutoFullBuild.js +140 -0
- package/dist/esm/node/plugin/plugins/build/pluginBuildApp.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/build/pluginBuildApp.js +50 -0
- package/dist/esm/node/plugin/plugins/{buildConfig.d.ts → build/pluginBuildConfig.d.ts} +3 -3
- package/dist/esm/node/plugin/plugins/{buildConfig.js → build/pluginBuildConfig.js} +22 -81
- package/dist/esm/node/plugin/plugins/build/pluginBuildEntry.d.ts +7 -0
- package/dist/esm/node/plugin/plugins/{buildEntry/index.js → build/pluginBuildEntry.js} +9 -9
- package/dist/esm/node/plugin/plugins/build/pluginDistFileNames.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/{distFileNames.js → build/pluginDistFileNames.js} +7 -7
- package/dist/esm/node/plugin/plugins/build/pluginDistPackageJsonFile.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/{packageJsonFile.js → build/pluginDistPackageJsonFile.js} +7 -6
- package/dist/esm/node/plugin/plugins/build/pluginSuppressRollupWarning.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/{suppressRollupWarning.js → build/pluginSuppressRollupWarning.js} +3 -3
- package/dist/esm/node/plugin/plugins/build.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/build.js +19 -0
- package/dist/esm/node/plugin/plugins/commonConfig.d.ts +15 -6
- package/dist/esm/node/plugin/plugins/commonConfig.js +22 -4
- package/dist/esm/node/plugin/plugins/devConfig/determineFsAllowList.js +1 -1
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +5 -5
- package/dist/esm/node/plugin/plugins/envVars.js +2 -2
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +10 -10
- package/dist/esm/node/plugin/plugins/extractExportNamesPlugin.js +2 -2
- package/dist/esm/node/plugin/plugins/fileEnv.js +5 -2
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +2 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/assertExtensions.js +5 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +7 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles/ignorePatternsBuiltIn.d.ts +1 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles/ignorePatternsBuiltIn.js +13 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +50 -64
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +2 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.js +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.d.ts +0 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +20 -8
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +8 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +279 -214
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/virtual-files/getVirtualFilePageConfigValuesAll.js +4 -4
- package/dist/esm/node/plugin/shared/findPageFiles.js +3 -3
- package/dist/esm/node/plugin/shared/getHttpRequestAsyncStore.js +1 -3
- package/dist/esm/node/plugin/shared/getOutDirs.d.ts +2 -2
- package/dist/esm/node/plugin/shared/getOutDirs.js +8 -7
- package/dist/esm/node/plugin/shared/isViteServerBuild.d.ts +15 -0
- package/dist/esm/node/plugin/shared/isViteServerBuild.js +45 -0
- package/dist/esm/node/plugin/shared/resolveClientEntriesDev.js +1 -1
- package/dist/esm/node/plugin/utils.d.ts +1 -0
- package/dist/esm/node/plugin/utils.js +1 -0
- package/dist/esm/node/prerender/context.d.ts +0 -2
- package/dist/esm/node/prerender/context.js +4 -9
- package/dist/esm/node/prerender/resolvePrerenderConfig.d.ts +10 -6
- package/dist/esm/node/prerender/resolvePrerenderConfig.js +24 -22
- package/dist/esm/node/prerender/runPrerender.d.ts +7 -25
- package/dist/esm/node/prerender/runPrerender.js +29 -29
- package/dist/esm/node/prerender/utils.d.ts +1 -0
- package/dist/esm/node/prerender/utils.js +1 -0
- package/dist/esm/node/runtime/globalContext.d.ts +2 -1
- package/dist/esm/node/runtime/renderPage/logErrorHint.js +7 -1
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +165 -5
- package/dist/esm/shared/getPageContextUrlComputed.js +1 -1
- package/dist/esm/shared/page-configs/Config.d.ts +12 -2
- package/dist/esm/shared/page-configs/PageConfig.d.ts +5 -5
- package/dist/esm/shared/page-configs/getConfigValueBuildTime.js +2 -5
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +3 -1
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +2 -0
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +20 -9
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/findFile.js +1 -1
- package/dist/esm/utils/findPackageJson.js +1 -1
- package/dist/esm/utils/isFilePathAbsoluteFilesystem.js +8 -2
- package/dist/esm/utils/path.js +1 -0
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/dist/esm/utils/requireResolve.js +11 -4
- package/dist/esm/utils/sorter.d.ts +18 -5
- package/dist/esm/utils/sorter.js +0 -3
- package/package.json +8 -16
- package/dist/cjs/node/plugin/plugins/autoFullBuild.js +0 -119
- package/dist/cjs/node/plugin/plugins/buildApp.js +0 -76
- package/dist/cjs/node/plugin/plugins/removeRequireHookPlugin.js +0 -17
- package/dist/cjs/node/plugin/shared/getFullBuildInlineConfig.js +0 -20
- package/dist/cjs/node/plugin/shared/viteIsSSR.js +0 -31
- package/dist/esm/node/plugin/plugins/autoFullBuild.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/autoFullBuild.js +0 -114
- package/dist/esm/node/plugin/plugins/buildApp.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/buildApp.js +0 -74
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.d.ts +0 -20
- package/dist/esm/node/plugin/plugins/buildEntry/index.d.ts +0 -8
- package/dist/esm/node/plugin/plugins/distFileNames.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/packageJsonFile.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/removeRequireHookPlugin.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/removeRequireHookPlugin.js +0 -15
- package/dist/esm/node/plugin/plugins/suppressRollupWarning.d.ts +0 -3
- package/dist/esm/node/plugin/shared/getFullBuildInlineConfig.d.ts +0 -2
- package/dist/esm/node/plugin/shared/getFullBuildInlineConfig.js +0 -17
- package/dist/esm/node/plugin/shared/viteIsSSR.d.ts +0 -11
- package/dist/esm/node/plugin/shared/viteIsSSR.js +0 -29
- package/dist-cjs-fixup.mjs +0 -41
|
@@ -6,7 +6,7 @@ import { extractAssetsAddQuery } from '../../../../../shared/extractAssetsQuery.
|
|
|
6
6
|
import { debug } from './debug.js';
|
|
7
7
|
import { isRuntimeEnvMatch } from './isRuntimeEnvMatch.js';
|
|
8
8
|
import { serializeConfigValues } from '../../../../../../shared/page-configs/serialize/serializeConfigValues.js';
|
|
9
|
-
import {
|
|
9
|
+
import { handleAssetsManifest_isFixEnabled } from '../../../build/handleAssetsManifest.js';
|
|
10
10
|
import { getConfigValueBuildTime } from '../../../../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
11
11
|
async function getVirtualFilePageConfigValuesAll(id, isDev, config) {
|
|
12
12
|
const result = isVirtualFileIdPageConfigValuesAll(id);
|
|
@@ -24,11 +24,11 @@ async function getVirtualFilePageConfigValuesAll(id, isDev, config) {
|
|
|
24
24
|
assert(pageConfig, { id, pageId });
|
|
25
25
|
const code = getLoadConfigValuesAll(pageConfig, isForClientSide, pageId,
|
|
26
26
|
// TODO/now: add meta.default
|
|
27
|
-
vikeConfig.global.config.includeAssetsImportedByServer ?? true, isDev);
|
|
27
|
+
vikeConfig.global.config.includeAssetsImportedByServer ?? true, config, isDev);
|
|
28
28
|
debug(id, isForClientSide ? 'CLIENT-SIDE' : 'SERVER-SIDE', code);
|
|
29
29
|
return code;
|
|
30
30
|
}
|
|
31
|
-
function getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, includeAssetsImportedByServer, isDev) {
|
|
31
|
+
function getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, includeAssetsImportedByServer, config, isDev) {
|
|
32
32
|
const lines = [];
|
|
33
33
|
const importStatements = [];
|
|
34
34
|
const filesEnv = new Map();
|
|
@@ -36,7 +36,7 @@ function getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, includeAsse
|
|
|
36
36
|
lines.push('export const configValuesSerialized = {');
|
|
37
37
|
lines.push(...serializeConfigValues(pageConfig, importStatements, filesEnv, (configEnv) => isRuntimeEnvMatch(configEnv, { isForClientSide, isClientRouting, isDev }), '', false));
|
|
38
38
|
lines.push('};');
|
|
39
|
-
if (!
|
|
39
|
+
if (!handleAssetsManifest_isFixEnabled(config) && includeAssetsImportedByServer && isForClientSide && !isDev) {
|
|
40
40
|
importStatements.push(`import '${extractAssetsAddQuery(getVirtualFileIdPageConfigValuesAll(pageId, false))}'`);
|
|
41
41
|
}
|
|
42
42
|
const code = [...importStatements, ...lines].join('\n');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { findPageFiles };
|
|
2
|
-
import glob from '
|
|
2
|
+
import { glob } from 'tinyglobby';
|
|
3
3
|
import { assertWarning, toPosixPath, scriptFileExtensions } from '../utils.js';
|
|
4
4
|
import pc from '@brillout/picocolors';
|
|
5
5
|
import { getOutDirs } from './getOutDirs.js';
|
|
@@ -7,11 +7,11 @@ async function findPageFiles(config, fileTypes, isDev) {
|
|
|
7
7
|
const cwd = config.root;
|
|
8
8
|
const { outDirRoot } = getOutDirs(config);
|
|
9
9
|
const timeBase = new Date().getTime();
|
|
10
|
-
let pageFiles = await glob(fileTypes.map((fileType) => `**/*${fileType}.${scriptFileExtensions}`), { ignore: ['**/node_modules/**', `${outDirRoot}/**`], cwd, dot: false });
|
|
10
|
+
let pageFiles = await glob(fileTypes.map((fileType) => `**/*${fileType}.${scriptFileExtensions}`), { ignore: ['**/node_modules/**', `${outDirRoot}/**`], cwd, dot: false, expandDirectories: false });
|
|
11
11
|
pageFiles = pageFiles.map((p) => '/' + toPosixPath(p));
|
|
12
12
|
const time = new Date().getTime() - timeBase;
|
|
13
13
|
if (isDev) {
|
|
14
|
-
// We only warn in dev, because while building it's expected to take a long time as
|
|
14
|
+
// We only warn in dev, because while building it's expected to take a long time as tinyglobby is competing for resources with other tasks
|
|
15
15
|
assertWarning(time < 1.5 * 1000, `Finding your page files ${pc.cyan('**/*.page.*')} took an unexpected long time (${time}ms). Reach out to the vike maintainer.`, {
|
|
16
16
|
onlyOnce: 'slow-page-files-search'
|
|
17
17
|
});
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
// Purpose of this file:
|
|
2
2
|
// - Swallow redundant error messages (Vite is buggy and emits the same error multiple times)
|
|
3
3
|
// - Prepend "[request(n)]" tag to Vite logs
|
|
4
|
-
// The mechanism is skipped if the
|
|
5
|
-
// - Bun doesn't support Async Hooks: https://github.com/oven-sh/bun/issues/1832
|
|
6
|
-
// - Node.js and Deno support Async Hooks
|
|
4
|
+
// The mechanism is skipped if the development environment doesn't support Async Hooks.
|
|
7
5
|
// We purposely don't use config.logger.hasErrorLogged(err) because:
|
|
8
6
|
// - We don't trust Vite with such details
|
|
9
7
|
// - Example of Vite bug leading to swallowing of errors: https://github.com/vitejs/vite/issues/12631
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { getOutDirs };
|
|
2
2
|
export { resolveOutDir };
|
|
3
3
|
export type { OutDirs };
|
|
4
|
-
import type { UserConfig, ResolvedConfig } from 'vite';
|
|
4
|
+
import type { UserConfig, ResolvedConfig, Environment } from 'vite';
|
|
5
5
|
type OutDirs = {
|
|
6
6
|
/** Absolute path to `outDir` */
|
|
7
7
|
outDirRoot: string;
|
|
@@ -10,6 +10,6 @@ type OutDirs = {
|
|
|
10
10
|
/** Absolute path to `${outDir}/server` */
|
|
11
11
|
outDirServer: string;
|
|
12
12
|
};
|
|
13
|
-
declare function getOutDirs(
|
|
13
|
+
declare function getOutDirs(configGlobal: ResolvedConfig, viteEnv?: Environment): OutDirs;
|
|
14
14
|
/** Appends `client/` or `server/` to `config.build.outDir` */
|
|
15
15
|
declare function resolveOutDir(config: UserConfig, isSSR?: true): string;
|
|
@@ -2,20 +2,21 @@ 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 { isViteServerBuild } from './isViteServerBuild.js';
|
|
6
6
|
const debug = createDebugger('vike:outDir');
|
|
7
|
-
function getOutDirs(
|
|
7
|
+
function getOutDirs(configGlobal, viteEnv) {
|
|
8
|
+
const configEnv = viteEnv?.config ?? configGlobal;
|
|
8
9
|
debug('getOutDirs()', new Error().stack);
|
|
9
|
-
const outDir = getOutDirFromViteResolvedConfig(
|
|
10
|
+
const outDir = getOutDirFromViteResolvedConfig(configEnv);
|
|
10
11
|
if (!isOutDirRoot(outDir))
|
|
11
|
-
assertOutDirResolved(outDir,
|
|
12
|
-
const outDirs = getOutDirsAll(outDir,
|
|
12
|
+
assertOutDirResolved(outDir, configEnv);
|
|
13
|
+
const outDirs = getOutDirsAll(outDir, configEnv.root);
|
|
13
14
|
return outDirs;
|
|
14
15
|
}
|
|
15
16
|
/** Appends `client/` or `server/` to `config.build.outDir` */
|
|
16
17
|
function resolveOutDir(config, isSSR) {
|
|
17
18
|
debug('resolveOutDir()', new Error().stack);
|
|
18
|
-
const isServerSide =
|
|
19
|
+
const isServerSide = isViteServerBuild(config) || isSSR;
|
|
19
20
|
debug('isServerSide', isServerSide);
|
|
20
21
|
const outDir = getOutDirFromViteUserConfig(config) || 'dist';
|
|
21
22
|
debug('outDir', outDir);
|
|
@@ -104,7 +105,7 @@ function assertOutDirResolved(outDir, config) {
|
|
|
104
105
|
assert('/client'.length === '/server'.length);
|
|
105
106
|
const outDirCorrected = outDir.slice(0, -1 * '/client'.length);
|
|
106
107
|
const wrongUsage = `You've set Vite's config.build.outDir to ${pc.cyan(outDir)} but you should set it to ${pc.cyan(outDirCorrected)} instead.`;
|
|
107
|
-
if (
|
|
108
|
+
if (isViteServerBuild(config)) {
|
|
108
109
|
assertUsage(outDir.endsWith('/server'), wrongUsage);
|
|
109
110
|
}
|
|
110
111
|
else {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { isViteServerBuild };
|
|
2
|
+
export { isViteClientBuild };
|
|
3
|
+
export { isViteServerBuild_options };
|
|
4
|
+
export { isViteServerBuild_safe };
|
|
5
|
+
export { isViteServerBuild_onlySsrEnv };
|
|
6
|
+
import type { Environment, ResolvedConfig, UserConfig } from 'vite';
|
|
7
|
+
declare function isViteServerBuild(configGlobal: ResolvedConfig | UserConfig, viteEnv?: Environment): boolean;
|
|
8
|
+
declare function isViteServerBuild_onlySsrEnv(configGlobal: ResolvedConfig, viteEnv: Environment | undefined): boolean;
|
|
9
|
+
declare function isViteClientBuild(configGlobal: ResolvedConfig, viteEnv: Environment): boolean;
|
|
10
|
+
declare function isViteServerBuild_options(options: {
|
|
11
|
+
ssr?: boolean;
|
|
12
|
+
} | undefined): boolean;
|
|
13
|
+
declare function isViteServerBuild_safe(config: ResolvedConfig, options: {
|
|
14
|
+
ssr?: boolean;
|
|
15
|
+
} | undefined): boolean;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export { isViteServerBuild };
|
|
2
|
+
export { isViteClientBuild };
|
|
3
|
+
export { isViteServerBuild_options };
|
|
4
|
+
export { isViteServerBuild_safe };
|
|
5
|
+
export { isViteServerBuild_onlySsrEnv };
|
|
6
|
+
import { assert } from '../../../utils/assert.js';
|
|
7
|
+
function isViteServerBuild(configGlobal, viteEnv) {
|
|
8
|
+
const configEnv = viteEnv?.config ?? configGlobal;
|
|
9
|
+
return !!configEnv?.build?.ssr;
|
|
10
|
+
}
|
|
11
|
+
// Only `ssr` env: for example don't include `vercel_edge` nor `vercel_node`.
|
|
12
|
+
function isViteServerBuild_onlySsrEnv(configGlobal, viteEnv) {
|
|
13
|
+
return viteEnv ? viteEnv.name === 'ssr' : isViteServerBuild(configGlobal);
|
|
14
|
+
}
|
|
15
|
+
function isViteClientBuild(configGlobal, viteEnv) {
|
|
16
|
+
const yes = !isViteServerBuild(configGlobal, viteEnv);
|
|
17
|
+
const isVite5 = viteEnv === undefined;
|
|
18
|
+
if (!isVite5) {
|
|
19
|
+
const yes2 = viteEnv.name === 'client';
|
|
20
|
+
assert(yes === yes2);
|
|
21
|
+
}
|
|
22
|
+
return yes;
|
|
23
|
+
}
|
|
24
|
+
function isViteServerBuild_options(options) {
|
|
25
|
+
return !!options?.ssr;
|
|
26
|
+
}
|
|
27
|
+
// Vite is quite messy about setting `ssr: boolean`, thus we use an extra safe implemention for security purposes.
|
|
28
|
+
// It's used for .client.js and .server.js guarantee thus we use agressive assert() calls for added safety.
|
|
29
|
+
function isViteServerBuild_safe(config, options) {
|
|
30
|
+
if (config.command === 'build') {
|
|
31
|
+
assert(typeof config.build.ssr === 'boolean');
|
|
32
|
+
const val = config.build.ssr;
|
|
33
|
+
if (options?.ssr !== undefined)
|
|
34
|
+
assert(val === options.ssr);
|
|
35
|
+
return val;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
assert(typeof options?.ssr === 'boolean');
|
|
39
|
+
const val = options.ssr;
|
|
40
|
+
/* This assert() fails (which is very unexpected).
|
|
41
|
+
if (typeof config.build.ssr === 'boolean') assert(val === config.build.ssr)
|
|
42
|
+
//*/
|
|
43
|
+
return val;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { resolveClientEntriesDev };
|
|
2
2
|
import { assert, assertPosixPath, toPosixPath, pathJoin, assertIsNpmPackageImport, assertIsNotProductionRuntime } from '../utils.js';
|
|
3
3
|
import { createRequire } from 'module';
|
|
4
|
-
// @ts-ignore
|
|
4
|
+
// @ts-ignore import.meta.url is shimmed at dist/cjs by dist-cjs-fixup.js.
|
|
5
5
|
const importMetaUrl = import.meta.url;
|
|
6
6
|
const require_ = createRequire(importMetaUrl);
|
|
7
7
|
assertIsNotProductionRuntime();
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
export { isPrerenderEnabled };
|
|
2
1
|
export { isPrerenderAutoRunEnabled };
|
|
3
2
|
export { temp_disablePrerenderAutoRun };
|
|
4
3
|
export { isPrerendering };
|
|
5
4
|
export { setContextIsPrerendering };
|
|
6
5
|
import type { VikeConfigObject } from '../plugin/plugins/importUserCode/v1-design/getVikeConfig.js';
|
|
7
|
-
declare function isPrerenderEnabled(vikeConfig: VikeConfigObject): boolean;
|
|
8
6
|
declare function isPrerenderAutoRunEnabled(vikeConfig: VikeConfigObject): boolean;
|
|
9
7
|
declare function temp_disablePrerenderAutoRun(): void;
|
|
10
8
|
declare function isPrerendering(): boolean;
|
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
export { isPrerenderEnabled };
|
|
2
1
|
export { isPrerenderAutoRunEnabled };
|
|
3
2
|
export { temp_disablePrerenderAutoRun };
|
|
4
3
|
export { isPrerendering };
|
|
5
4
|
export { setContextIsPrerendering };
|
|
6
5
|
import { getGlobalObject } from '../../utils/getGlobalObject.js';
|
|
7
|
-
import {
|
|
6
|
+
import { resolvePrerenderConfigGlobal } from './resolvePrerenderConfig.js';
|
|
8
7
|
const globalObject = getGlobalObject('prerender/context.ts', {});
|
|
9
|
-
function isPrerenderEnabled(vikeConfig) {
|
|
10
|
-
const prerenderConfig = resolvePrerenderConfig(vikeConfig);
|
|
11
|
-
return !!prerenderConfig;
|
|
12
|
-
}
|
|
13
8
|
function isPrerenderAutoRunEnabled(vikeConfig) {
|
|
14
|
-
const
|
|
15
|
-
return (
|
|
16
|
-
!(
|
|
9
|
+
const prerenderConfigGlobal = resolvePrerenderConfigGlobal(vikeConfig);
|
|
10
|
+
return (prerenderConfigGlobal.isEnabled &&
|
|
11
|
+
!(prerenderConfigGlobal || {}).disableAutoRun &&
|
|
17
12
|
!globalObject.isDisabled &&
|
|
18
13
|
vikeConfig.global.config.disableAutoFullBuild !== 'prerender');
|
|
19
14
|
}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { resolvePrerenderConfigGlobal };
|
|
2
2
|
export { resolvePrerenderConfigLocal };
|
|
3
|
-
import type { ConfigResolved } from '../../shared/page-configs/Config/PageContextConfig.js';
|
|
4
3
|
import { VikeConfigObject } from '../plugin/plugins/importUserCode/v1-design/getVikeConfig.js';
|
|
5
4
|
import type { PageConfigBuildTime } from '../../shared/page-configs/PageConfig.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
declare function resolvePrerenderConfigGlobal(vikeConfig: VikeConfigObject): {
|
|
6
|
+
partial: boolean;
|
|
7
|
+
noExtraDir: boolean;
|
|
8
|
+
parallel: number | boolean;
|
|
9
|
+
disableAutoRun: boolean;
|
|
10
|
+
} & {
|
|
11
|
+
defaultLocalValue: boolean;
|
|
12
|
+
isEnabled: boolean;
|
|
13
|
+
};
|
|
9
14
|
declare function resolvePrerenderConfigLocal(pageConfig: PageConfigBuildTime): {
|
|
10
15
|
value: boolean;
|
|
11
|
-
configValueFilePathToShowToUser: string;
|
|
12
16
|
} | null;
|
|
@@ -1,27 +1,30 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { resolvePrerenderConfigGlobal };
|
|
2
2
|
export { resolvePrerenderConfigLocal };
|
|
3
|
-
import { assert, isArray } from './utils.js';
|
|
3
|
+
import { assert, isArray, objectAssign } from './utils.js';
|
|
4
4
|
import { getConfigValueBuildTime } from '../../shared/page-configs/getConfigValueBuildTime.js';
|
|
5
|
-
|
|
6
|
-
// TODO/now:
|
|
7
|
-
// - prerender.value
|
|
8
|
-
function resolvePrerenderConfig(vikeConfig) {
|
|
5
|
+
function resolvePrerenderConfigGlobal(vikeConfig) {
|
|
9
6
|
const prerenderConfigs = vikeConfig.global.config.prerender;
|
|
10
|
-
|
|
11
|
-
!vikeConfig.pageConfigs.some((pageConfig) => resolvePrerenderConfigLocal(pageConfig)?.value)) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
let prerenderSettings = prerenderConfigs || [];
|
|
7
|
+
let prerenderConfigList = prerenderConfigs || [];
|
|
15
8
|
// Needed because of backwards compatibility of `vike({prerender:true})` in `vite.config.js`; after we remove it we can remove this line.
|
|
16
|
-
|
|
17
|
-
assert(
|
|
18
|
-
const
|
|
19
|
-
partial: pickFirst(
|
|
20
|
-
noExtraDir: pickFirst(
|
|
21
|
-
parallel: pickFirst(
|
|
22
|
-
disableAutoRun: pickFirst(
|
|
9
|
+
prerenderConfigList = prerenderConfigList.filter(isObject2);
|
|
10
|
+
assert(prerenderConfigList.every(isObject2)); // Help TS
|
|
11
|
+
const prerenderConfigGlobal = {
|
|
12
|
+
partial: pickFirst(prerenderConfigList.map((c) => c.partial)) ?? false,
|
|
13
|
+
noExtraDir: pickFirst(prerenderConfigList.map((c) => c.noExtraDir)) ?? false,
|
|
14
|
+
parallel: pickFirst(prerenderConfigList.map((c) => c.parallel)) ?? true,
|
|
15
|
+
disableAutoRun: pickFirst(prerenderConfigList.map((c) => c.disableAutoRun)) ?? false
|
|
23
16
|
};
|
|
24
|
-
|
|
17
|
+
const prerenderConfigGlobalLocalValue = prerenderConfigList.map((c) => c.value).filter((v) => v !== null);
|
|
18
|
+
const defaultLocalValue = pickFirst(prerenderConfigGlobalLocalValue) ??
|
|
19
|
+
(prerenderConfigGlobalLocalValue.length > 0 ||
|
|
20
|
+
// Backwards compatibility for with vike({ prerender: true }) in vite.config.js
|
|
21
|
+
prerenderConfigs?.some((p) => p === true) ||
|
|
22
|
+
false);
|
|
23
|
+
objectAssign(prerenderConfigGlobal, {
|
|
24
|
+
defaultLocalValue,
|
|
25
|
+
isEnabled: defaultLocalValue || vikeConfig.pageConfigs.some((pageConfig) => resolvePrerenderConfigLocal(pageConfig)?.value)
|
|
26
|
+
});
|
|
27
|
+
return prerenderConfigGlobal;
|
|
25
28
|
}
|
|
26
29
|
function resolvePrerenderConfigLocal(pageConfig) {
|
|
27
30
|
const configValue = getConfigValueBuildTime(pageConfig, 'prerender');
|
|
@@ -32,9 +35,8 @@ function resolvePrerenderConfigLocal(pageConfig) {
|
|
|
32
35
|
const value = values[0];
|
|
33
36
|
assert(typeof value === 'boolean');
|
|
34
37
|
assert(isArray(configValue.definedAtData));
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
return { value, configValueFilePathToShowToUser };
|
|
38
|
+
const prerenderConfigLocal = { value };
|
|
39
|
+
return prerenderConfigLocal;
|
|
38
40
|
}
|
|
39
41
|
function isObject2(p) {
|
|
40
42
|
return typeof p === 'object' && p !== null;
|
|
@@ -4,46 +4,24 @@ export { runPrerenderFromAutoRun };
|
|
|
4
4
|
export { runPrerender_forceExit };
|
|
5
5
|
export type { PrerenderOptions };
|
|
6
6
|
export type { PrerenderContextPublic };
|
|
7
|
-
import { PageContextInitEnhanced } from '../runtime/renderPage/renderPageAlreadyRouted.js';
|
|
8
7
|
import type { InlineConfig, ResolvedConfig } from 'vite';
|
|
9
|
-
import { PageContextUrlInternal } from '../../shared/getPageContextUrlComputed.js';
|
|
10
8
|
import type { APIOptions } from '../api/types.js';
|
|
9
|
+
import type { PageContextServer } from '../../shared/types.js';
|
|
11
10
|
type ProvidedByHook = null | {
|
|
12
11
|
hookFilePath: string;
|
|
13
12
|
hookName: 'onBeforePrerenderStart' | 'prerender';
|
|
14
13
|
};
|
|
15
|
-
type TransformerHook = {
|
|
16
|
-
hookFilePath: string;
|
|
17
|
-
hookName: 'onPrerenderStart' | 'onBeforePrerender';
|
|
18
|
-
};
|
|
19
14
|
type PageContextPrerendered = {
|
|
20
15
|
urlOriginal: string;
|
|
21
16
|
_providedByHook?: ProvidedByHook;
|
|
22
17
|
};
|
|
23
|
-
type
|
|
24
|
-
type PrerenderContext = {
|
|
25
|
-
pageContexts: PageContext[];
|
|
26
|
-
pageContextInit: Record<string, unknown> | null;
|
|
27
|
-
noExtraDir: boolean;
|
|
28
|
-
prerenderedPageContexts: PrerenderedPageContexts;
|
|
29
|
-
output: Output;
|
|
30
|
-
};
|
|
31
|
-
type Output = {
|
|
18
|
+
type Output<PageContext = PageContextPrerendered> = {
|
|
32
19
|
filePath: string;
|
|
33
20
|
fileType: FileType;
|
|
34
21
|
fileContent: string;
|
|
35
|
-
pageContext:
|
|
22
|
+
pageContext: PageContext;
|
|
36
23
|
}[];
|
|
37
24
|
type FileType = 'HTML' | 'JSON';
|
|
38
|
-
type PrerenderContextPublic = Pick<PrerenderContext, 'pageContexts'>;
|
|
39
|
-
type PageContext = PageContextInitEnhanced & {
|
|
40
|
-
_urlRewrite: null;
|
|
41
|
-
_urlHandler: null;
|
|
42
|
-
_urlOriginalBeforeHook?: string;
|
|
43
|
-
_urlOriginalModifiedByHook?: TransformerHook;
|
|
44
|
-
_providedByHook: ProvidedByHook;
|
|
45
|
-
_pageContextAlreadyProvidedByOnPrerenderHook?: true;
|
|
46
|
-
} & PageContextUrlInternal;
|
|
47
25
|
type PrerenderOptions = APIOptions & {
|
|
48
26
|
/** Initial `pageContext` values */
|
|
49
27
|
pageContextInit?: Record<string, unknown>;
|
|
@@ -72,3 +50,7 @@ declare function runPrerenderFromAutoRun(viteConfig: InlineConfig | undefined, c
|
|
|
72
50
|
forceExit: boolean;
|
|
73
51
|
}>;
|
|
74
52
|
declare function runPrerender_forceExit(): void;
|
|
53
|
+
type PrerenderContextPublic = {
|
|
54
|
+
output: Output<PageContextServer>;
|
|
55
|
+
pageContexts: PageContextServer[];
|
|
56
|
+
};
|
|
@@ -26,10 +26,11 @@ import { logErrorHint } from '../runtime/renderPage/logErrorHint.js';
|
|
|
26
26
|
import { executeHook, isUserHookError } from '../../shared/hooks/executeHook.js';
|
|
27
27
|
import { prepareViteApiCall } from '../api/prepareViteApiCall.js';
|
|
28
28
|
import { setContextIsPrerendering } from './context.js';
|
|
29
|
-
import {
|
|
29
|
+
import { resolvePrerenderConfigGlobal, resolvePrerenderConfigLocal } from './resolvePrerenderConfig.js';
|
|
30
30
|
import { getOutDirs } from '../plugin/shared/getOutDirs.js';
|
|
31
31
|
import { isVikeCli } from '../cli/context.js';
|
|
32
32
|
import { isViteCliCall } from '../plugin/shared/isViteCliCall.js';
|
|
33
|
+
import { getVikeConfigPublic } from '../plugin/plugins/commonConfig.js';
|
|
33
34
|
async function runPrerenderFromAPI(options = {}) {
|
|
34
35
|
return await runPrerender(options, 'prerender()');
|
|
35
36
|
// - We purposely propagate the error to the user land, so that the error interrupts the user land. It's also, I guess, a nice-to-have that the user has control over the error.
|
|
@@ -56,11 +57,13 @@ async function runPrerenderFromAutoRun(viteConfig, config) {
|
|
|
56
57
|
prerenderContextPublic = ret.prerenderContextPublic;
|
|
57
58
|
}
|
|
58
59
|
catch (err) {
|
|
60
|
+
// Avoid Rollup prefixing the error with [vike:build:pluginAutoFullBuild], see for example https://github.com/vikejs/vike/issues/472#issuecomment-1276274203
|
|
59
61
|
console.error(err);
|
|
60
62
|
logErrorHint(err);
|
|
61
63
|
process.exit(1);
|
|
62
64
|
}
|
|
63
|
-
|
|
65
|
+
const vike = getVikeConfigPublic(config);
|
|
66
|
+
vike.prerenderContext = prerenderContextPublic;
|
|
64
67
|
const forceExit = isVikeCli() || isViteCliCall();
|
|
65
68
|
return { forceExit };
|
|
66
69
|
}
|
|
@@ -79,15 +82,16 @@ async function runPrerender(options = {}, standaloneTrigger) {
|
|
|
79
82
|
const vikeConfig = await getVikeConfig(viteConfig);
|
|
80
83
|
const { outDirClient } = getOutDirs(viteConfig);
|
|
81
84
|
const { root } = viteConfig;
|
|
82
|
-
const
|
|
83
|
-
validatePrerenderConfig(
|
|
84
|
-
|
|
85
|
+
const prerenderConfigGlobal = resolvePrerenderConfigGlobal(vikeConfig);
|
|
86
|
+
validatePrerenderConfig(prerenderConfigGlobal);
|
|
87
|
+
const { partial, noExtraDir, parallel, defaultLocalValue, isEnabled } = prerenderConfigGlobal;
|
|
88
|
+
if (!isEnabled) {
|
|
85
89
|
assert(standaloneTrigger);
|
|
86
|
-
|
|
90
|
+
// TODO/now: make it assertUsage() and remove dist/server/entry.mjs whenever possible
|
|
91
|
+
assertWarning(prerenderConfigGlobal, `You're executing ${pc.cyan(standaloneTrigger)} but you didn't enable pre-rendering. Use the config ${pc.cyan('prerender')} (${pc.underline('https://vike.dev/prerender')}) to enable it.`, {
|
|
87
92
|
onlyOnce: true
|
|
88
93
|
});
|
|
89
94
|
}
|
|
90
|
-
const { partial = false, noExtraDir = false, parallel = true } = prerenderConfig || {};
|
|
91
95
|
const concurrencyLimit = pLimit(parallel === false || parallel === 0 ? 1 : parallel === true || parallel === undefined ? cpus().length : parallel);
|
|
92
96
|
await initGlobalContext_runPrerender();
|
|
93
97
|
const globalContext = await getGlobalContextInternal();
|
|
@@ -100,7 +104,7 @@ async function runPrerender(options = {}, standaloneTrigger) {
|
|
|
100
104
|
output: []
|
|
101
105
|
};
|
|
102
106
|
const doNotPrerenderList = [];
|
|
103
|
-
await collectDoNoPrerenderList(vikeConfig.pageConfigs, doNotPrerenderList, concurrencyLimit, globalContext);
|
|
107
|
+
await collectDoNoPrerenderList(vikeConfig.pageConfigs, doNotPrerenderList, defaultLocalValue, concurrencyLimit, globalContext);
|
|
104
108
|
await callOnBeforePrerenderStartHooks(prerenderContext, globalContext, concurrencyLimit, doNotPrerenderList);
|
|
105
109
|
await handlePagesWithStaticRoutes(prerenderContext, globalContext, doNotPrerenderList, concurrencyLimit);
|
|
106
110
|
await callOnPrerenderStartHook(prerenderContext, globalContext);
|
|
@@ -123,20 +127,21 @@ async function runPrerender(options = {}, standaloneTrigger) {
|
|
|
123
127
|
const prerenderContextPublic = makePublic(prerenderContext);
|
|
124
128
|
return { viteConfig, prerenderContextPublic };
|
|
125
129
|
}
|
|
126
|
-
async function collectDoNoPrerenderList(pageConfigs, doNotPrerenderList, concurrencyLimit, globalContext) {
|
|
130
|
+
async function collectDoNoPrerenderList(pageConfigs, doNotPrerenderList, defaultLocalValue, concurrencyLimit, globalContext) {
|
|
127
131
|
// V1 design
|
|
128
132
|
pageConfigs.forEach((pageConfig) => {
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
133
|
+
const prerenderConfigLocal = resolvePrerenderConfigLocal(pageConfig);
|
|
134
|
+
const { pageId } = pageConfig;
|
|
135
|
+
if (!prerenderConfigLocal) {
|
|
136
|
+
if (!defaultLocalValue) {
|
|
137
|
+
doNotPrerenderList.push({ pageId });
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
const { value } = prerenderConfigLocal;
|
|
142
|
+
if (value === false) {
|
|
143
|
+
doNotPrerenderList.push({ pageId });
|
|
144
|
+
}
|
|
140
145
|
}
|
|
141
146
|
});
|
|
142
147
|
// Old design
|
|
@@ -169,12 +174,7 @@ async function collectDoNoPrerenderList(pageConfigs, doNotPrerenderList, concurr
|
|
|
169
174
|
}
|
|
170
175
|
else {
|
|
171
176
|
// Don't pre-render `pageId`
|
|
172
|
-
doNotPrerenderList.push({
|
|
173
|
-
pageId,
|
|
174
|
-
setByConfigFile: p.filePath,
|
|
175
|
-
setByConfigName: 'doNotPrerender',
|
|
176
|
-
setByConfigValue: doNotPrerender
|
|
177
|
-
});
|
|
177
|
+
doNotPrerenderList.push({ pageId });
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
});
|
|
@@ -527,8 +527,7 @@ function warnContradictoryNoPrerenderList(prerenderedPageContexts, doNotPrerende
|
|
|
527
527
|
if (!isContradictory)
|
|
528
528
|
return;
|
|
529
529
|
}
|
|
530
|
-
|
|
531
|
-
assertWarning(false, `The ${providedByHook.hookName}() hook defined by ${providedByHook.hookFilePath} returns the URL ${pc.cyan(urlOriginal)}, while ${setByConfigFile} sets the config ${pc.cyan(setByConfigName)} to ${pc.cyan(String(setByConfigValue))}. This is contradictory: either don't set the config ${pc.cyan(setByConfigName)} to ${pc.cyan(String(setByConfigValue))} or remove the URL ${pc.cyan(urlOriginal)} from the list of URLs to be pre-rendered.`, { onlyOnce: true });
|
|
530
|
+
assertWarning(false, `The ${providedByHook.hookName}() hook defined by ${providedByHook.hookFilePath} returns the URL ${pc.cyan(urlOriginal)} matching the route of the page ${pc.cyan(pageId)} which isn't configured to be pre-rendered. This is contradictory: either enable pre-rendering for ${pc.cyan(pageId)} or remove the URL ${pc.cyan(urlOriginal)} from the list of URLs to be pre-rendered.`, { onlyOnce: true });
|
|
532
531
|
});
|
|
533
532
|
}
|
|
534
533
|
async function warnMissingPages(prerenderedPageContexts, globalContext, doNotPrerenderList, partial) {
|
|
@@ -775,7 +774,8 @@ prerenderConfig) {
|
|
|
775
774
|
}
|
|
776
775
|
function makePublic(prerenderContext) {
|
|
777
776
|
const prerenderContextPublic = makePublicCopy(prerenderContext, 'prerenderContext', [
|
|
778
|
-
'
|
|
777
|
+
'output', // vite-plugin-vercel
|
|
778
|
+
'pageContexts' // https://vike.dev/i18n#pre-rendering
|
|
779
779
|
]);
|
|
780
780
|
return prerenderContextPublic;
|
|
781
781
|
}
|
|
@@ -23,7 +23,6 @@ import type { ResolvedConfig, ViteDevServer } from 'vite';
|
|
|
23
23
|
import type { PageConfigUserFriendly, PageConfigsUserFriendly } from '../../shared/page-configs/getPageConfigUserFriendly.js';
|
|
24
24
|
import type { ConfigVitePluginServerEntry } from '@brillout/vite-plugin-server-entry/plugin';
|
|
25
25
|
import { type BaseUrlsResolved } from '../shared/resolveBase.js';
|
|
26
|
-
type GlobalContextPublic = Pick<GlobalContext, 'assetsManifest' | 'config' | 'viteConfig' | 'pages' | 'baseAssets' | 'baseServer'>;
|
|
27
26
|
type PageRuntimeInfo = Awaited<ReturnType<typeof getUserFiles>>;
|
|
28
27
|
type GlobalContextInternal = GlobalContext & {
|
|
29
28
|
globalContext_public: GlobalContextPublic;
|
|
@@ -57,6 +56,8 @@ declare function getGlobalContextInternal(): Promise<GlobalContextInternal>;
|
|
|
57
56
|
declare function getGlobalContextSync(): GlobalContextPublic;
|
|
58
57
|
/** @experimental https://vike.dev/getGlobalContext */
|
|
59
58
|
declare function getGlobalContextAsync(isProduction: boolean): Promise<GlobalContextPublic>;
|
|
59
|
+
type GlobalContextPublic = ReturnType<typeof makePublic>;
|
|
60
|
+
declare function makePublic(globalContext: GlobalContext): Pick<GlobalContext, "pages" | "baseServer" | "baseAssets" | "config" | "assetsManifest" | "viteConfig">;
|
|
60
61
|
declare function setGlobalContext_viteDevServer(viteDevServer: ViteDevServer): Promise<void>;
|
|
61
62
|
declare function setGlobalContext_viteConfig(viteConfig: ResolvedConfig, outDirRoot: string): void;
|
|
62
63
|
declare function setGlobalContext_isPrerendering(): void;
|
|
@@ -25,13 +25,19 @@ const errorsMisc = [
|
|
|
25
25
|
mustMentionNodeModules: false
|
|
26
26
|
}
|
|
27
27
|
];
|
|
28
|
+
const reactInvalidEelement = 'https://vike.dev/broken-npm-package#react-invalid-component';
|
|
28
29
|
const errorsReact = [
|
|
29
30
|
{
|
|
30
31
|
errMsg: 'Element type is invalid: expected a string (for built-in components) or a class/function (for composite components)',
|
|
31
|
-
link:
|
|
32
|
+
link: reactInvalidEelement,
|
|
32
33
|
// The stack trace can be user-land while the import is coming from node_modules
|
|
33
34
|
mustMentionNodeModules: false
|
|
34
35
|
},
|
|
36
|
+
{
|
|
37
|
+
errMsg: 'Objects are not valid as a React child',
|
|
38
|
+
link: reactInvalidEelement,
|
|
39
|
+
mustMentionNodeModules: false
|
|
40
|
+
},
|
|
35
41
|
{
|
|
36
42
|
// React's "Invalid hook call.", see https://github.com/vikejs/vike/discussions/1637#discussioncomment-9424712
|
|
37
43
|
errMsg: "Cannot read properties of null (reading 'useContext')"
|