vike 0.4.217 → 0.4.218-commit-01a099d
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/__internal/index.js +9 -8
- package/dist/cjs/node/api/build.js +20 -11
- package/dist/cjs/node/api/index.js +17 -7
- package/dist/cjs/node/api/prepareViteApiCall.js +109 -26
- package/dist/cjs/node/api/utils.js +2 -0
- package/dist/cjs/node/cli/entry.js +17 -7
- package/dist/cjs/node/plugin/index.js +6 -5
- package/dist/cjs/node/plugin/plugins/autoFullBuild.js +2 -3
- package/dist/cjs/node/plugin/plugins/baseUrls.js +20 -18
- package/dist/cjs/node/plugin/plugins/buildConfig.js +2 -2
- package/dist/cjs/node/plugin/plugins/{importBuild → buildEntry}/index.js +16 -17
- package/dist/cjs/node/plugin/plugins/commonConfig.js +6 -6
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +1 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +22 -111
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +188 -13
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +2 -1
- package/dist/cjs/node/plugin/plugins/setGlobalContext.js +1 -1
- package/dist/cjs/node/plugin/plugins/{vite6HmrRegressionWorkaround.js → workaroundVite6HmrRegression.js} +3 -3
- package/dist/cjs/node/plugin/shared/getHttpRequestAsyncStore.js +17 -7
- package/dist/cjs/node/prerender/isPrerenderEnabled.js +8 -0
- package/dist/cjs/node/prerender/runPrerender.js +21 -12
- package/dist/cjs/node/runtime/globalContext.js +44 -21
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +2 -2
- package/dist/cjs/node/runtime/index-common.js +0 -15
- package/dist/cjs/node/runtime/onLoad.js +17 -3
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +2 -2
- package/dist/cjs/node/runtime/renderPage/createHttpResponse/getCacheControl.js +2 -2
- package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +1 -1
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -3
- package/dist/cjs/node/runtime-dev/index.js +17 -7
- package/dist/cjs/node/shared/resolveBase.js +2 -2
- package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +3 -3
- package/dist/cjs/shared/getPageFiles/{setPageFiles.js → getPageFiles.js} +2 -3
- package/dist/cjs/shared/getPageFiles.js +3 -9
- package/dist/cjs/shared/hooks/getHook.js +3 -3
- package/dist/cjs/shared/{getPageFiles/getExports.js → page-configs/getPageConfigUserFriendly.js} +113 -81
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +79 -54
- package/dist/cjs/shared/route/loadPageRoutes.js +3 -3
- package/dist/cjs/shared/utils.js +1 -0
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assert.js +4 -3
- package/dist/esm/__internal/index.d.ts +3 -5
- package/dist/esm/__internal/index.js +4 -5
- package/dist/esm/client/client-routing-runtime/createPageContext.js +7 -1
- package/dist/esm/client/client-routing-runtime/entry.d.ts +1 -1
- package/dist/esm/client/client-routing-runtime/entry.js +0 -1
- package/dist/esm/client/client-routing-runtime/getPageContextCurrent.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.d.ts +4 -4
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +1 -1
- package/dist/esm/client/client-routing-runtime/prefetch/getPrefetchSettings.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/prefetch.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/prefetch.js +2 -2
- package/dist/esm/client/server-routing-runtime/entry.d.ts +1 -1
- package/dist/esm/client/server-routing-runtime/entry.js +0 -1
- package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +1 -1
- package/dist/esm/client/server-routing-runtime/getPageContext.js +8 -2
- package/dist/esm/client/shared/executeOnRenderClientHook.d.ts +2 -2
- package/dist/esm/client/shared/loadUserFilesClientSide.d.ts +2 -2
- package/dist/esm/client/shared/loadUserFilesClientSide.js +2 -2
- package/dist/esm/client/shared/preparePageContextForUserConsumptionClientSide.d.ts +2 -2
- package/dist/esm/node/api/build.js +3 -4
- package/dist/esm/node/api/prepareViteApiCall.d.ts +9 -3
- package/dist/esm/node/api/prepareViteApiCall.js +91 -21
- package/dist/esm/node/api/utils.d.ts +2 -0
- package/dist/esm/node/api/utils.js +2 -0
- package/dist/esm/node/cli/parseCli.d.ts +1 -1
- package/dist/esm/node/plugin/index.d.ts +1 -1
- package/dist/esm/node/plugin/index.js +6 -5
- package/dist/esm/node/plugin/plugins/autoFullBuild.js +2 -3
- package/dist/esm/node/plugin/plugins/baseUrls.d.ts +1 -2
- package/dist/esm/node/plugin/plugins/baseUrls.js +21 -19
- package/dist/esm/node/plugin/plugins/buildConfig.js +2 -2
- package/dist/esm/node/plugin/plugins/{importBuild → buildEntry}/getVikeManifest.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/{importBuild → buildEntry}/index.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/{importBuild → buildEntry}/index.js +16 -17
- package/dist/esm/node/plugin/plugins/commonConfig.d.ts +7 -1
- package/dist/esm/node/plugin/plugins/commonConfig.js +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +1 -3
- 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 +23 -112
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +99 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +188 -13
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +2 -1
- package/dist/esm/node/plugin/plugins/setGlobalContext.js +1 -1
- package/dist/esm/node/plugin/plugins/workaroundVite6HmrRegression.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/{vite6HmrRegressionWorkaround.js → workaroundVite6HmrRegression.js} +3 -3
- package/dist/esm/node/plugin/shared/getEnvVarObject.d.ts +1 -1
- package/dist/esm/node/prerender/isPrerenderEnabled.d.ts +3 -0
- package/dist/esm/node/prerender/isPrerenderEnabled.js +6 -0
- package/dist/esm/node/prerender/runPrerender.d.ts +1 -2
- package/dist/esm/node/prerender/runPrerender.js +3 -4
- package/dist/esm/node/runtime/globalContext.d.ts +4 -4
- package/dist/esm/node/runtime/globalContext.js +44 -21
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +1 -1
- package/dist/esm/node/runtime/index-common.d.ts +0 -1
- package/dist/esm/node/runtime/index-common.js +0 -15
- package/dist/esm/node/runtime/index-deprecated.d.ts +1 -0
- package/dist/esm/node/runtime/onLoad.js +16 -2
- package/dist/esm/node/runtime/renderPage/analyzePage.js +1 -1
- package/dist/esm/node/runtime/renderPage/createHttpResponse/getCacheControl.js +1 -1
- package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +2 -2
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +5 -5
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -3
- package/dist/esm/node/shared/resolveBase.js +2 -2
- package/dist/esm/shared/getPageFiles/analyzeClientSide.js +1 -1
- package/dist/esm/shared/getPageFiles/{setPageFiles.js → getPageFiles.js} +2 -3
- package/dist/esm/shared/getPageFiles.d.ts +2 -5
- package/dist/esm/shared/getPageFiles.js +1 -4
- package/dist/esm/shared/hooks/getHook.d.ts +3 -3
- package/dist/esm/shared/hooks/getHook.js +1 -1
- package/dist/esm/shared/page-configs/Config.d.ts +1 -1
- package/dist/esm/shared/page-configs/PageConfig.d.ts +7 -3
- package/dist/esm/shared/{getPageFiles/getExports.d.ts → page-configs/getPageConfigUserFriendly.d.ts} +23 -12
- package/dist/esm/shared/{getPageFiles/getExports.js → page-configs/getPageConfigUserFriendly.js} +112 -80
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +28 -4
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +79 -54
- package/dist/esm/shared/route/executeGuardHook.d.ts +2 -2
- package/dist/esm/shared/route/loadPageRoutes.js +1 -1
- package/dist/esm/shared/types.d.ts +1 -1
- package/dist/esm/shared/utils.d.ts +1 -0
- package/dist/esm/shared/utils.js +1 -0
- package/dist/esm/types/index.d.ts +1 -1
- 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 +4 -3
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +2 -21
- package/__internal/loadImportBuild.js +0 -3
- package/__internal/setup.js +0 -3
- package/dist/cjs/node/plugin/plugins/commonConfig/pluginName.js +0 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveVikeConfigGlobal.js +0 -128
- package/dist/cjs/node/runtime/globalContext/loadImportBuild.js +0 -25
- package/dist/cjs/node/runtime/page-files/getPageFilesExports.js +0 -22
- package/dist/cjs/node/runtime/page-files/setup.js +0 -5
- package/dist/esm/client/client-routing-runtime/pageFiles.d.ts +0 -1
- package/dist/esm/client/client-routing-runtime/pageFiles.js +0 -4
- package/dist/esm/client/server-routing-runtime/pageFiles.d.ts +0 -1
- package/dist/esm/client/server-routing-runtime/pageFiles.js +0 -4
- package/dist/esm/node/plugin/plugins/commonConfig/pluginName.d.ts +0 -1
- package/dist/esm/node/plugin/plugins/commonConfig/pluginName.js +0 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveVikeConfigGlobal.d.ts +0 -104
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveVikeConfigGlobal.js +0 -123
- package/dist/esm/node/plugin/plugins/vite6HmrRegressionWorkaround.d.ts +0 -3
- package/dist/esm/node/runtime/globalContext/loadImportBuild.d.ts +0 -18
- package/dist/esm/node/runtime/globalContext/loadImportBuild.js +0 -23
- package/dist/esm/node/runtime/page-files/getPageFilesExports.d.ts +0 -2
- package/dist/esm/node/runtime/page-files/getPageFilesExports.js +0 -20
- package/dist/esm/node/runtime/page-files/setup.d.ts +0 -1
- package/dist/esm/node/runtime/page-files/setup.js +0 -3
- package/dist/cjs/node/plugin/plugins/{importBuild → buildEntry}/getVikeManifest.js +0 -0
- package/dist/cjs/shared/page-configs/{getConfigValue.js → getConfigValueRuntime.js} +0 -0
- package/dist/esm/node/plugin/plugins/{importBuild → buildEntry}/getVikeManifest.js +0 -0
- package/dist/esm/shared/getPageFiles/{setPageFiles.d.ts → getPageFiles.d.ts} +1 -1
- /package/dist/esm/shared/page-configs/{getConfigValue.d.ts → getConfigValueRuntime.d.ts} +0 -0
- /package/dist/esm/shared/page-configs/{getConfigValue.js → getConfigValueRuntime.js} +0 -0
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
export { crawlPlusFiles };
|
|
2
|
-
import { assertPosixPath, assert, scriptFileExtensions, assertIsSingleModuleInstance, assertIsNotProductionRuntime, isVersionOrAbove, isScriptFile } from '../../../../utils.js';
|
|
2
|
+
import { assertPosixPath, assert, scriptFileExtensions, assertIsSingleModuleInstance, assertIsNotProductionRuntime, isVersionOrAbove, isScriptFile, scriptFileExtensionList } from '../../../../utils.js';
|
|
3
3
|
import path from 'path';
|
|
4
|
-
import fs from 'fs/promises';
|
|
5
4
|
import glob from 'fast-glob';
|
|
6
5
|
import { exec } from 'child_process';
|
|
7
6
|
import { promisify } from 'util';
|
|
8
7
|
import { isTemporaryBuildFile } from './transpileAndExecuteFile.js';
|
|
8
|
+
import { getEnvVarObject } from '../../../../shared/getEnvVarObject.js';
|
|
9
9
|
const execA = promisify(exec);
|
|
10
|
-
const TOO_MANY_UNTRACKED_FILES = 5;
|
|
11
10
|
assertIsNotProductionRuntime();
|
|
12
11
|
assertIsSingleModuleInstance('crawlPlusFiles.ts');
|
|
13
12
|
let gitIsNotUsable = false;
|
|
14
|
-
async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem
|
|
13
|
+
async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem) {
|
|
15
14
|
assertPosixPath(userRootDir);
|
|
16
15
|
//*/
|
|
17
16
|
const outDirRelativeFromUserRootDir = null;
|
|
@@ -31,14 +30,13 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, crawlWithGi
|
|
|
31
30
|
//
|
|
32
31
|
!outDirRelativeFromUserRootDir.startsWith('../')));
|
|
33
32
|
// Crawl
|
|
34
|
-
let files
|
|
35
|
-
const res =
|
|
33
|
+
let files;
|
|
34
|
+
const res = !isGitCrawlDisabled() && (await gitLsFiles(userRootDir, outDirRelativeFromUserRootDir));
|
|
36
35
|
if (res &&
|
|
37
36
|
// Fallback to fast-glob for users that dynamically generate plus files. (Assuming that no plus file is found because of the user's .gitignore list.)
|
|
38
|
-
res.
|
|
39
|
-
files = res
|
|
37
|
+
res.length > 0) {
|
|
38
|
+
files = res;
|
|
40
39
|
// We cannot find files inside symlink directories with `$ git ls-files` => we use fast-glob
|
|
41
|
-
files.push(...(await crawlSymlinkDirs(res.symlinkDirs, userRootDir, outDirRelativeFromUserRootDir)));
|
|
42
40
|
}
|
|
43
41
|
else {
|
|
44
42
|
files = await fastGlob(userRootDir, outDirRelativeFromUserRootDir);
|
|
@@ -70,24 +68,21 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
70
68
|
'git',
|
|
71
69
|
preserveUTF8,
|
|
72
70
|
'ls-files',
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
// - Performance gain seems negligible: https://github.com/vikejs/vike/pull/1688#issuecomment-2166206648
|
|
76
|
-
// ...scriptFileExtensionList.map((ext) => `"**/+*.${ext}"`),
|
|
71
|
+
// Performance gain seems negligible: https://github.com/vikejs/vike/pull/1688#issuecomment-2166206648
|
|
72
|
+
...scriptFileExtensionList.map((ext) => `"**/+*.${ext}"`),
|
|
77
73
|
// Performance gain is non-negligible.
|
|
78
74
|
// - https://github.com/vikejs/vike/pull/1688#issuecomment-2166206648
|
|
79
75
|
// - When node_modules/ is untracked the performance gain could be significant?
|
|
80
76
|
...ignoreAsPatterns.map((pattern) => `--exclude="${pattern}"`),
|
|
81
77
|
// --others --exclude-standard => list untracked files (--others) while using .gitignore (--exclude-standard)
|
|
82
78
|
// --cached => list tracked files
|
|
83
|
-
|
|
84
|
-
'--others --exclude-standard --cached --stage'
|
|
79
|
+
'--others --exclude-standard --cached'
|
|
85
80
|
].join(' ');
|
|
86
|
-
let
|
|
81
|
+
let filesAll;
|
|
87
82
|
let filesDeleted;
|
|
88
83
|
try {
|
|
89
84
|
;
|
|
90
|
-
[
|
|
85
|
+
[filesAll, filesDeleted] = await Promise.all([
|
|
91
86
|
// Main command
|
|
92
87
|
runCmd1(cmd, userRootDir),
|
|
93
88
|
// Get tracked but deleted files
|
|
@@ -101,40 +96,23 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
101
96
|
}
|
|
102
97
|
throw err;
|
|
103
98
|
}
|
|
104
|
-
const filePaths = resultLines.map(parseGitLsResultLine);
|
|
105
|
-
// If there are too many files without mode we fallback to fast-glob
|
|
106
|
-
if (filePaths.filter((f) => !f.mode).length > TOO_MANY_UNTRACKED_FILES)
|
|
107
|
-
return null;
|
|
108
|
-
const symlinkDirs = [];
|
|
109
99
|
const files = [];
|
|
110
|
-
for (const
|
|
111
|
-
//
|
|
112
|
-
if (
|
|
100
|
+
for (const filePath of filesAll) {
|
|
101
|
+
// + file?
|
|
102
|
+
if (!path.posix.basename(filePath).startsWith('+'))
|
|
113
103
|
continue;
|
|
114
104
|
// We have to repeat the same exclusion logic here because the option --exclude of `$ git ls-files` only applies to untracked files. (We use --exclude only to speed up the `$ git ls-files` command.)
|
|
115
105
|
if (!ignoreAsFilterFn(filePath))
|
|
116
106
|
continue;
|
|
117
|
-
// Symlink directory?
|
|
118
|
-
{
|
|
119
|
-
const isSymlinkDir = await isSymlinkDirectory(mode, filePath, userRootDir);
|
|
120
|
-
if (isSymlinkDir) {
|
|
121
|
-
symlinkDirs.push(filePath);
|
|
122
|
-
continue;
|
|
123
|
-
}
|
|
124
|
-
// Skip deleted files and non-symlink directories
|
|
125
|
-
if (isSymlinkDir === null) {
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
// + file?
|
|
130
|
-
if (!path.posix.basename(filePath).startsWith('+'))
|
|
131
|
-
continue;
|
|
132
107
|
// JavaScript file?
|
|
133
108
|
if (!isScriptFile(filePath))
|
|
134
109
|
continue;
|
|
110
|
+
// Deleted?
|
|
111
|
+
if (filesDeleted.includes(filePath))
|
|
112
|
+
continue;
|
|
135
113
|
files.push(filePath);
|
|
136
114
|
}
|
|
137
|
-
return
|
|
115
|
+
return files;
|
|
138
116
|
}
|
|
139
117
|
// Same as gitLsFiles() but using fast-glob
|
|
140
118
|
async function fastGlob(userRootDir, outDirRelativeFromUserRootDir) {
|
|
@@ -204,77 +182,6 @@ async function isGitNotUsable(userRootDir) {
|
|
|
204
182
|
return false;
|
|
205
183
|
}
|
|
206
184
|
}
|
|
207
|
-
async function crawlSymlinkDirs(symlinkDirs, userRootDir, outDirRelativeFromUserRootDir) {
|
|
208
|
-
const filesInSymlinkDirs = (await Promise.all(symlinkDirs.map(async (symlinkDir) => (await fastGlob(path.posix.join(userRootDir, symlinkDir), outDirRelativeFromUserRootDir)).map((filePath) => path.posix.join(symlinkDir, filePath))))).flat();
|
|
209
|
-
return filesInSymlinkDirs;
|
|
210
|
-
}
|
|
211
|
-
// Parse:
|
|
212
|
-
// ```
|
|
213
|
-
// some/not/tracked/path
|
|
214
|
-
// 100644 f6928073402b241b468b199893ff6f4aed0b7195 0\tpages/index/+Page.tsx
|
|
215
|
-
// ```
|
|
216
|
-
function parseGitLsResultLine(resultLine) {
|
|
217
|
-
const [part1, part2, ...rest] = resultLine.split('\t');
|
|
218
|
-
assert(part1);
|
|
219
|
-
assert(rest.length === 0);
|
|
220
|
-
// Git doesn't provide the mode for untracked paths.
|
|
221
|
-
// `resultLine` is:
|
|
222
|
-
// ```
|
|
223
|
-
// some/not/tracked/path
|
|
224
|
-
// ```
|
|
225
|
-
if (part2 === undefined) {
|
|
226
|
-
return { filePath: part1, mode: null };
|
|
227
|
-
}
|
|
228
|
-
assert(part2);
|
|
229
|
-
// `resultLine` is:
|
|
230
|
-
// ```
|
|
231
|
-
// 100644 f6928073402b241b468b199893ff6f4aed0b7195 0\tpages/index/+Page.tsx
|
|
232
|
-
// ```
|
|
233
|
-
const [mode, _, __, ...rest2] = part1.split(' ');
|
|
234
|
-
assert(mode && _ && __ && rest2.length === 0);
|
|
235
|
-
return { filePath: part2, mode };
|
|
236
|
-
}
|
|
237
|
-
async function isSymlinkDirectory(mode, filePath, userRootDir) {
|
|
238
|
-
const filePathAbsolute = path.posix.join(userRootDir, filePath);
|
|
239
|
-
let stats = null;
|
|
240
|
-
let isSymlink = false;
|
|
241
|
-
if (mode === '120000') {
|
|
242
|
-
isSymlink = true;
|
|
243
|
-
}
|
|
244
|
-
else if (mode === null) {
|
|
245
|
-
// `$ git ls-files` doesn't provide the mode when Git doesn't track the path
|
|
246
|
-
stats = await getFileStats(filePathAbsolute);
|
|
247
|
-
if (stats === null)
|
|
248
|
-
return null;
|
|
249
|
-
isSymlink = stats.isSymbolicLink();
|
|
250
|
-
if (!isSymlink && stats.isDirectory())
|
|
251
|
-
return null;
|
|
252
|
-
}
|
|
253
|
-
else {
|
|
254
|
-
assert(mode);
|
|
255
|
-
}
|
|
256
|
-
if (!isSymlink)
|
|
257
|
-
return false;
|
|
258
|
-
if (!stats)
|
|
259
|
-
stats = await getFileStats(filePathAbsolute);
|
|
260
|
-
if (stats === null)
|
|
261
|
-
return null;
|
|
262
|
-
const isDirectory = stats.isDirectory();
|
|
263
|
-
return isDirectory;
|
|
264
|
-
}
|
|
265
|
-
async function getFileStats(filePathAbsolute) {
|
|
266
|
-
let stats;
|
|
267
|
-
try {
|
|
268
|
-
stats = await fs.lstat(filePathAbsolute);
|
|
269
|
-
}
|
|
270
|
-
catch (err) {
|
|
271
|
-
// File was deleted, usually a temporary file such as +config.js.build-j95xb988fpln.mjs
|
|
272
|
-
// ENOENT: no such file or directory
|
|
273
|
-
assert(err.code === 'ENOENT');
|
|
274
|
-
return null;
|
|
275
|
-
}
|
|
276
|
-
return stats;
|
|
277
|
-
}
|
|
278
185
|
async function runCmd1(cmd, cwd) {
|
|
279
186
|
const { stdout } = await execA(cmd, {
|
|
280
187
|
cwd,
|
|
@@ -299,3 +206,7 @@ async function runCmd2(cmd, cwd) {
|
|
|
299
206
|
stderr = stderr.toString().trim();
|
|
300
207
|
return { stdout, stderr };
|
|
301
208
|
}
|
|
209
|
+
function isGitCrawlDisabled() {
|
|
210
|
+
const crawSettings = getEnvVarObject('VIKE_CRAWL');
|
|
211
|
+
return crawSettings?.git === false;
|
|
212
|
+
}
|
|
@@ -8,11 +8,13 @@ export { getConfigValueInterfaceFile };
|
|
|
8
8
|
export type { VikeConfigObject };
|
|
9
9
|
export type { InterfaceValueFile };
|
|
10
10
|
export type { InterfaceFile };
|
|
11
|
+
export type { VikeConfigGlobal };
|
|
12
|
+
export type { VikeVitePluginOptions };
|
|
11
13
|
import type { PageConfigGlobalBuildTime, PageConfigBuildTime } from '../../../../../shared/page-configs/PageConfig.js';
|
|
12
14
|
import { type LocationId } from './getVikeConfig/filesystemRouting.js';
|
|
13
15
|
import type { ResolvedConfig } from 'vite';
|
|
14
16
|
import type { FilePathResolved } from '../../../../../shared/page-configs/FilePath.js';
|
|
15
|
-
import
|
|
17
|
+
import { getPageConfigUserFriendlyNew } from '../../../../../shared/page-configs/getPageConfigUserFriendly.js';
|
|
16
18
|
type InterfaceFile = InterfaceConfigFile | InterfaceValueFile;
|
|
17
19
|
type InterfaceFileCommons = {
|
|
18
20
|
locationId: LocationId;
|
|
@@ -37,6 +39,9 @@ type VikeConfigObject = {
|
|
|
37
39
|
pageConfigs: PageConfigBuildTime[];
|
|
38
40
|
pageConfigGlobal: PageConfigGlobalBuildTime;
|
|
39
41
|
vikeConfigGlobal: VikeConfigGlobal;
|
|
42
|
+
vikeConfigNew: {
|
|
43
|
+
global: ReturnType<typeof getPageConfigUserFriendlyNew>;
|
|
44
|
+
};
|
|
40
45
|
};
|
|
41
46
|
declare const vikeConfigDependencies: Set<string>;
|
|
42
47
|
declare function reloadVikeConfig(config: ResolvedConfig): void;
|
|
@@ -47,3 +52,96 @@ declare function getVikeConfig2(userRootDir: string, isDev: boolean, vikeVitePlu
|
|
|
47
52
|
declare function isV1Design(config: ResolvedConfig): Promise<boolean>;
|
|
48
53
|
declare function isVikeConfigFile(filePath: string): boolean;
|
|
49
54
|
declare function getConfigValueInterfaceFile(interfaceFile: InterfaceFile, configName: string): unknown;
|
|
55
|
+
type VikeConfigGlobal = {
|
|
56
|
+
prerender: false | {
|
|
57
|
+
noExtraDir: boolean;
|
|
58
|
+
parallel: boolean | number;
|
|
59
|
+
partial: boolean;
|
|
60
|
+
disableAutoRun: boolean;
|
|
61
|
+
};
|
|
62
|
+
disableAutoFullBuild: boolean | 'prerender' | null;
|
|
63
|
+
includeAssetsImportedByServer: boolean;
|
|
64
|
+
baseAssets: string | null;
|
|
65
|
+
baseServer: string | null;
|
|
66
|
+
redirects: Record<string, string>;
|
|
67
|
+
trailingSlash: boolean;
|
|
68
|
+
disableUrlNormalization: boolean;
|
|
69
|
+
};
|
|
70
|
+
type VikeVitePluginOptions = {
|
|
71
|
+
/**
|
|
72
|
+
* Enable pre-rendering.
|
|
73
|
+
*
|
|
74
|
+
* https://vike.dev/pre-rendering
|
|
75
|
+
*
|
|
76
|
+
* @default false
|
|
77
|
+
*/
|
|
78
|
+
prerender?: boolean | {
|
|
79
|
+
/**
|
|
80
|
+
* Don't create a new directory for each HTML file.
|
|
81
|
+
*
|
|
82
|
+
* For example, generate `dist/client/about.html` instead of `dist/client/about/index.html`.
|
|
83
|
+
*
|
|
84
|
+
* @default false
|
|
85
|
+
*/
|
|
86
|
+
noExtraDir?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Number of concurrent pre-render jobs.
|
|
89
|
+
*
|
|
90
|
+
* Set to `false` to disable concurrency.
|
|
91
|
+
*
|
|
92
|
+
* @default os.cpus().length
|
|
93
|
+
*/
|
|
94
|
+
parallel?: boolean | number;
|
|
95
|
+
/**
|
|
96
|
+
* Allow only some of your pages to be pre-rendered.
|
|
97
|
+
*
|
|
98
|
+
* This setting doesn't affect the pre-rendering process: it merely suppresses the warnings when some of your pages cannot be pre-rendered.
|
|
99
|
+
|
|
100
|
+
* @default false
|
|
101
|
+
*/
|
|
102
|
+
partial?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Disable the automatic initiation of the pre-rendering process when running `$ vike build`.
|
|
105
|
+
*
|
|
106
|
+
* Use this if you want to programmatically initiate the pre-rendering process instead.
|
|
107
|
+
*
|
|
108
|
+
* https://vike.dev/api#prerender
|
|
109
|
+
*
|
|
110
|
+
* @default false
|
|
111
|
+
*/
|
|
112
|
+
disableAutoRun?: boolean;
|
|
113
|
+
};
|
|
114
|
+
/** @deprecated See https://vike.dev/disableAutoFullBuild */
|
|
115
|
+
disableAutoFullBuild?: boolean | 'prerender';
|
|
116
|
+
/** The Base URL of your server.
|
|
117
|
+
*
|
|
118
|
+
* https://vike.dev/base-url
|
|
119
|
+
*/
|
|
120
|
+
baseServer?: string;
|
|
121
|
+
/** The Base URL of your static assets.
|
|
122
|
+
*
|
|
123
|
+
* https://vike.dev/base-url
|
|
124
|
+
*/
|
|
125
|
+
baseAssets?: string;
|
|
126
|
+
/** @deprecated It's now `true` by default. You can remove this option. */
|
|
127
|
+
includeAssetsImportedByServer?: boolean;
|
|
128
|
+
/** Permanent redirections (HTTP status code 301)
|
|
129
|
+
*
|
|
130
|
+
* https://vike.dev/redirects
|
|
131
|
+
*/
|
|
132
|
+
redirects?: Record<string, string>;
|
|
133
|
+
/** Whether URLs should end with a trailing slash.
|
|
134
|
+
*
|
|
135
|
+
* https://vike.dev/url-normalization
|
|
136
|
+
*
|
|
137
|
+
* @default false
|
|
138
|
+
*/
|
|
139
|
+
trailingSlash?: boolean;
|
|
140
|
+
/** Disable automatic URL normalization.
|
|
141
|
+
*
|
|
142
|
+
* https://vike.dev/url-normalization
|
|
143
|
+
*
|
|
144
|
+
* @default false
|
|
145
|
+
*/
|
|
146
|
+
disableUrlNormalization?: boolean;
|
|
147
|
+
};
|
|
@@ -23,7 +23,8 @@ import { clearFilesEnvMap, resolveConfigEnvWithFileName, resolvePointerImportOfC
|
|
|
23
23
|
import { getFilePathResolved } from '../../../shared/getFilePath.js';
|
|
24
24
|
import { getConfigValueBuildTime } from '../../../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
25
25
|
import { assertExtensionsPeerDependencies, assertExtensionsConventions } from './assertExtensions.js';
|
|
26
|
-
import {
|
|
26
|
+
import { getPageConfigUserFriendlyNew } from '../../../../../shared/page-configs/getPageConfigUserFriendly.js';
|
|
27
|
+
import { getConfigValuesBase } from '../../../../../shared/page-configs/serialize/serializeConfigValues.js';
|
|
27
28
|
assertIsNotProductionRuntime();
|
|
28
29
|
let restartVite = false;
|
|
29
30
|
let wasConfigInvalid = null;
|
|
@@ -78,6 +79,7 @@ async function getVikeConfig(config, { doNotRestartViteOnError } = {}) {
|
|
|
78
79
|
return await getVikeConfigEntry(userRootDir, isDev, vikeVitePluginOptions, doNotRestartViteOnError ?? false);
|
|
79
80
|
}
|
|
80
81
|
async function getVikeConfig2(userRootDir, isDev, vikeVitePluginOptions) {
|
|
82
|
+
assert(vikeVitePluginOptions);
|
|
81
83
|
return await getVikeConfigEntry(userRootDir, isDev, vikeVitePluginOptions, false);
|
|
82
84
|
}
|
|
83
85
|
async function getVikeConfigEntry(userRootDir, isDev, vikeVitePluginOptions, doNotRestartViteOnError) {
|
|
@@ -92,8 +94,8 @@ async function isV1Design(config) {
|
|
|
92
94
|
const isV1Design = pageConfigs.length > 0;
|
|
93
95
|
return isV1Design;
|
|
94
96
|
}
|
|
95
|
-
async function loadInterfaceFiles(userRootDir
|
|
96
|
-
const plusFiles = await findPlusFiles(userRootDir, null
|
|
97
|
+
async function loadInterfaceFiles(userRootDir) {
|
|
98
|
+
const plusFiles = await findPlusFiles(userRootDir, null);
|
|
97
99
|
const configFiles = [];
|
|
98
100
|
const valueFiles = [];
|
|
99
101
|
plusFiles.forEach((f) => {
|
|
@@ -238,18 +240,19 @@ async function loadVikeConfig_withErrorHandling(userRootDir, isDev, vikeVitePlug
|
|
|
238
240
|
configDefinitions: {},
|
|
239
241
|
configValueSources: {}
|
|
240
242
|
},
|
|
241
|
-
vikeConfigGlobal: resolveVikeConfigGlobal({}, {})
|
|
243
|
+
vikeConfigGlobal: resolveVikeConfigGlobal({}, {}),
|
|
244
|
+
vikeConfigNew: {
|
|
245
|
+
global: getPageConfigUserFriendlyNew({ configValues: {} })
|
|
246
|
+
}
|
|
242
247
|
};
|
|
243
248
|
return dummyData;
|
|
244
249
|
}
|
|
245
250
|
}
|
|
246
251
|
}
|
|
247
252
|
async function loadVikeConfig(userRootDir, vikeVitePluginOptions) {
|
|
248
|
-
const
|
|
249
|
-
const interfaceFilesByLocationId = await loadInterfaceFiles(userRootDir, crawlWithGit);
|
|
253
|
+
const interfaceFilesByLocationId = await loadInterfaceFiles(userRootDir);
|
|
250
254
|
const importedFilesLoaded = {};
|
|
251
|
-
const { pageConfigGlobal,
|
|
252
|
-
const vikeConfigGlobal = resolveVikeConfigGlobal(vikeVitePluginOptions, pageConfigGlobalValues);
|
|
255
|
+
const { pageConfigGlobal, vikeConfigGlobal } = await getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded, vikeVitePluginOptions);
|
|
253
256
|
const pageConfigs = await Promise.all(objectEntries(interfaceFilesByLocationId)
|
|
254
257
|
.filter(([_pageId, interfaceFiles]) => isDefiningPage(interfaceFiles))
|
|
255
258
|
.map(async ([locationId]) => {
|
|
@@ -299,7 +302,37 @@ async function loadVikeConfig(userRootDir, vikeVitePluginOptions) {
|
|
|
299
302
|
return pageConfig;
|
|
300
303
|
}));
|
|
301
304
|
assertPageConfigs(pageConfigs);
|
|
302
|
-
|
|
305
|
+
const configValues = getConfigValues(pageConfigGlobal);
|
|
306
|
+
const global = getPageConfigUserFriendlyNew({ configValues });
|
|
307
|
+
return { pageConfigs, pageConfigGlobal, vikeConfigGlobal, vikeConfigNew: { global } };
|
|
308
|
+
}
|
|
309
|
+
function getConfigValues(pageConfig) {
|
|
310
|
+
const configValues = {};
|
|
311
|
+
getConfigValuesBase(pageConfig, (configEnv) => !!configEnv.config).forEach((entry) => {
|
|
312
|
+
if (entry.configValueBase.type === 'computed') {
|
|
313
|
+
assert('value' in entry); // Help TS
|
|
314
|
+
const { configValueBase, value, configName } = entry;
|
|
315
|
+
configValues[configName] = { ...configValueBase, value };
|
|
316
|
+
}
|
|
317
|
+
if (entry.configValueBase.type === 'standard') {
|
|
318
|
+
assert('sourceRelevant' in entry); // Help TS
|
|
319
|
+
const { configValueBase, sourceRelevant, configName } = entry;
|
|
320
|
+
assert('value' in sourceRelevant);
|
|
321
|
+
const { value } = sourceRelevant;
|
|
322
|
+
configValues[configName] = { ...configValueBase, value };
|
|
323
|
+
}
|
|
324
|
+
if (entry.configValueBase.type === 'cumulative') {
|
|
325
|
+
assert('sourcesRelevant' in entry); // Help TS
|
|
326
|
+
const { configValueBase, sourcesRelevant, configName } = entry;
|
|
327
|
+
const values = [];
|
|
328
|
+
sourcesRelevant.forEach((source) => {
|
|
329
|
+
assert('value' in source);
|
|
330
|
+
values.push(source.value);
|
|
331
|
+
});
|
|
332
|
+
configValues[configName] = { ...configValueBase, value: values };
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
return configValues;
|
|
303
336
|
}
|
|
304
337
|
// TODO/soon: refactor
|
|
305
338
|
// - Dedupe: most of the assertUsageGlobalConfigs() code below is a copy-paste of the assertUsage() logic inside getGlobalConfigs()
|
|
@@ -377,7 +410,7 @@ function getInterfaceFilesRelevant(interfaceFilesByLocationId, locationIdPage) {
|
|
|
377
410
|
.sort(([locationId1], [locationId2]) => sortAfterInheritanceOrder(locationId1, locationId2, locationIdPage)));
|
|
378
411
|
return interfaceFilesRelevant;
|
|
379
412
|
}
|
|
380
|
-
async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded) {
|
|
413
|
+
async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded, vikeVitePluginOptions) {
|
|
381
414
|
const locationIds = objectKeys(interfaceFilesByLocationId);
|
|
382
415
|
const interfaceFilesGlobal = objectFromEntries(objectEntries(interfaceFilesByLocationId).filter(([locationId]) => {
|
|
383
416
|
return isGlobalLocation(locationId, locationIds);
|
|
@@ -432,7 +465,31 @@ async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importe
|
|
|
432
465
|
pageConfigGlobalValues[configName] = configValueSource.value;
|
|
433
466
|
}
|
|
434
467
|
}));
|
|
435
|
-
|
|
468
|
+
const vikeConfigGlobal = resolveVikeConfigGlobal(vikeVitePluginOptions, pageConfigGlobalValues);
|
|
469
|
+
{
|
|
470
|
+
assert(isObject(vikeVitePluginOptions));
|
|
471
|
+
Object.entries(vikeVitePluginOptions).forEach(([configName, value]) => {
|
|
472
|
+
if (pageConfigGlobal.configValueSources[configName])
|
|
473
|
+
return;
|
|
474
|
+
pageConfigGlobal.configValueSources[configName] = [];
|
|
475
|
+
pageConfigGlobal.configValueSources[configName].push({
|
|
476
|
+
value,
|
|
477
|
+
configEnv: { config: true },
|
|
478
|
+
definedAtFilePath: {
|
|
479
|
+
...getFilePathResolved({
|
|
480
|
+
userRootDir,
|
|
481
|
+
filePathAbsoluteUserRootDir: '/vite.config.js'
|
|
482
|
+
}),
|
|
483
|
+
fileExportPathToShowToUser: null
|
|
484
|
+
},
|
|
485
|
+
locationId: '/',
|
|
486
|
+
isOverriden: false,
|
|
487
|
+
valueIsImportedAtRuntime: false,
|
|
488
|
+
valueIsDefinedByPlusFile: false
|
|
489
|
+
});
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
return { pageConfigGlobal, pageConfigGlobalValues, vikeConfigGlobal };
|
|
436
493
|
}
|
|
437
494
|
async function resolveConfigValueSources(configName, configDef, interfaceFilesRelevant, userRootDir, importedFilesLoaded) {
|
|
438
495
|
const sourcesInfo = [];
|
|
@@ -793,8 +850,8 @@ function getComputed(configValueSources, configDefinitions) {
|
|
|
793
850
|
});
|
|
794
851
|
return configValuesComputed;
|
|
795
852
|
}
|
|
796
|
-
async function findPlusFiles(userRootDir, outDirRoot
|
|
797
|
-
const files = await crawlPlusFiles(userRootDir, outDirRoot
|
|
853
|
+
async function findPlusFiles(userRootDir, outDirRoot) {
|
|
854
|
+
const files = await crawlPlusFiles(userRootDir, outDirRoot);
|
|
798
855
|
const plusFiles = files.map(({ filePathAbsoluteUserRootDir }) => getFilePathResolved({ filePathAbsoluteUserRootDir, userRootDir }));
|
|
799
856
|
return plusFiles;
|
|
800
857
|
}
|
|
@@ -1010,3 +1067,121 @@ function sortConfigValueSources(configValueSources, locationIdPage) {
|
|
|
1010
1067
|
function getConfigValueInterfaceFile(interfaceFile, configName) {
|
|
1011
1068
|
return interfaceFile.fileExportsByConfigName[configName]?.configValue;
|
|
1012
1069
|
}
|
|
1070
|
+
// TODO: refactor code below
|
|
1071
|
+
function resolveVikeConfigGlobal(vikeVitePluginOptions, pageConfigGlobalValues) {
|
|
1072
|
+
// TODO/v1-release: remove
|
|
1073
|
+
assertVikeConfigGlobal(vikeVitePluginOptions, ({ prop, errMsg }) => `vite.config.js > vike option ${prop} ${errMsg}`);
|
|
1074
|
+
const configs = [vikeVitePluginOptions];
|
|
1075
|
+
assertVikeConfigGlobal(pageConfigGlobalValues, ({ prop, errMsg }) => {
|
|
1076
|
+
// Can we add the config file path ?
|
|
1077
|
+
return `config ${pc.cyan(prop)} ${errMsg}`;
|
|
1078
|
+
});
|
|
1079
|
+
configs.push(pageConfigGlobalValues);
|
|
1080
|
+
const vikeConfigGlobal = {
|
|
1081
|
+
disableAutoFullBuild: pickFirst(configs.map((c) => c.disableAutoFullBuild)) ?? null,
|
|
1082
|
+
prerender: resolvePrerenderOptions(configs),
|
|
1083
|
+
includeAssetsImportedByServer: pickFirst(configs.map((c) => c.includeAssetsImportedByServer)) ?? true,
|
|
1084
|
+
baseServer: pickFirst(configs.map((c) => c.baseServer)) ?? null,
|
|
1085
|
+
baseAssets: pickFirst(configs.map((c) => c.baseAssets)) ?? null,
|
|
1086
|
+
redirects: merge(configs.map((c) => c.redirects)) ?? {},
|
|
1087
|
+
disableUrlNormalization: pickFirst(configs.map((c) => c.disableUrlNormalization)) ?? false,
|
|
1088
|
+
trailingSlash: pickFirst(configs.map((c) => c.trailingSlash)) ?? false
|
|
1089
|
+
};
|
|
1090
|
+
return vikeConfigGlobal;
|
|
1091
|
+
}
|
|
1092
|
+
function resolvePrerenderOptions(configs) {
|
|
1093
|
+
if (!configs.some((c) => c.prerender)) {
|
|
1094
|
+
return false;
|
|
1095
|
+
}
|
|
1096
|
+
const configsPrerender = configs.map((c) => c.prerender).filter(isObject2);
|
|
1097
|
+
return {
|
|
1098
|
+
partial: pickFirst(configsPrerender.map((c) => c.partial)) ?? false,
|
|
1099
|
+
noExtraDir: pickFirst(configsPrerender.map((c) => c.noExtraDir)) ?? false,
|
|
1100
|
+
parallel: pickFirst(configsPrerender.map((c) => c.parallel)) ?? true,
|
|
1101
|
+
disableAutoRun: pickFirst(configsPrerender.map((c) => c.disableAutoRun)) ?? false
|
|
1102
|
+
};
|
|
1103
|
+
}
|
|
1104
|
+
function isObject2(p) {
|
|
1105
|
+
return typeof p === 'object';
|
|
1106
|
+
}
|
|
1107
|
+
function merge(objs) {
|
|
1108
|
+
const obj = {};
|
|
1109
|
+
objs.forEach((e) => {
|
|
1110
|
+
Object.assign(obj, e);
|
|
1111
|
+
});
|
|
1112
|
+
return obj;
|
|
1113
|
+
}
|
|
1114
|
+
function pickFirst(arr) {
|
|
1115
|
+
return arr.filter((v) => v !== undefined)[0];
|
|
1116
|
+
}
|
|
1117
|
+
function assertVikeConfigGlobal(vikeConfigGlobal, wrongUsageMsg) {
|
|
1118
|
+
const wrongUsageError = check(vikeConfigGlobal);
|
|
1119
|
+
if (wrongUsageError) {
|
|
1120
|
+
assertUsage(false, wrongUsageMsg(wrongUsageError));
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
function check(vikeConfigGlobal) {
|
|
1124
|
+
assert(isObject(vikeConfigGlobal));
|
|
1125
|
+
{
|
|
1126
|
+
const prop = 'disableUrlNormalization';
|
|
1127
|
+
if (!hasProp(vikeConfigGlobal, prop, 'boolean') && !hasProp(vikeConfigGlobal, prop, 'undefined'))
|
|
1128
|
+
return { prop, errMsg: 'should be a boolean' };
|
|
1129
|
+
}
|
|
1130
|
+
{
|
|
1131
|
+
const prop = 'trailingSlash';
|
|
1132
|
+
if (!hasProp(vikeConfigGlobal, prop, 'boolean') && !hasProp(vikeConfigGlobal, prop, 'undefined'))
|
|
1133
|
+
return { prop, errMsg: 'should be a boolean' };
|
|
1134
|
+
}
|
|
1135
|
+
{
|
|
1136
|
+
const prop = 'redirects';
|
|
1137
|
+
const { redirects } = vikeConfigGlobal;
|
|
1138
|
+
if (!(redirects === undefined ||
|
|
1139
|
+
(isObject(redirects) && Object.values(redirects).every((v) => typeof v === 'string'))))
|
|
1140
|
+
return { prop, errMsg: 'should be an object of strings' };
|
|
1141
|
+
}
|
|
1142
|
+
{
|
|
1143
|
+
const prop = 'disableAutoFullBuild';
|
|
1144
|
+
if (!hasProp(vikeConfigGlobal, prop, 'boolean') &&
|
|
1145
|
+
!hasProp(vikeConfigGlobal, prop, 'undefined') &&
|
|
1146
|
+
!(vikeConfigGlobal[prop] === 'prerender'))
|
|
1147
|
+
return { prop, errMsg: "should be a boolean or 'prerender'" };
|
|
1148
|
+
}
|
|
1149
|
+
{
|
|
1150
|
+
const prop = 'includeAssetsImportedByServer';
|
|
1151
|
+
if (!hasProp(vikeConfigGlobal, prop, 'boolean') && !hasProp(vikeConfigGlobal, prop, 'undefined'))
|
|
1152
|
+
return { prop, errMsg: 'should be a boolean' };
|
|
1153
|
+
}
|
|
1154
|
+
{
|
|
1155
|
+
const prop = 'prerender';
|
|
1156
|
+
if (!hasProp(vikeConfigGlobal, prop, 'object') &&
|
|
1157
|
+
!hasProp(vikeConfigGlobal, prop, 'boolean') &&
|
|
1158
|
+
!hasProp(vikeConfigGlobal, prop, 'undefined'))
|
|
1159
|
+
return { prop, errMsg: 'should be an object or a boolean' };
|
|
1160
|
+
}
|
|
1161
|
+
const configVikePrerender = vikeConfigGlobal.prerender;
|
|
1162
|
+
if (typeof configVikePrerender === 'object') {
|
|
1163
|
+
{
|
|
1164
|
+
const p = 'partial';
|
|
1165
|
+
if (!hasProp(configVikePrerender, p, 'boolean') && !hasProp(configVikePrerender, p, 'undefined'))
|
|
1166
|
+
return { prop: `prerender.${p}`, errMsg: 'should be a boolean' };
|
|
1167
|
+
}
|
|
1168
|
+
{
|
|
1169
|
+
const p = 'noExtraDir';
|
|
1170
|
+
if (!hasProp(configVikePrerender, p, 'boolean') && !hasProp(configVikePrerender, p, 'undefined'))
|
|
1171
|
+
return { prop: `prerender.${p}`, errMsg: 'should be a boolean' };
|
|
1172
|
+
}
|
|
1173
|
+
{
|
|
1174
|
+
const p = 'disableAutoRun';
|
|
1175
|
+
if (!hasProp(configVikePrerender, p, 'boolean') && !hasProp(configVikePrerender, p, 'undefined'))
|
|
1176
|
+
return { prop: `prerender.${p}`, errMsg: 'should be a boolean' };
|
|
1177
|
+
}
|
|
1178
|
+
{
|
|
1179
|
+
const p = 'parallel';
|
|
1180
|
+
if (!hasProp(configVikePrerender, p, 'boolean') &&
|
|
1181
|
+
!hasProp(configVikePrerender, p, 'number') &&
|
|
1182
|
+
!hasProp(configVikePrerender, p, 'undefined'))
|
|
1183
|
+
return { prop: `prerender.${p}`, errMsg: 'should be a boolean or a number' };
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
return null;
|
|
1187
|
+
}
|
|
@@ -5,7 +5,8 @@ import { getVikeConfig } from './getVikeConfig.js';
|
|
|
5
5
|
import { isRuntimeEnvMatch } from './isRuntimeEnvMatch.js';
|
|
6
6
|
import { serializeConfigValues } from '../../../../../shared/page-configs/serialize/serializeConfigValues.js';
|
|
7
7
|
async function getVirtualFilePageConfigs(isForClientSide, isDev, id, isClientRouting, config) {
|
|
8
|
-
const
|
|
8
|
+
const vikeConfig = await getVikeConfig(config, { doNotRestartViteOnError: true });
|
|
9
|
+
const { pageConfigs, pageConfigGlobal } = vikeConfig;
|
|
9
10
|
return getCode(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isClientRouting);
|
|
10
11
|
}
|
|
11
12
|
function getCode(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isClientRouting) {
|
|
@@ -33,7 +33,7 @@ function setGlobalContext() {
|
|
|
33
33
|
order: 'post',
|
|
34
34
|
async handler(config) {
|
|
35
35
|
const { outDirRoot } = getOutDirs(config);
|
|
36
|
-
assertFilePathAbsoluteFilesystem(outDirRoot); // Needed for
|
|
36
|
+
assertFilePathAbsoluteFilesystem(outDirRoot); // Needed for `importServerProductionEntry({ outDir })` of @brillout/vite-plugin-server-entry
|
|
37
37
|
setGlobalContext_viteConfig(config, outDirRoot);
|
|
38
38
|
const vikeConfig = await getVikeConfig(config);
|
|
39
39
|
setGlobalContext_vikeConfig(vikeConfig);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { workaroundVite6HmrRegression };
|
|
2
2
|
// https://vite.dev/guide/migration (will be 404 after vite@7 release) > search for `hmrReload()`
|
|
3
3
|
// https://v6.vite.dev/guide/migration (will exist after vite@7 release) > search for `hmrReload()`
|
|
4
4
|
// Workaround seems to work for docs page /banner (which is HTML-only)
|
|
5
5
|
// But doesn't seem to work for /examples/render-modes/ (see https://github.com/vikejs/vike/pull/2069 commit `renable HMR test for HTML-only`)
|
|
6
|
-
function
|
|
6
|
+
function workaroundVite6HmrRegression() {
|
|
7
7
|
return {
|
|
8
|
-
name: 'vike:
|
|
8
|
+
name: 'vike:workaroundVite6HmrRegression',
|
|
9
9
|
enforce: 'post',
|
|
10
10
|
hotUpdate: {
|
|
11
11
|
order: 'post',
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { getEnvVarObject };
|
|
2
|
-
declare function getEnvVarObject(envVarName: 'VITE_CONFIG'): null | Record<string, unknown>;
|
|
2
|
+
declare function getEnvVarObject(envVarName: 'VITE_CONFIG' | 'VIKE_CRAWL'): null | Record<string, unknown>;
|
|
@@ -3,7 +3,6 @@ export { runPrerenderFromCLIPrerenderCommand };
|
|
|
3
3
|
export { runPrerenderFromAutoRun };
|
|
4
4
|
export { runPrerender_forceExit };
|
|
5
5
|
export type { PrerenderOptions };
|
|
6
|
-
import '../runtime/page-files/setup.js';
|
|
7
6
|
import type { InlineConfig, ResolvedConfig } from 'vite';
|
|
8
7
|
import type { APIOptions } from '../api/types.js';
|
|
9
8
|
type PrerenderOptions = APIOptions & {
|
|
@@ -30,5 +29,5 @@ declare function runPrerenderFromAPI(options?: PrerenderOptions): Promise<{
|
|
|
30
29
|
viteConfig: ResolvedConfig;
|
|
31
30
|
}>;
|
|
32
31
|
declare function runPrerenderFromCLIPrerenderCommand(): Promise<void>;
|
|
33
|
-
declare function runPrerenderFromAutoRun(viteConfig: InlineConfig, forceExit: boolean): Promise<void>;
|
|
32
|
+
declare function runPrerenderFromAutoRun(viteConfig: InlineConfig | undefined, forceExit: boolean): Promise<void>;
|
|
34
33
|
declare function runPrerender_forceExit(): void;
|