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/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -6,17 +6,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.crawlPlusFiles = crawlPlusFiles;
|
|
7
7
|
const utils_js_1 = require("../../../../utils.js");
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const promises_1 = __importDefault(require("fs/promises"));
|
|
10
9
|
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
11
10
|
const child_process_1 = require("child_process");
|
|
12
11
|
const util_1 = require("util");
|
|
13
12
|
const transpileAndExecuteFile_js_1 = require("./transpileAndExecuteFile.js");
|
|
13
|
+
const getEnvVarObject_js_1 = require("../../../../shared/getEnvVarObject.js");
|
|
14
14
|
const execA = (0, util_1.promisify)(child_process_1.exec);
|
|
15
|
-
const TOO_MANY_UNTRACKED_FILES = 5;
|
|
16
15
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
17
16
|
(0, utils_js_1.assertIsSingleModuleInstance)('crawlPlusFiles.ts');
|
|
18
17
|
let gitIsNotUsable = false;
|
|
19
|
-
async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem
|
|
18
|
+
async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem) {
|
|
20
19
|
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
21
20
|
//*/
|
|
22
21
|
const outDirRelativeFromUserRootDir = null;
|
|
@@ -36,14 +35,13 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, crawlWithGi
|
|
|
36
35
|
//
|
|
37
36
|
!outDirRelativeFromUserRootDir.startsWith('../')));
|
|
38
37
|
// Crawl
|
|
39
|
-
let files
|
|
40
|
-
const res =
|
|
38
|
+
let files;
|
|
39
|
+
const res = !isGitCrawlDisabled() && (await gitLsFiles(userRootDir, outDirRelativeFromUserRootDir));
|
|
41
40
|
if (res &&
|
|
42
41
|
// 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.)
|
|
43
|
-
res.
|
|
44
|
-
files = res
|
|
42
|
+
res.length > 0) {
|
|
43
|
+
files = res;
|
|
45
44
|
// We cannot find files inside symlink directories with `$ git ls-files` => we use fast-glob
|
|
46
|
-
files.push(...(await crawlSymlinkDirs(res.symlinkDirs, userRootDir, outDirRelativeFromUserRootDir)));
|
|
47
45
|
}
|
|
48
46
|
else {
|
|
49
47
|
files = await fastGlob(userRootDir, outDirRelativeFromUserRootDir);
|
|
@@ -75,24 +73,21 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
75
73
|
'git',
|
|
76
74
|
preserveUTF8,
|
|
77
75
|
'ls-files',
|
|
78
|
-
//
|
|
79
|
-
|
|
80
|
-
// - Performance gain seems negligible: https://github.com/vikejs/vike/pull/1688#issuecomment-2166206648
|
|
81
|
-
// ...scriptFileExtensionList.map((ext) => `"**/+*.${ext}"`),
|
|
76
|
+
// Performance gain seems negligible: https://github.com/vikejs/vike/pull/1688#issuecomment-2166206648
|
|
77
|
+
...utils_js_1.scriptFileExtensionList.map((ext) => `"**/+*.${ext}"`),
|
|
82
78
|
// Performance gain is non-negligible.
|
|
83
79
|
// - https://github.com/vikejs/vike/pull/1688#issuecomment-2166206648
|
|
84
80
|
// - When node_modules/ is untracked the performance gain could be significant?
|
|
85
81
|
...ignoreAsPatterns.map((pattern) => `--exclude="${pattern}"`),
|
|
86
82
|
// --others --exclude-standard => list untracked files (--others) while using .gitignore (--exclude-standard)
|
|
87
83
|
// --cached => list tracked files
|
|
88
|
-
|
|
89
|
-
'--others --exclude-standard --cached --stage'
|
|
84
|
+
'--others --exclude-standard --cached'
|
|
90
85
|
].join(' ');
|
|
91
|
-
let
|
|
86
|
+
let filesAll;
|
|
92
87
|
let filesDeleted;
|
|
93
88
|
try {
|
|
94
89
|
;
|
|
95
|
-
[
|
|
90
|
+
[filesAll, filesDeleted] = await Promise.all([
|
|
96
91
|
// Main command
|
|
97
92
|
runCmd1(cmd, userRootDir),
|
|
98
93
|
// Get tracked but deleted files
|
|
@@ -106,40 +101,23 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
106
101
|
}
|
|
107
102
|
throw err;
|
|
108
103
|
}
|
|
109
|
-
const filePaths = resultLines.map(parseGitLsResultLine);
|
|
110
|
-
// If there are too many files without mode we fallback to fast-glob
|
|
111
|
-
if (filePaths.filter((f) => !f.mode).length > TOO_MANY_UNTRACKED_FILES)
|
|
112
|
-
return null;
|
|
113
|
-
const symlinkDirs = [];
|
|
114
104
|
const files = [];
|
|
115
|
-
for (const
|
|
116
|
-
//
|
|
117
|
-
if (
|
|
105
|
+
for (const filePath of filesAll) {
|
|
106
|
+
// + file?
|
|
107
|
+
if (!path_1.default.posix.basename(filePath).startsWith('+'))
|
|
118
108
|
continue;
|
|
119
109
|
// 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.)
|
|
120
110
|
if (!ignoreAsFilterFn(filePath))
|
|
121
111
|
continue;
|
|
122
|
-
// Symlink directory?
|
|
123
|
-
{
|
|
124
|
-
const isSymlinkDir = await isSymlinkDirectory(mode, filePath, userRootDir);
|
|
125
|
-
if (isSymlinkDir) {
|
|
126
|
-
symlinkDirs.push(filePath);
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
// Skip deleted files and non-symlink directories
|
|
130
|
-
if (isSymlinkDir === null) {
|
|
131
|
-
continue;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
// + file?
|
|
135
|
-
if (!path_1.default.posix.basename(filePath).startsWith('+'))
|
|
136
|
-
continue;
|
|
137
112
|
// JavaScript file?
|
|
138
113
|
if (!(0, utils_js_1.isScriptFile)(filePath))
|
|
139
114
|
continue;
|
|
115
|
+
// Deleted?
|
|
116
|
+
if (filesDeleted.includes(filePath))
|
|
117
|
+
continue;
|
|
140
118
|
files.push(filePath);
|
|
141
119
|
}
|
|
142
|
-
return
|
|
120
|
+
return files;
|
|
143
121
|
}
|
|
144
122
|
// Same as gitLsFiles() but using fast-glob
|
|
145
123
|
async function fastGlob(userRootDir, outDirRelativeFromUserRootDir) {
|
|
@@ -209,77 +187,6 @@ async function isGitNotUsable(userRootDir) {
|
|
|
209
187
|
return false;
|
|
210
188
|
}
|
|
211
189
|
}
|
|
212
|
-
async function crawlSymlinkDirs(symlinkDirs, userRootDir, outDirRelativeFromUserRootDir) {
|
|
213
|
-
const filesInSymlinkDirs = (await Promise.all(symlinkDirs.map(async (symlinkDir) => (await fastGlob(path_1.default.posix.join(userRootDir, symlinkDir), outDirRelativeFromUserRootDir)).map((filePath) => path_1.default.posix.join(symlinkDir, filePath))))).flat();
|
|
214
|
-
return filesInSymlinkDirs;
|
|
215
|
-
}
|
|
216
|
-
// Parse:
|
|
217
|
-
// ```
|
|
218
|
-
// some/not/tracked/path
|
|
219
|
-
// 100644 f6928073402b241b468b199893ff6f4aed0b7195 0\tpages/index/+Page.tsx
|
|
220
|
-
// ```
|
|
221
|
-
function parseGitLsResultLine(resultLine) {
|
|
222
|
-
const [part1, part2, ...rest] = resultLine.split('\t');
|
|
223
|
-
(0, utils_js_1.assert)(part1);
|
|
224
|
-
(0, utils_js_1.assert)(rest.length === 0);
|
|
225
|
-
// Git doesn't provide the mode for untracked paths.
|
|
226
|
-
// `resultLine` is:
|
|
227
|
-
// ```
|
|
228
|
-
// some/not/tracked/path
|
|
229
|
-
// ```
|
|
230
|
-
if (part2 === undefined) {
|
|
231
|
-
return { filePath: part1, mode: null };
|
|
232
|
-
}
|
|
233
|
-
(0, utils_js_1.assert)(part2);
|
|
234
|
-
// `resultLine` is:
|
|
235
|
-
// ```
|
|
236
|
-
// 100644 f6928073402b241b468b199893ff6f4aed0b7195 0\tpages/index/+Page.tsx
|
|
237
|
-
// ```
|
|
238
|
-
const [mode, _, __, ...rest2] = part1.split(' ');
|
|
239
|
-
(0, utils_js_1.assert)(mode && _ && __ && rest2.length === 0);
|
|
240
|
-
return { filePath: part2, mode };
|
|
241
|
-
}
|
|
242
|
-
async function isSymlinkDirectory(mode, filePath, userRootDir) {
|
|
243
|
-
const filePathAbsolute = path_1.default.posix.join(userRootDir, filePath);
|
|
244
|
-
let stats = null;
|
|
245
|
-
let isSymlink = false;
|
|
246
|
-
if (mode === '120000') {
|
|
247
|
-
isSymlink = true;
|
|
248
|
-
}
|
|
249
|
-
else if (mode === null) {
|
|
250
|
-
// `$ git ls-files` doesn't provide the mode when Git doesn't track the path
|
|
251
|
-
stats = await getFileStats(filePathAbsolute);
|
|
252
|
-
if (stats === null)
|
|
253
|
-
return null;
|
|
254
|
-
isSymlink = stats.isSymbolicLink();
|
|
255
|
-
if (!isSymlink && stats.isDirectory())
|
|
256
|
-
return null;
|
|
257
|
-
}
|
|
258
|
-
else {
|
|
259
|
-
(0, utils_js_1.assert)(mode);
|
|
260
|
-
}
|
|
261
|
-
if (!isSymlink)
|
|
262
|
-
return false;
|
|
263
|
-
if (!stats)
|
|
264
|
-
stats = await getFileStats(filePathAbsolute);
|
|
265
|
-
if (stats === null)
|
|
266
|
-
return null;
|
|
267
|
-
const isDirectory = stats.isDirectory();
|
|
268
|
-
return isDirectory;
|
|
269
|
-
}
|
|
270
|
-
async function getFileStats(filePathAbsolute) {
|
|
271
|
-
let stats;
|
|
272
|
-
try {
|
|
273
|
-
stats = await promises_1.default.lstat(filePathAbsolute);
|
|
274
|
-
}
|
|
275
|
-
catch (err) {
|
|
276
|
-
// File was deleted, usually a temporary file such as +config.js.build-j95xb988fpln.mjs
|
|
277
|
-
// ENOENT: no such file or directory
|
|
278
|
-
(0, utils_js_1.assert)(err.code === 'ENOENT');
|
|
279
|
-
return null;
|
|
280
|
-
}
|
|
281
|
-
return stats;
|
|
282
|
-
}
|
|
283
190
|
async function runCmd1(cmd, cwd) {
|
|
284
191
|
const { stdout } = await execA(cmd, {
|
|
285
192
|
cwd,
|
|
@@ -304,3 +211,7 @@ async function runCmd2(cmd, cwd) {
|
|
|
304
211
|
stderr = stderr.toString().trim();
|
|
305
212
|
return { stdout, stderr };
|
|
306
213
|
}
|
|
214
|
+
function isGitCrawlDisabled() {
|
|
215
|
+
const crawSettings = (0, getEnvVarObject_js_1.getEnvVarObject)('VIKE_CRAWL');
|
|
216
|
+
return crawSettings?.git === false;
|
|
217
|
+
}
|
|
@@ -28,7 +28,8 @@ const resolvePointerImport_js_1 = require("./getVikeConfig/resolvePointerImport.
|
|
|
28
28
|
const getFilePath_js_1 = require("../../../shared/getFilePath.js");
|
|
29
29
|
const getConfigValueBuildTime_js_1 = require("../../../../../shared/page-configs/getConfigValueBuildTime.js");
|
|
30
30
|
const assertExtensions_js_1 = require("./assertExtensions.js");
|
|
31
|
-
const
|
|
31
|
+
const getPageConfigUserFriendly_js_1 = require("../../../../../shared/page-configs/getPageConfigUserFriendly.js");
|
|
32
|
+
const serializeConfigValues_js_1 = require("../../../../../shared/page-configs/serialize/serializeConfigValues.js");
|
|
32
33
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
33
34
|
let restartVite = false;
|
|
34
35
|
let wasConfigInvalid = null;
|
|
@@ -84,6 +85,7 @@ async function getVikeConfig(config, { doNotRestartViteOnError } = {}) {
|
|
|
84
85
|
return await getVikeConfigEntry(userRootDir, isDev, vikeVitePluginOptions, doNotRestartViteOnError ?? false);
|
|
85
86
|
}
|
|
86
87
|
async function getVikeConfig2(userRootDir, isDev, vikeVitePluginOptions) {
|
|
88
|
+
(0, utils_js_1.assert)(vikeVitePluginOptions);
|
|
87
89
|
return await getVikeConfigEntry(userRootDir, isDev, vikeVitePluginOptions, false);
|
|
88
90
|
}
|
|
89
91
|
async function getVikeConfigEntry(userRootDir, isDev, vikeVitePluginOptions, doNotRestartViteOnError) {
|
|
@@ -98,8 +100,8 @@ async function isV1Design(config) {
|
|
|
98
100
|
const isV1Design = pageConfigs.length > 0;
|
|
99
101
|
return isV1Design;
|
|
100
102
|
}
|
|
101
|
-
async function loadInterfaceFiles(userRootDir
|
|
102
|
-
const plusFiles = await findPlusFiles(userRootDir, null
|
|
103
|
+
async function loadInterfaceFiles(userRootDir) {
|
|
104
|
+
const plusFiles = await findPlusFiles(userRootDir, null);
|
|
103
105
|
const configFiles = [];
|
|
104
106
|
const valueFiles = [];
|
|
105
107
|
plusFiles.forEach((f) => {
|
|
@@ -244,18 +246,19 @@ async function loadVikeConfig_withErrorHandling(userRootDir, isDev, vikeVitePlug
|
|
|
244
246
|
configDefinitions: {},
|
|
245
247
|
configValueSources: {}
|
|
246
248
|
},
|
|
247
|
-
vikeConfigGlobal:
|
|
249
|
+
vikeConfigGlobal: resolveVikeConfigGlobal({}, {}),
|
|
250
|
+
vikeConfigNew: {
|
|
251
|
+
global: (0, getPageConfigUserFriendly_js_1.getPageConfigUserFriendlyNew)({ configValues: {} })
|
|
252
|
+
}
|
|
248
253
|
};
|
|
249
254
|
return dummyData;
|
|
250
255
|
}
|
|
251
256
|
}
|
|
252
257
|
}
|
|
253
258
|
async function loadVikeConfig(userRootDir, vikeVitePluginOptions) {
|
|
254
|
-
const
|
|
255
|
-
const interfaceFilesByLocationId = await loadInterfaceFiles(userRootDir, crawlWithGit);
|
|
259
|
+
const interfaceFilesByLocationId = await loadInterfaceFiles(userRootDir);
|
|
256
260
|
const importedFilesLoaded = {};
|
|
257
|
-
const { pageConfigGlobal,
|
|
258
|
-
const vikeConfigGlobal = (0, resolveVikeConfigGlobal_js_1.resolveVikeConfigGlobal)(vikeVitePluginOptions, pageConfigGlobalValues);
|
|
261
|
+
const { pageConfigGlobal, vikeConfigGlobal } = await getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded, vikeVitePluginOptions);
|
|
259
262
|
const pageConfigs = await Promise.all((0, utils_js_1.objectEntries)(interfaceFilesByLocationId)
|
|
260
263
|
.filter(([_pageId, interfaceFiles]) => isDefiningPage(interfaceFiles))
|
|
261
264
|
.map(async ([locationId]) => {
|
|
@@ -305,7 +308,37 @@ async function loadVikeConfig(userRootDir, vikeVitePluginOptions) {
|
|
|
305
308
|
return pageConfig;
|
|
306
309
|
}));
|
|
307
310
|
assertPageConfigs(pageConfigs);
|
|
308
|
-
|
|
311
|
+
const configValues = getConfigValues(pageConfigGlobal);
|
|
312
|
+
const global = (0, getPageConfigUserFriendly_js_1.getPageConfigUserFriendlyNew)({ configValues });
|
|
313
|
+
return { pageConfigs, pageConfigGlobal, vikeConfigGlobal, vikeConfigNew: { global } };
|
|
314
|
+
}
|
|
315
|
+
function getConfigValues(pageConfig) {
|
|
316
|
+
const configValues = {};
|
|
317
|
+
(0, serializeConfigValues_js_1.getConfigValuesBase)(pageConfig, (configEnv) => !!configEnv.config).forEach((entry) => {
|
|
318
|
+
if (entry.configValueBase.type === 'computed') {
|
|
319
|
+
(0, utils_js_1.assert)('value' in entry); // Help TS
|
|
320
|
+
const { configValueBase, value, configName } = entry;
|
|
321
|
+
configValues[configName] = { ...configValueBase, value };
|
|
322
|
+
}
|
|
323
|
+
if (entry.configValueBase.type === 'standard') {
|
|
324
|
+
(0, utils_js_1.assert)('sourceRelevant' in entry); // Help TS
|
|
325
|
+
const { configValueBase, sourceRelevant, configName } = entry;
|
|
326
|
+
(0, utils_js_1.assert)('value' in sourceRelevant);
|
|
327
|
+
const { value } = sourceRelevant;
|
|
328
|
+
configValues[configName] = { ...configValueBase, value };
|
|
329
|
+
}
|
|
330
|
+
if (entry.configValueBase.type === 'cumulative') {
|
|
331
|
+
(0, utils_js_1.assert)('sourcesRelevant' in entry); // Help TS
|
|
332
|
+
const { configValueBase, sourcesRelevant, configName } = entry;
|
|
333
|
+
const values = [];
|
|
334
|
+
sourcesRelevant.forEach((source) => {
|
|
335
|
+
(0, utils_js_1.assert)('value' in source);
|
|
336
|
+
values.push(source.value);
|
|
337
|
+
});
|
|
338
|
+
configValues[configName] = { ...configValueBase, value: values };
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
return configValues;
|
|
309
342
|
}
|
|
310
343
|
// TODO/soon: refactor
|
|
311
344
|
// - Dedupe: most of the assertUsageGlobalConfigs() code below is a copy-paste of the assertUsage() logic inside getGlobalConfigs()
|
|
@@ -383,7 +416,7 @@ function getInterfaceFilesRelevant(interfaceFilesByLocationId, locationIdPage) {
|
|
|
383
416
|
.sort(([locationId1], [locationId2]) => (0, filesystemRouting_js_1.sortAfterInheritanceOrder)(locationId1, locationId2, locationIdPage)));
|
|
384
417
|
return interfaceFilesRelevant;
|
|
385
418
|
}
|
|
386
|
-
async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded) {
|
|
419
|
+
async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded, vikeVitePluginOptions) {
|
|
387
420
|
const locationIds = (0, utils_js_1.objectKeys)(interfaceFilesByLocationId);
|
|
388
421
|
const interfaceFilesGlobal = (0, utils_js_1.objectFromEntries)((0, utils_js_1.objectEntries)(interfaceFilesByLocationId).filter(([locationId]) => {
|
|
389
422
|
return (0, filesystemRouting_js_1.isGlobalLocation)(locationId, locationIds);
|
|
@@ -438,7 +471,31 @@ async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importe
|
|
|
438
471
|
pageConfigGlobalValues[configName] = configValueSource.value;
|
|
439
472
|
}
|
|
440
473
|
}));
|
|
441
|
-
|
|
474
|
+
const vikeConfigGlobal = resolveVikeConfigGlobal(vikeVitePluginOptions, pageConfigGlobalValues);
|
|
475
|
+
{
|
|
476
|
+
(0, utils_js_1.assert)((0, utils_js_1.isObject)(vikeVitePluginOptions));
|
|
477
|
+
Object.entries(vikeVitePluginOptions).forEach(([configName, value]) => {
|
|
478
|
+
if (pageConfigGlobal.configValueSources[configName])
|
|
479
|
+
return;
|
|
480
|
+
pageConfigGlobal.configValueSources[configName] = [];
|
|
481
|
+
pageConfigGlobal.configValueSources[configName].push({
|
|
482
|
+
value,
|
|
483
|
+
configEnv: { config: true },
|
|
484
|
+
definedAtFilePath: {
|
|
485
|
+
...(0, getFilePath_js_1.getFilePathResolved)({
|
|
486
|
+
userRootDir,
|
|
487
|
+
filePathAbsoluteUserRootDir: '/vite.config.js'
|
|
488
|
+
}),
|
|
489
|
+
fileExportPathToShowToUser: null
|
|
490
|
+
},
|
|
491
|
+
locationId: '/',
|
|
492
|
+
isOverriden: false,
|
|
493
|
+
valueIsImportedAtRuntime: false,
|
|
494
|
+
valueIsDefinedByPlusFile: false
|
|
495
|
+
});
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
return { pageConfigGlobal, pageConfigGlobalValues, vikeConfigGlobal };
|
|
442
499
|
}
|
|
443
500
|
async function resolveConfigValueSources(configName, configDef, interfaceFilesRelevant, userRootDir, importedFilesLoaded) {
|
|
444
501
|
const sourcesInfo = [];
|
|
@@ -799,8 +856,8 @@ function getComputed(configValueSources, configDefinitions) {
|
|
|
799
856
|
});
|
|
800
857
|
return configValuesComputed;
|
|
801
858
|
}
|
|
802
|
-
async function findPlusFiles(userRootDir, outDirRoot
|
|
803
|
-
const files = await (0, crawlPlusFiles_js_1.crawlPlusFiles)(userRootDir, outDirRoot
|
|
859
|
+
async function findPlusFiles(userRootDir, outDirRoot) {
|
|
860
|
+
const files = await (0, crawlPlusFiles_js_1.crawlPlusFiles)(userRootDir, outDirRoot);
|
|
804
861
|
const plusFiles = files.map(({ filePathAbsoluteUserRootDir }) => (0, getFilePath_js_1.getFilePathResolved)({ filePathAbsoluteUserRootDir, userRootDir }));
|
|
805
862
|
return plusFiles;
|
|
806
863
|
}
|
|
@@ -1016,3 +1073,121 @@ function sortConfigValueSources(configValueSources, locationIdPage) {
|
|
|
1016
1073
|
function getConfigValueInterfaceFile(interfaceFile, configName) {
|
|
1017
1074
|
return interfaceFile.fileExportsByConfigName[configName]?.configValue;
|
|
1018
1075
|
}
|
|
1076
|
+
// TODO: refactor code below
|
|
1077
|
+
function resolveVikeConfigGlobal(vikeVitePluginOptions, pageConfigGlobalValues) {
|
|
1078
|
+
// TODO/v1-release: remove
|
|
1079
|
+
assertVikeConfigGlobal(vikeVitePluginOptions, ({ prop, errMsg }) => `vite.config.js > vike option ${prop} ${errMsg}`);
|
|
1080
|
+
const configs = [vikeVitePluginOptions];
|
|
1081
|
+
assertVikeConfigGlobal(pageConfigGlobalValues, ({ prop, errMsg }) => {
|
|
1082
|
+
// Can we add the config file path ?
|
|
1083
|
+
return `config ${picocolors_1.default.cyan(prop)} ${errMsg}`;
|
|
1084
|
+
});
|
|
1085
|
+
configs.push(pageConfigGlobalValues);
|
|
1086
|
+
const vikeConfigGlobal = {
|
|
1087
|
+
disableAutoFullBuild: pickFirst(configs.map((c) => c.disableAutoFullBuild)) ?? null,
|
|
1088
|
+
prerender: resolvePrerenderOptions(configs),
|
|
1089
|
+
includeAssetsImportedByServer: pickFirst(configs.map((c) => c.includeAssetsImportedByServer)) ?? true,
|
|
1090
|
+
baseServer: pickFirst(configs.map((c) => c.baseServer)) ?? null,
|
|
1091
|
+
baseAssets: pickFirst(configs.map((c) => c.baseAssets)) ?? null,
|
|
1092
|
+
redirects: merge(configs.map((c) => c.redirects)) ?? {},
|
|
1093
|
+
disableUrlNormalization: pickFirst(configs.map((c) => c.disableUrlNormalization)) ?? false,
|
|
1094
|
+
trailingSlash: pickFirst(configs.map((c) => c.trailingSlash)) ?? false
|
|
1095
|
+
};
|
|
1096
|
+
return vikeConfigGlobal;
|
|
1097
|
+
}
|
|
1098
|
+
function resolvePrerenderOptions(configs) {
|
|
1099
|
+
if (!configs.some((c) => c.prerender)) {
|
|
1100
|
+
return false;
|
|
1101
|
+
}
|
|
1102
|
+
const configsPrerender = configs.map((c) => c.prerender).filter(isObject2);
|
|
1103
|
+
return {
|
|
1104
|
+
partial: pickFirst(configsPrerender.map((c) => c.partial)) ?? false,
|
|
1105
|
+
noExtraDir: pickFirst(configsPrerender.map((c) => c.noExtraDir)) ?? false,
|
|
1106
|
+
parallel: pickFirst(configsPrerender.map((c) => c.parallel)) ?? true,
|
|
1107
|
+
disableAutoRun: pickFirst(configsPrerender.map((c) => c.disableAutoRun)) ?? false
|
|
1108
|
+
};
|
|
1109
|
+
}
|
|
1110
|
+
function isObject2(p) {
|
|
1111
|
+
return typeof p === 'object';
|
|
1112
|
+
}
|
|
1113
|
+
function merge(objs) {
|
|
1114
|
+
const obj = {};
|
|
1115
|
+
objs.forEach((e) => {
|
|
1116
|
+
Object.assign(obj, e);
|
|
1117
|
+
});
|
|
1118
|
+
return obj;
|
|
1119
|
+
}
|
|
1120
|
+
function pickFirst(arr) {
|
|
1121
|
+
return arr.filter((v) => v !== undefined)[0];
|
|
1122
|
+
}
|
|
1123
|
+
function assertVikeConfigGlobal(vikeConfigGlobal, wrongUsageMsg) {
|
|
1124
|
+
const wrongUsageError = check(vikeConfigGlobal);
|
|
1125
|
+
if (wrongUsageError) {
|
|
1126
|
+
(0, utils_js_1.assertUsage)(false, wrongUsageMsg(wrongUsageError));
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
function check(vikeConfigGlobal) {
|
|
1130
|
+
(0, utils_js_1.assert)((0, utils_js_1.isObject)(vikeConfigGlobal));
|
|
1131
|
+
{
|
|
1132
|
+
const prop = 'disableUrlNormalization';
|
|
1133
|
+
if (!(0, utils_js_1.hasProp)(vikeConfigGlobal, prop, 'boolean') && !(0, utils_js_1.hasProp)(vikeConfigGlobal, prop, 'undefined'))
|
|
1134
|
+
return { prop, errMsg: 'should be a boolean' };
|
|
1135
|
+
}
|
|
1136
|
+
{
|
|
1137
|
+
const prop = 'trailingSlash';
|
|
1138
|
+
if (!(0, utils_js_1.hasProp)(vikeConfigGlobal, prop, 'boolean') && !(0, utils_js_1.hasProp)(vikeConfigGlobal, prop, 'undefined'))
|
|
1139
|
+
return { prop, errMsg: 'should be a boolean' };
|
|
1140
|
+
}
|
|
1141
|
+
{
|
|
1142
|
+
const prop = 'redirects';
|
|
1143
|
+
const { redirects } = vikeConfigGlobal;
|
|
1144
|
+
if (!(redirects === undefined ||
|
|
1145
|
+
((0, utils_js_1.isObject)(redirects) && Object.values(redirects).every((v) => typeof v === 'string'))))
|
|
1146
|
+
return { prop, errMsg: 'should be an object of strings' };
|
|
1147
|
+
}
|
|
1148
|
+
{
|
|
1149
|
+
const prop = 'disableAutoFullBuild';
|
|
1150
|
+
if (!(0, utils_js_1.hasProp)(vikeConfigGlobal, prop, 'boolean') &&
|
|
1151
|
+
!(0, utils_js_1.hasProp)(vikeConfigGlobal, prop, 'undefined') &&
|
|
1152
|
+
!(vikeConfigGlobal[prop] === 'prerender'))
|
|
1153
|
+
return { prop, errMsg: "should be a boolean or 'prerender'" };
|
|
1154
|
+
}
|
|
1155
|
+
{
|
|
1156
|
+
const prop = 'includeAssetsImportedByServer';
|
|
1157
|
+
if (!(0, utils_js_1.hasProp)(vikeConfigGlobal, prop, 'boolean') && !(0, utils_js_1.hasProp)(vikeConfigGlobal, prop, 'undefined'))
|
|
1158
|
+
return { prop, errMsg: 'should be a boolean' };
|
|
1159
|
+
}
|
|
1160
|
+
{
|
|
1161
|
+
const prop = 'prerender';
|
|
1162
|
+
if (!(0, utils_js_1.hasProp)(vikeConfigGlobal, prop, 'object') &&
|
|
1163
|
+
!(0, utils_js_1.hasProp)(vikeConfigGlobal, prop, 'boolean') &&
|
|
1164
|
+
!(0, utils_js_1.hasProp)(vikeConfigGlobal, prop, 'undefined'))
|
|
1165
|
+
return { prop, errMsg: 'should be an object or a boolean' };
|
|
1166
|
+
}
|
|
1167
|
+
const configVikePrerender = vikeConfigGlobal.prerender;
|
|
1168
|
+
if (typeof configVikePrerender === 'object') {
|
|
1169
|
+
{
|
|
1170
|
+
const p = 'partial';
|
|
1171
|
+
if (!(0, utils_js_1.hasProp)(configVikePrerender, p, 'boolean') && !(0, utils_js_1.hasProp)(configVikePrerender, p, 'undefined'))
|
|
1172
|
+
return { prop: `prerender.${p}`, errMsg: 'should be a boolean' };
|
|
1173
|
+
}
|
|
1174
|
+
{
|
|
1175
|
+
const p = 'noExtraDir';
|
|
1176
|
+
if (!(0, utils_js_1.hasProp)(configVikePrerender, p, 'boolean') && !(0, utils_js_1.hasProp)(configVikePrerender, p, 'undefined'))
|
|
1177
|
+
return { prop: `prerender.${p}`, errMsg: 'should be a boolean' };
|
|
1178
|
+
}
|
|
1179
|
+
{
|
|
1180
|
+
const p = 'disableAutoRun';
|
|
1181
|
+
if (!(0, utils_js_1.hasProp)(configVikePrerender, p, 'boolean') && !(0, utils_js_1.hasProp)(configVikePrerender, p, 'undefined'))
|
|
1182
|
+
return { prop: `prerender.${p}`, errMsg: 'should be a boolean' };
|
|
1183
|
+
}
|
|
1184
|
+
{
|
|
1185
|
+
const p = 'parallel';
|
|
1186
|
+
if (!(0, utils_js_1.hasProp)(configVikePrerender, p, 'boolean') &&
|
|
1187
|
+
!(0, utils_js_1.hasProp)(configVikePrerender, p, 'number') &&
|
|
1188
|
+
!(0, utils_js_1.hasProp)(configVikePrerender, p, 'undefined'))
|
|
1189
|
+
return { prop: `prerender.${p}`, errMsg: 'should be a boolean or a number' };
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
return null;
|
|
1193
|
+
}
|
|
@@ -7,7 +7,8 @@ const getVikeConfig_js_1 = require("./getVikeConfig.js");
|
|
|
7
7
|
const isRuntimeEnvMatch_js_1 = require("./isRuntimeEnvMatch.js");
|
|
8
8
|
const serializeConfigValues_js_1 = require("../../../../../shared/page-configs/serialize/serializeConfigValues.js");
|
|
9
9
|
async function getVirtualFilePageConfigs(isForClientSide, isDev, id, isClientRouting, config) {
|
|
10
|
-
const
|
|
10
|
+
const vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig)(config, { doNotRestartViteOnError: true });
|
|
11
|
+
const { pageConfigs, pageConfigGlobal } = vikeConfig;
|
|
11
12
|
return getCode(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isClientRouting);
|
|
12
13
|
}
|
|
13
14
|
function getCode(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isClientRouting) {
|
|
@@ -35,7 +35,7 @@ function setGlobalContext() {
|
|
|
35
35
|
order: 'post',
|
|
36
36
|
async handler(config) {
|
|
37
37
|
const { outDirRoot } = (0, utils_js_1.getOutDirs)(config);
|
|
38
|
-
(0, utils_js_1.assertFilePathAbsoluteFilesystem)(outDirRoot); // Needed for
|
|
38
|
+
(0, utils_js_1.assertFilePathAbsoluteFilesystem)(outDirRoot); // Needed for `importServerProductionEntry({ outDir })` of @brillout/vite-plugin-server-entry
|
|
39
39
|
(0, globalContext_js_1.setGlobalContext_viteConfig)(config, outDirRoot);
|
|
40
40
|
const vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig)(config);
|
|
41
41
|
(0, globalContext_js_1.setGlobalContext_vikeConfig)(vikeConfig);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.workaroundVite6HmrRegression = workaroundVite6HmrRegression;
|
|
4
4
|
// https://vite.dev/guide/migration (will be 404 after vite@7 release) > search for `hmrReload()`
|
|
5
5
|
// https://v6.vite.dev/guide/migration (will exist after vite@7 release) > search for `hmrReload()`
|
|
6
6
|
// Workaround seems to work for docs page /banner (which is HTML-only)
|
|
7
7
|
// 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`)
|
|
8
|
-
function
|
|
8
|
+
function workaroundVite6HmrRegression() {
|
|
9
9
|
return {
|
|
10
|
-
name: 'vike:
|
|
10
|
+
name: 'vike:workaroundVite6HmrRegression',
|
|
11
11
|
enforce: 'post',
|
|
12
12
|
hotUpdate: {
|
|
13
13
|
order: 'post',
|
|
@@ -18,13 +18,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
18
18
|
}) : function(o, v) {
|
|
19
19
|
o["default"] = v;
|
|
20
20
|
});
|
|
21
|
-
var __importStar = (this && this.__importStar) || function (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
39
|
exports.getHttpRequestAsyncStore = getHttpRequestAsyncStore;
|
|
30
40
|
exports.installHttpRequestAsyncStore = installHttpRequestAsyncStore;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isPrerenderEnabled = isPrerenderEnabled;
|
|
4
|
+
function isPrerenderEnabled(vikeConfigGlobal) {
|
|
5
|
+
return (vikeConfigGlobal.prerender &&
|
|
6
|
+
!vikeConfigGlobal.prerender.disableAutoRun &&
|
|
7
|
+
vikeConfigGlobal.disableAutoFullBuild !== 'prerender');
|
|
8
|
+
}
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
@@ -30,7 +40,6 @@ exports.runPrerenderFromAPI = runPrerenderFromAPI;
|
|
|
30
40
|
exports.runPrerenderFromCLIPrerenderCommand = runPrerenderFromCLIPrerenderCommand;
|
|
31
41
|
exports.runPrerenderFromAutoRun = runPrerenderFromAutoRun;
|
|
32
42
|
exports.runPrerender_forceExit = runPrerender_forceExit;
|
|
33
|
-
require("../runtime/page-files/setup.js");
|
|
34
43
|
const path_1 = __importDefault(require("path"));
|
|
35
44
|
const index_js_1 = require("../../shared/route/index.js");
|
|
36
45
|
const utils_js_1 = require("./utils.js");
|
|
@@ -43,7 +52,7 @@ const getPageFiles_js_1 = require("../../shared/getPageFiles.js");
|
|
|
43
52
|
const getPageContextRequestUrl_js_1 = require("../../shared/getPageContextRequestUrl.js");
|
|
44
53
|
const resolveRouteString_js_1 = require("../../shared/route/resolveRouteString.js");
|
|
45
54
|
const helpers_js_1 = require("../../shared/page-configs/helpers.js");
|
|
46
|
-
const
|
|
55
|
+
const getConfigValueRuntime_js_1 = require("../../shared/page-configs/getConfigValueRuntime.js");
|
|
47
56
|
const loadConfigValues_js_1 = require("../../shared/page-configs/loadConfigValues.js");
|
|
48
57
|
const error_page_js_1 = require("../../shared/error-page.js");
|
|
49
58
|
const getPageContextUrlComputed_js_1 = require("../../shared/getPageContextUrlComputed.js");
|
|
@@ -96,7 +105,7 @@ async function runPrerender(options = {}, standaloneTrigger) {
|
|
|
96
105
|
console.log(`${picocolors_1.default.cyan(`vike v${utils_js_1.projectInfo.projectVersion}`)} ${picocolors_1.default.green('pre-rendering HTML...')}`);
|
|
97
106
|
}
|
|
98
107
|
await disableReactStreaming();
|
|
99
|
-
const viteConfig = await (0, vite_1.resolveConfig)(options.viteConfig || {}, '
|
|
108
|
+
const viteConfig = await (0, vite_1.resolveConfig)(options.viteConfig || {}, 'build', 'production');
|
|
100
109
|
assertLoadedConfig(viteConfig, options);
|
|
101
110
|
const vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig)(viteConfig);
|
|
102
111
|
const { outDirClient } = (0, utils_js_1.getOutDirs)(viteConfig);
|
|
@@ -506,10 +515,10 @@ async function routeAndPrerender(prerenderContext, concurrencyLimit, onComplete)
|
|
|
506
515
|
if (pageContext._pageConfigs.length > 0) {
|
|
507
516
|
const pageConfig = pageContext._pageConfigs.find((p) => p.pageId === pageId);
|
|
508
517
|
(0, utils_js_1.assert)(pageConfig);
|
|
509
|
-
usesClientRouter = (0,
|
|
518
|
+
usesClientRouter = (0, getConfigValueRuntime_js_1.getConfigValueRuntime)(pageConfig, 'clientRouting', 'boolean')?.value ?? false;
|
|
510
519
|
}
|
|
511
520
|
else {
|
|
512
|
-
usesClientRouter = globalContext.
|
|
521
|
+
usesClientRouter = globalContext.usesClientRouter;
|
|
513
522
|
}
|
|
514
523
|
}
|
|
515
524
|
(0, utils_js_1.objectAssign)(pageContext, {
|