vike 0.4.215 → 0.4.217-commit-99ea561
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 +2 -2
- package/dist/cjs/node/api/build.js +10 -3
- package/dist/cjs/node/api/context.js +8 -6
- package/dist/cjs/node/api/dev.js +7 -2
- package/dist/cjs/node/api/{prepareApiCall.js → prepareViteApiCall.js} +16 -6
- package/dist/cjs/node/api/prerender.js +7 -2
- package/dist/cjs/node/api/preview.js +7 -2
- package/dist/cjs/node/api/utils.js +1 -0
- package/dist/cjs/node/plugin/index.js +7 -10
- package/dist/cjs/node/plugin/onLoad.js +2 -2
- package/dist/cjs/node/plugin/plugins/autoFullBuild.js +15 -12
- package/dist/cjs/node/plugin/plugins/baseUrls.js +17 -12
- package/dist/cjs/node/plugin/plugins/buildConfig/fixServerAssets.js +1 -1
- package/dist/cjs/node/plugin/plugins/buildConfig.js +10 -10
- package/dist/cjs/node/plugin/plugins/commonConfig.js +35 -4
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +5 -5
- package/dist/cjs/node/plugin/plugins/devConfig/index.js +1 -4
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +4 -7
- package/dist/cjs/node/plugin/plugins/importBuild/getVikeManifest.js +2 -2
- package/dist/cjs/node/plugin/plugins/importBuild/index.js +8 -6
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +8 -8
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +9 -13
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +23 -106
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveVikeConfigGlobal.js +128 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +42 -28
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +3 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +1 -1
- package/dist/cjs/node/plugin/plugins/previewConfig.js +4 -4
- package/dist/cjs/node/plugin/plugins/setGlobalContext.js +35 -17
- package/dist/cjs/node/prerender/runPrerender.js +5 -7
- package/dist/cjs/node/prerender/utils.js +1 -1
- package/dist/cjs/node/runtime/globalContext.js +21 -13
- package/dist/cjs/node/runtime/index-common.js +3 -1
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +1 -1
- package/dist/cjs/node/runtime/renderPage.js +4 -2
- package/dist/cjs/node/runtime/utils.js +1 -2
- package/dist/cjs/node/runtime-dev/createDevMiddleware.js +25 -0
- package/dist/cjs/node/runtime-dev/index.js +32 -0
- package/dist/cjs/node/shared/resolveBase.js +41 -0
- package/dist/cjs/shared/page-configs/getConfigValueBuildTime.js +2 -2
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +2 -2
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assertSetup.js +135 -0
- package/dist/cjs/utils/isDocker.js +2 -2
- package/dist/cjs/utils/requireResolve.js +2 -2
- package/dist/esm/__internal/index.js +2 -2
- package/dist/esm/node/api/build.d.ts +5 -0
- package/dist/esm/node/api/build.js +10 -3
- package/dist/esm/node/api/context.js +9 -7
- package/dist/esm/node/api/dev.d.ts +5 -0
- package/dist/esm/node/api/dev.js +7 -2
- package/dist/esm/node/api/prepareViteApiCall.d.ts +7 -0
- package/dist/esm/node/api/{prepareApiCall.js → prepareViteApiCall.js} +16 -6
- package/dist/esm/node/api/prerender.d.ts +5 -0
- package/dist/esm/node/api/prerender.js +7 -2
- package/dist/esm/node/api/preview.d.ts +5 -0
- package/dist/esm/node/api/preview.js +7 -2
- package/dist/esm/node/api/utils.d.ts +1 -0
- package/dist/esm/node/api/utils.js +1 -0
- package/dist/esm/node/cli/parseCli.d.ts +1 -1
- package/dist/esm/node/plugin/index.d.ts +3 -3
- package/dist/esm/node/plugin/index.js +6 -9
- package/dist/esm/node/plugin/onLoad.js +1 -1
- package/dist/esm/node/plugin/plugins/autoFullBuild.js +15 -12
- package/dist/esm/node/plugin/plugins/baseUrls.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/baseUrls.js +17 -12
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.js +1 -1
- package/dist/esm/node/plugin/plugins/buildConfig.js +11 -11
- package/dist/esm/node/plugin/plugins/commonConfig.d.ts +7 -1
- package/dist/esm/node/plugin/plugins/commonConfig.js +36 -5
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +5 -5
- package/dist/esm/node/plugin/plugins/devConfig/index.js +2 -5
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +4 -7
- package/dist/esm/node/plugin/plugins/importBuild/getVikeManifest.d.ts +3 -2
- package/dist/esm/node/plugin/plugins/importBuild/getVikeManifest.js +2 -2
- package/dist/esm/node/plugin/plugins/importBuild/index.js +8 -6
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +8 -8
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +11 -15
- 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 -106
- package/dist/esm/{shared/ConfigVike.d.ts → node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveVikeConfigGlobal.d.ts} +14 -12
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveVikeConfigGlobal.js +123 -0
- 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 +43 -29
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +3 -4
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +1 -1
- package/dist/esm/node/plugin/plugins/previewConfig.js +5 -5
- package/dist/esm/node/plugin/plugins/setGlobalContext.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/setGlobalContext.js +37 -19
- package/dist/esm/node/plugin/shared/getEnvVarObject.d.ts +1 -1
- package/dist/esm/node/prerender/runPrerender.js +6 -8
- package/dist/esm/node/prerender/utils.d.ts +1 -1
- package/dist/esm/node/prerender/utils.js +1 -1
- package/dist/esm/node/runtime/globalContext.d.ts +8 -4
- package/dist/esm/node/runtime/globalContext.js +22 -14
- package/dist/esm/node/runtime/index-common.d.ts +1 -0
- package/dist/esm/node/runtime/index-common.js +1 -0
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +1 -1
- package/dist/esm/node/runtime/renderPage.js +5 -3
- package/dist/esm/node/runtime/utils.d.ts +1 -2
- package/dist/esm/node/runtime/utils.js +1 -2
- package/dist/esm/node/runtime-dev/createDevMiddleware.d.ts +10 -0
- package/dist/esm/node/runtime-dev/createDevMiddleware.js +23 -0
- package/dist/esm/node/runtime-dev/index.d.ts +3 -0
- package/dist/esm/node/runtime-dev/index.js +6 -0
- package/dist/esm/node/shared/resolveBase.d.ts +11 -0
- package/dist/esm/node/shared/resolveBase.js +36 -0
- package/dist/esm/shared/page-configs/Config.d.ts +2 -2
- package/dist/esm/shared/page-configs/getConfigValueBuildTime.js +1 -1
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +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/assertSetup.d.ts +20 -0
- package/dist/esm/utils/assertSetup.js +130 -0
- package/dist/esm/utils/isDocker.js +1 -1
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/dist/esm/utils/requireResolve.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/node/plugin/plugins/config/assertVikeConfig.js +0 -75
- package/dist/cjs/node/plugin/plugins/config/index.js +0 -81
- package/dist/cjs/node/plugin/plugins/config/pickFirst.js +0 -6
- package/dist/cjs/node/plugin/plugins/config/resolveBase.js +0 -47
- package/dist/cjs/node/shared/getConfigVike.js +0 -10
- package/dist/cjs/shared/ConfigVike.js +0 -2
- package/dist/cjs/utils/assertIsNotProductionRuntime.js +0 -62
- package/dist/cjs/utils/assertNodeEnv.js +0 -106
- package/dist/esm/node/api/prepareApiCall.d.ts +0 -7
- package/dist/esm/node/plugin/plugins/config/assertVikeConfig.d.ts +0 -7
- package/dist/esm/node/plugin/plugins/config/assertVikeConfig.js +0 -73
- package/dist/esm/node/plugin/plugins/config/index.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/config/index.js +0 -76
- package/dist/esm/node/plugin/plugins/config/pickFirst.d.ts +0 -1
- package/dist/esm/node/plugin/plugins/config/pickFirst.js +0 -3
- package/dist/esm/node/plugin/plugins/config/resolveBase.d.ts +0 -10
- package/dist/esm/node/plugin/plugins/config/resolveBase.js +0 -42
- package/dist/esm/node/shared/getConfigVike.d.ts +0 -4
- package/dist/esm/node/shared/getConfigVike.js +0 -8
- package/dist/esm/shared/ConfigVike.js +0 -1
- package/dist/esm/utils/assertIsNotProductionRuntime.d.ts +0 -12
- package/dist/esm/utils/assertIsNotProductionRuntime.js +0 -59
- package/dist/esm/utils/assertNodeEnv.d.ts +0 -10
- package/dist/esm/utils/assertNodeEnv.js +0 -103
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
export { crawlPlusFiles };
|
|
2
2
|
import { assertPosixPath, assert, scriptFileExtensions, assertIsSingleModuleInstance, assertIsNotProductionRuntime, isVersionOrAbove, isScriptFile } 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
|
-
|
|
17
|
-
|
|
15
|
+
//*/
|
|
16
|
+
const outDirRelativeFromUserRootDir = null;
|
|
17
|
+
/*/
|
|
18
|
+
assertPosixPath(outDirAbsoluteFilesystem)
|
|
19
|
+
let outDirRelativeFromUserRootDir: string | null = path.posix.relative(userRootDir, outDirAbsoluteFilesystem)
|
|
18
20
|
if (outDirRelativeFromUserRootDir.startsWith('../')) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
// config.outDir is outside of config.root => it's going to be ignored anyways
|
|
22
|
+
outDirRelativeFromUserRootDir = null
|
|
21
23
|
}
|
|
24
|
+
//*/
|
|
22
25
|
assert(outDirRelativeFromUserRootDir === null ||
|
|
23
26
|
/* Not true if outDirRelativeFromUserRootDir starts with a hidden directory (i.e. a directory with a name that starts with `.`)
|
|
24
27
|
!outDirRelativeFromUserRootDir.startsWith('.') &&
|
|
@@ -27,14 +30,13 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, crawlWithGi
|
|
|
27
30
|
//
|
|
28
31
|
!outDirRelativeFromUserRootDir.startsWith('../')));
|
|
29
32
|
// Crawl
|
|
30
|
-
let files
|
|
31
|
-
const res =
|
|
33
|
+
let files;
|
|
34
|
+
const res = !isGitCrawlDisabled() && (await gitLsFiles(userRootDir, outDirRelativeFromUserRootDir));
|
|
32
35
|
if (res &&
|
|
33
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.)
|
|
34
|
-
res.
|
|
35
|
-
files = res
|
|
37
|
+
res.length > 0) {
|
|
38
|
+
files = res;
|
|
36
39
|
// We cannot find files inside symlink directories with `$ git ls-files` => we use fast-glob
|
|
37
|
-
files.push(...(await crawlSymlinkDirs(res.symlinkDirs, userRootDir, outDirRelativeFromUserRootDir)));
|
|
38
40
|
}
|
|
39
41
|
else {
|
|
40
42
|
files = await fastGlob(userRootDir, outDirRelativeFromUserRootDir);
|
|
@@ -76,14 +78,13 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
76
78
|
...ignoreAsPatterns.map((pattern) => `--exclude="${pattern}"`),
|
|
77
79
|
// --others --exclude-standard => list untracked files (--others) while using .gitignore (--exclude-standard)
|
|
78
80
|
// --cached => list tracked files
|
|
79
|
-
|
|
80
|
-
'--others --exclude-standard --cached --stage'
|
|
81
|
+
'--others --exclude-standard --cached'
|
|
81
82
|
].join(' ');
|
|
82
|
-
let
|
|
83
|
+
let filesAll;
|
|
83
84
|
let filesDeleted;
|
|
84
85
|
try {
|
|
85
86
|
;
|
|
86
|
-
[
|
|
87
|
+
[filesAll, filesDeleted] = await Promise.all([
|
|
87
88
|
// Main command
|
|
88
89
|
runCmd1(cmd, userRootDir),
|
|
89
90
|
// Get tracked but deleted files
|
|
@@ -97,31 +98,14 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
97
98
|
}
|
|
98
99
|
throw err;
|
|
99
100
|
}
|
|
100
|
-
const filePaths = resultLines.map(parseGitLsResultLine);
|
|
101
|
-
// If there are too many files without mode we fallback to fast-glob
|
|
102
|
-
if (filePaths.filter((f) => !f.mode).length > TOO_MANY_UNTRACKED_FILES)
|
|
103
|
-
return null;
|
|
104
|
-
const symlinkDirs = [];
|
|
105
101
|
const files = [];
|
|
106
|
-
for (const
|
|
102
|
+
for (const filePath of filesAll) {
|
|
107
103
|
// Deleted?
|
|
108
104
|
if (filesDeleted.includes(filePath))
|
|
109
105
|
continue;
|
|
110
106
|
// 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.)
|
|
111
107
|
if (!ignoreAsFilterFn(filePath))
|
|
112
108
|
continue;
|
|
113
|
-
// Symlink directory?
|
|
114
|
-
{
|
|
115
|
-
const isSymlinkDir = await isSymlinkDirectory(mode, filePath, userRootDir);
|
|
116
|
-
if (isSymlinkDir) {
|
|
117
|
-
symlinkDirs.push(filePath);
|
|
118
|
-
continue;
|
|
119
|
-
}
|
|
120
|
-
// Skip deleted files and non-symlink directories
|
|
121
|
-
if (isSymlinkDir === null) {
|
|
122
|
-
continue;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
109
|
// + file?
|
|
126
110
|
if (!path.posix.basename(filePath).startsWith('+'))
|
|
127
111
|
continue;
|
|
@@ -130,7 +114,7 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
130
114
|
continue;
|
|
131
115
|
files.push(filePath);
|
|
132
116
|
}
|
|
133
|
-
return
|
|
117
|
+
return files;
|
|
134
118
|
}
|
|
135
119
|
// Same as gitLsFiles() but using fast-glob
|
|
136
120
|
async function fastGlob(userRootDir, outDirRelativeFromUserRootDir) {
|
|
@@ -200,77 +184,6 @@ async function isGitNotUsable(userRootDir) {
|
|
|
200
184
|
return false;
|
|
201
185
|
}
|
|
202
186
|
}
|
|
203
|
-
async function crawlSymlinkDirs(symlinkDirs, userRootDir, outDirRelativeFromUserRootDir) {
|
|
204
|
-
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();
|
|
205
|
-
return filesInSymlinkDirs;
|
|
206
|
-
}
|
|
207
|
-
// Parse:
|
|
208
|
-
// ```
|
|
209
|
-
// some/not/tracked/path
|
|
210
|
-
// 100644 f6928073402b241b468b199893ff6f4aed0b7195 0\tpages/index/+Page.tsx
|
|
211
|
-
// ```
|
|
212
|
-
function parseGitLsResultLine(resultLine) {
|
|
213
|
-
const [part1, part2, ...rest] = resultLine.split('\t');
|
|
214
|
-
assert(part1);
|
|
215
|
-
assert(rest.length === 0);
|
|
216
|
-
// Git doesn't provide the mode for untracked paths.
|
|
217
|
-
// `resultLine` is:
|
|
218
|
-
// ```
|
|
219
|
-
// some/not/tracked/path
|
|
220
|
-
// ```
|
|
221
|
-
if (part2 === undefined) {
|
|
222
|
-
return { filePath: part1, mode: null };
|
|
223
|
-
}
|
|
224
|
-
assert(part2);
|
|
225
|
-
// `resultLine` is:
|
|
226
|
-
// ```
|
|
227
|
-
// 100644 f6928073402b241b468b199893ff6f4aed0b7195 0\tpages/index/+Page.tsx
|
|
228
|
-
// ```
|
|
229
|
-
const [mode, _, __, ...rest2] = part1.split(' ');
|
|
230
|
-
assert(mode && _ && __ && rest2.length === 0);
|
|
231
|
-
return { filePath: part2, mode };
|
|
232
|
-
}
|
|
233
|
-
async function isSymlinkDirectory(mode, filePath, userRootDir) {
|
|
234
|
-
const filePathAbsolute = path.posix.join(userRootDir, filePath);
|
|
235
|
-
let stats = null;
|
|
236
|
-
let isSymlink = false;
|
|
237
|
-
if (mode === '120000') {
|
|
238
|
-
isSymlink = true;
|
|
239
|
-
}
|
|
240
|
-
else if (mode === null) {
|
|
241
|
-
// `$ git ls-files` doesn't provide the mode when Git doesn't track the path
|
|
242
|
-
stats = await getFileStats(filePathAbsolute);
|
|
243
|
-
if (stats === null)
|
|
244
|
-
return null;
|
|
245
|
-
isSymlink = stats.isSymbolicLink();
|
|
246
|
-
if (!isSymlink && stats.isDirectory())
|
|
247
|
-
return null;
|
|
248
|
-
}
|
|
249
|
-
else {
|
|
250
|
-
assert(mode);
|
|
251
|
-
}
|
|
252
|
-
if (!isSymlink)
|
|
253
|
-
return false;
|
|
254
|
-
if (!stats)
|
|
255
|
-
stats = await getFileStats(filePathAbsolute);
|
|
256
|
-
if (stats === null)
|
|
257
|
-
return null;
|
|
258
|
-
const isDirectory = stats.isDirectory();
|
|
259
|
-
return isDirectory;
|
|
260
|
-
}
|
|
261
|
-
async function getFileStats(filePathAbsolute) {
|
|
262
|
-
let stats;
|
|
263
|
-
try {
|
|
264
|
-
stats = await fs.lstat(filePathAbsolute);
|
|
265
|
-
}
|
|
266
|
-
catch (err) {
|
|
267
|
-
// File was deleted, usually a temporary file such as +config.js.build-j95xb988fpln.mjs
|
|
268
|
-
// ENOENT: no such file or directory
|
|
269
|
-
assert(err.code === 'ENOENT');
|
|
270
|
-
return null;
|
|
271
|
-
}
|
|
272
|
-
return stats;
|
|
273
|
-
}
|
|
274
187
|
async function runCmd1(cmd, cwd) {
|
|
275
188
|
const { stdout } = await execA(cmd, {
|
|
276
189
|
cwd,
|
|
@@ -295,3 +208,7 @@ async function runCmd2(cmd, cwd) {
|
|
|
295
208
|
stderr = stderr.toString().trim();
|
|
296
209
|
return { stdout, stderr };
|
|
297
210
|
}
|
|
211
|
+
function isGitCrawlDisabled() {
|
|
212
|
+
const crawSettings = getEnvVarObject('VIKE_CRAWL');
|
|
213
|
+
return crawSettings?.git === false;
|
|
214
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
export
|
|
2
|
-
export type {
|
|
3
|
-
type
|
|
1
|
+
export { resolveVikeConfigGlobal };
|
|
2
|
+
export type { VikeConfigGlobal };
|
|
3
|
+
export type { VikeVitePluginOptions };
|
|
4
|
+
declare function resolveVikeConfigGlobal(vikeVitePluginOptions: unknown, pageConfigGlobalValues: Record<string, unknown>): VikeConfigGlobal;
|
|
5
|
+
type VikeConfigGlobal = {
|
|
4
6
|
prerender: false | {
|
|
5
7
|
noExtraDir: boolean;
|
|
6
8
|
parallel: boolean | number;
|
|
@@ -9,8 +11,8 @@ type ConfigVikeResolved = {
|
|
|
9
11
|
};
|
|
10
12
|
disableAutoFullBuild: boolean | 'prerender' | null;
|
|
11
13
|
includeAssetsImportedByServer: boolean;
|
|
12
|
-
baseAssets: string;
|
|
13
|
-
baseServer: string;
|
|
14
|
+
baseAssets: string | null;
|
|
15
|
+
baseServer: string | null;
|
|
14
16
|
redirects: Record<string, string>;
|
|
15
17
|
trailingSlash: boolean;
|
|
16
18
|
disableUrlNormalization: boolean;
|
|
@@ -18,7 +20,7 @@ type ConfigVikeResolved = {
|
|
|
18
20
|
git: null | boolean;
|
|
19
21
|
};
|
|
20
22
|
};
|
|
21
|
-
type
|
|
23
|
+
type VikeVitePluginOptions = {
|
|
22
24
|
/**
|
|
23
25
|
* Enable pre-rendering.
|
|
24
26
|
*
|
|
@@ -44,12 +46,12 @@ type ConfigVikeUserProvided = {
|
|
|
44
46
|
*/
|
|
45
47
|
parallel?: boolean | number;
|
|
46
48
|
/**
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
* Allow only some of your pages to be pre-rendered.
|
|
50
|
+
*
|
|
51
|
+
* This setting doesn't affect the pre-rendering process: it merely suppresses the warnings when some of your pages cannot be pre-rendered.
|
|
52
|
+
|
|
53
|
+
* @default false
|
|
54
|
+
*/
|
|
53
55
|
partial?: boolean;
|
|
54
56
|
/**
|
|
55
57
|
* Disable the automatic initiation of the pre-rendering process when running `$ vike build`.
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
export { resolveVikeConfigGlobal };
|
|
2
|
+
import pc from '@brillout/picocolors';
|
|
3
|
+
import { assert, assertUsage, hasProp, isObject } from '../../../../utils.js';
|
|
4
|
+
function resolveVikeConfigGlobal(vikeVitePluginOptions, pageConfigGlobalValues) {
|
|
5
|
+
// TODO/v1-release: remove
|
|
6
|
+
assertVikeConfigGlobal(vikeVitePluginOptions, ({ prop, errMsg }) => `vite.config.js > vike option ${prop} ${errMsg}`);
|
|
7
|
+
const configs = [vikeVitePluginOptions];
|
|
8
|
+
assertVikeConfigGlobal(pageConfigGlobalValues, ({ prop, errMsg }) => {
|
|
9
|
+
// Can we add the config file path ?
|
|
10
|
+
return `config ${pc.cyan(prop)} ${errMsg}`;
|
|
11
|
+
});
|
|
12
|
+
configs.push(pageConfigGlobalValues);
|
|
13
|
+
const vikeConfigGlobal = {
|
|
14
|
+
disableAutoFullBuild: pickFirst(configs.map((c) => c.disableAutoFullBuild)) ?? null,
|
|
15
|
+
prerender: resolvePrerenderOptions(configs),
|
|
16
|
+
includeAssetsImportedByServer: pickFirst(configs.map((c) => c.includeAssetsImportedByServer)) ?? true,
|
|
17
|
+
baseServer: pickFirst(configs.map((c) => c.baseServer)) ?? null,
|
|
18
|
+
baseAssets: pickFirst(configs.map((c) => c.baseAssets)) ?? null,
|
|
19
|
+
redirects: merge(configs.map((c) => c.redirects)) ?? {},
|
|
20
|
+
disableUrlNormalization: pickFirst(configs.map((c) => c.disableUrlNormalization)) ?? false,
|
|
21
|
+
trailingSlash: pickFirst(configs.map((c) => c.trailingSlash)) ?? false,
|
|
22
|
+
crawl: {
|
|
23
|
+
git: vikeVitePluginOptions.crawl?.git ?? null
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
return vikeConfigGlobal;
|
|
27
|
+
}
|
|
28
|
+
function resolvePrerenderOptions(configs) {
|
|
29
|
+
if (!configs.some((c) => c.prerender)) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
const configsPrerender = configs.map((c) => c.prerender).filter(isObject2);
|
|
33
|
+
return {
|
|
34
|
+
partial: pickFirst(configsPrerender.map((c) => c.partial)) ?? false,
|
|
35
|
+
noExtraDir: pickFirst(configsPrerender.map((c) => c.noExtraDir)) ?? false,
|
|
36
|
+
parallel: pickFirst(configsPrerender.map((c) => c.parallel)) ?? true,
|
|
37
|
+
disableAutoRun: pickFirst(configsPrerender.map((c) => c.disableAutoRun)) ?? false
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function isObject2(p) {
|
|
41
|
+
return typeof p === 'object';
|
|
42
|
+
}
|
|
43
|
+
function merge(objs) {
|
|
44
|
+
const obj = {};
|
|
45
|
+
objs.forEach((e) => {
|
|
46
|
+
Object.assign(obj, e);
|
|
47
|
+
});
|
|
48
|
+
return obj;
|
|
49
|
+
}
|
|
50
|
+
function pickFirst(arr) {
|
|
51
|
+
return arr.filter((v) => v !== undefined)[0];
|
|
52
|
+
}
|
|
53
|
+
function assertVikeConfigGlobal(vikeConfigGlobal, wrongUsageMsg) {
|
|
54
|
+
const wrongUsageError = check(vikeConfigGlobal);
|
|
55
|
+
if (wrongUsageError) {
|
|
56
|
+
assertUsage(false, wrongUsageMsg(wrongUsageError));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function check(vikeConfigGlobal) {
|
|
60
|
+
assert(isObject(vikeConfigGlobal));
|
|
61
|
+
{
|
|
62
|
+
const prop = 'disableUrlNormalization';
|
|
63
|
+
if (!hasProp(vikeConfigGlobal, prop, 'boolean') && !hasProp(vikeConfigGlobal, prop, 'undefined'))
|
|
64
|
+
return { prop, errMsg: 'should be a boolean' };
|
|
65
|
+
}
|
|
66
|
+
{
|
|
67
|
+
const prop = 'trailingSlash';
|
|
68
|
+
if (!hasProp(vikeConfigGlobal, prop, 'boolean') && !hasProp(vikeConfigGlobal, prop, 'undefined'))
|
|
69
|
+
return { prop, errMsg: 'should be a boolean' };
|
|
70
|
+
}
|
|
71
|
+
{
|
|
72
|
+
const prop = 'redirects';
|
|
73
|
+
const { redirects } = vikeConfigGlobal;
|
|
74
|
+
if (!(redirects === undefined ||
|
|
75
|
+
(isObject(redirects) && Object.values(redirects).every((v) => typeof v === 'string'))))
|
|
76
|
+
return { prop, errMsg: 'should be an object of strings' };
|
|
77
|
+
}
|
|
78
|
+
{
|
|
79
|
+
const prop = 'disableAutoFullBuild';
|
|
80
|
+
if (!hasProp(vikeConfigGlobal, prop, 'boolean') &&
|
|
81
|
+
!hasProp(vikeConfigGlobal, prop, 'undefined') &&
|
|
82
|
+
!(vikeConfigGlobal[prop] === 'prerender'))
|
|
83
|
+
return { prop, errMsg: "should be a boolean or 'prerender'" };
|
|
84
|
+
}
|
|
85
|
+
{
|
|
86
|
+
const prop = 'includeAssetsImportedByServer';
|
|
87
|
+
if (!hasProp(vikeConfigGlobal, prop, 'boolean') && !hasProp(vikeConfigGlobal, prop, 'undefined'))
|
|
88
|
+
return { prop, errMsg: 'should be a boolean' };
|
|
89
|
+
}
|
|
90
|
+
{
|
|
91
|
+
const prop = 'prerender';
|
|
92
|
+
if (!hasProp(vikeConfigGlobal, prop, 'object') &&
|
|
93
|
+
!hasProp(vikeConfigGlobal, prop, 'boolean') &&
|
|
94
|
+
!hasProp(vikeConfigGlobal, prop, 'undefined'))
|
|
95
|
+
return { prop, errMsg: 'should be an object or a boolean' };
|
|
96
|
+
}
|
|
97
|
+
const configVikePrerender = vikeConfigGlobal.prerender;
|
|
98
|
+
if (typeof configVikePrerender === 'object') {
|
|
99
|
+
{
|
|
100
|
+
const p = 'partial';
|
|
101
|
+
if (!hasProp(configVikePrerender, p, 'boolean') && !hasProp(configVikePrerender, p, 'undefined'))
|
|
102
|
+
return { prop: `prerender.${p}`, errMsg: 'should be a boolean' };
|
|
103
|
+
}
|
|
104
|
+
{
|
|
105
|
+
const p = 'noExtraDir';
|
|
106
|
+
if (!hasProp(configVikePrerender, p, 'boolean') && !hasProp(configVikePrerender, p, 'undefined'))
|
|
107
|
+
return { prop: `prerender.${p}`, errMsg: 'should be a boolean' };
|
|
108
|
+
}
|
|
109
|
+
{
|
|
110
|
+
const p = 'disableAutoRun';
|
|
111
|
+
if (!hasProp(configVikePrerender, p, 'boolean') && !hasProp(configVikePrerender, p, 'undefined'))
|
|
112
|
+
return { prop: `prerender.${p}`, errMsg: 'should be a boolean' };
|
|
113
|
+
}
|
|
114
|
+
{
|
|
115
|
+
const p = 'parallel';
|
|
116
|
+
if (!hasProp(configVikePrerender, p, 'boolean') &&
|
|
117
|
+
!hasProp(configVikePrerender, p, 'number') &&
|
|
118
|
+
!hasProp(configVikePrerender, p, 'undefined'))
|
|
119
|
+
return { prop: `prerender.${p}`, errMsg: 'should be a boolean or a number' };
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { getVikeConfig };
|
|
2
|
+
export { getVikeConfig2 };
|
|
2
3
|
export { reloadVikeConfig };
|
|
3
4
|
export { vikeConfigDependencies };
|
|
4
5
|
export { isVikeConfigFile };
|
|
@@ -11,6 +12,7 @@ import type { PageConfigGlobalBuildTime, PageConfigBuildTime } from '../../../..
|
|
|
11
12
|
import { type LocationId } from './getVikeConfig/filesystemRouting.js';
|
|
12
13
|
import type { ResolvedConfig } from 'vite';
|
|
13
14
|
import type { FilePathResolved } from '../../../../../shared/page-configs/FilePath.js';
|
|
15
|
+
import type { VikeConfigGlobal } from './getVikeConfig/resolveVikeConfigGlobal.js';
|
|
14
16
|
type InterfaceFile = InterfaceConfigFile | InterfaceValueFile;
|
|
15
17
|
type InterfaceFileCommons = {
|
|
16
18
|
locationId: LocationId;
|
|
@@ -34,14 +36,14 @@ type ConfigName = string;
|
|
|
34
36
|
type VikeConfigObject = {
|
|
35
37
|
pageConfigs: PageConfigBuildTime[];
|
|
36
38
|
pageConfigGlobal: PageConfigGlobalBuildTime;
|
|
37
|
-
|
|
39
|
+
vikeConfigGlobal: VikeConfigGlobal;
|
|
38
40
|
};
|
|
39
41
|
declare const vikeConfigDependencies: Set<string>;
|
|
40
|
-
declare function reloadVikeConfig(
|
|
41
|
-
declare function getVikeConfig(config: ResolvedConfig,
|
|
42
|
-
|
|
43
|
-
tolerateInvalidConfig?: true;
|
|
42
|
+
declare function reloadVikeConfig(config: ResolvedConfig): void;
|
|
43
|
+
declare function getVikeConfig(config: ResolvedConfig, { doNotRestartViteOnError }?: {
|
|
44
|
+
doNotRestartViteOnError?: true;
|
|
44
45
|
}): Promise<VikeConfigObject>;
|
|
45
|
-
declare function
|
|
46
|
+
declare function getVikeConfig2(userRootDir: string, isDev: boolean, vikeVitePluginOptions: unknown): Promise<VikeConfigObject>;
|
|
47
|
+
declare function isV1Design(config: ResolvedConfig): Promise<boolean>;
|
|
46
48
|
declare function isVikeConfigFile(filePath: string): boolean;
|
|
47
49
|
declare function getConfigValueInterfaceFile(interfaceFile: InterfaceFile, configName: string): unknown;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { getVikeConfig };
|
|
2
|
+
export { getVikeConfig2 };
|
|
2
3
|
export { reloadVikeConfig };
|
|
3
4
|
export { vikeConfigDependencies };
|
|
4
5
|
export { isVikeConfigFile };
|
|
5
6
|
export { isV1Design };
|
|
6
7
|
export { getConfigValueInterfaceFile };
|
|
7
|
-
import { assertPosixPath, assert, isObject, assertUsage, assertWarning, objectEntries, hasProp, includes, assertIsNotProductionRuntime, getMostSimilar, joinEnglish, lowerFirst,
|
|
8
|
+
import { assertPosixPath, assert, isObject, assertUsage, assertWarning, objectEntries, hasProp, includes, assertIsNotProductionRuntime, getMostSimilar, joinEnglish, lowerFirst, assertKeys, objectKeys, objectFromEntries, makeFirst, isNpmPackageImport, reverse } from '../../../utils.js';
|
|
8
9
|
import path from 'path';
|
|
9
10
|
import { configDefinitionsBuiltIn, configDefinitionsBuiltInGlobal } from './getVikeConfig/configDefinitionsBuiltIn.js';
|
|
10
11
|
import { getLocationId, getFilesystemRouteString, getFilesystemRouteDefinedBy, isInherited, sortAfterInheritanceOrder, isGlobalLocation, applyFilesystemRoutingRootEffect } from './getVikeConfig/filesystemRouting.js';
|
|
@@ -21,17 +22,20 @@ import { loadConfigFile, loadImportedFile, loadValueFile } from './getVikeConfig
|
|
|
21
22
|
import { clearFilesEnvMap, resolveConfigEnvWithFileName, resolvePointerImportOfConfig } from './getVikeConfig/resolvePointerImport.js';
|
|
22
23
|
import { getFilePathResolved } from '../../../shared/getFilePath.js';
|
|
23
24
|
import { getConfigValueBuildTime } from '../../../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
24
|
-
import { getConfigVike } from '../../../../shared/getConfigVike.js';
|
|
25
25
|
import { assertExtensionsPeerDependencies, assertExtensionsConventions } from './assertExtensions.js';
|
|
26
|
+
import { resolveVikeConfigGlobal } from './getVikeConfig/resolveVikeConfigGlobal.js';
|
|
26
27
|
assertIsNotProductionRuntime();
|
|
27
|
-
let
|
|
28
|
+
let restartVite = false;
|
|
28
29
|
let wasConfigInvalid = null;
|
|
29
30
|
let vikeConfigPromise = null;
|
|
30
31
|
const vikeConfigDependencies = new Set();
|
|
31
|
-
function reloadVikeConfig(
|
|
32
|
+
function reloadVikeConfig(config) {
|
|
33
|
+
const userRootDir = config.root;
|
|
34
|
+
const vikeVitePluginOptions = config._vikeVitePluginOptions;
|
|
35
|
+
assert(vikeVitePluginOptions);
|
|
32
36
|
vikeConfigDependencies.clear();
|
|
33
37
|
clearFilesEnvMap();
|
|
34
|
-
vikeConfigPromise = loadVikeConfig_withErrorHandling(userRootDir,
|
|
38
|
+
vikeConfigPromise = loadVikeConfig_withErrorHandling(userRootDir, true, vikeVitePluginOptions);
|
|
35
39
|
handleReloadSideEffects();
|
|
36
40
|
}
|
|
37
41
|
async function handleReloadSideEffects() {
|
|
@@ -55,8 +59,8 @@ async function handleReloadSideEffects() {
|
|
|
55
59
|
wasConfigInvalid = false;
|
|
56
60
|
logConfigErrorRecover();
|
|
57
61
|
}
|
|
58
|
-
if (
|
|
59
|
-
|
|
62
|
+
if (restartVite) {
|
|
63
|
+
restartVite = false;
|
|
60
64
|
const viteDevServer = getViteDevServer();
|
|
61
65
|
assert(viteDevServer);
|
|
62
66
|
removeSuperfluousViteLog_enable();
|
|
@@ -65,23 +69,32 @@ async function handleReloadSideEffects() {
|
|
|
65
69
|
}
|
|
66
70
|
}
|
|
67
71
|
}
|
|
68
|
-
async function getVikeConfig(config,
|
|
69
|
-
const { outDirRoot } = getOutDirs(config);
|
|
72
|
+
async function getVikeConfig(config, { doNotRestartViteOnError } = {}) {
|
|
70
73
|
const userRootDir = config.root;
|
|
74
|
+
const vikeVitePluginOptions = config._vikeVitePluginOptions;
|
|
75
|
+
assert(vikeVitePluginOptions);
|
|
76
|
+
const isDev = config._isDev;
|
|
77
|
+
assert(typeof isDev === 'boolean');
|
|
78
|
+
return await getVikeConfigEntry(userRootDir, isDev, vikeVitePluginOptions, doNotRestartViteOnError ?? false);
|
|
79
|
+
}
|
|
80
|
+
async function getVikeConfig2(userRootDir, isDev, vikeVitePluginOptions) {
|
|
81
|
+
assert(vikeVitePluginOptions);
|
|
82
|
+
return await getVikeConfigEntry(userRootDir, isDev, vikeVitePluginOptions, false);
|
|
83
|
+
}
|
|
84
|
+
async function getVikeConfigEntry(userRootDir, isDev, vikeVitePluginOptions, doNotRestartViteOnError) {
|
|
71
85
|
if (!vikeConfigPromise) {
|
|
72
|
-
|
|
73
|
-
vikeConfigPromise = loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev, crawlWithGit_, tolerateInvalidConfig);
|
|
86
|
+
vikeConfigPromise = loadVikeConfig_withErrorHandling(userRootDir, isDev, vikeVitePluginOptions, doNotRestartViteOnError);
|
|
74
87
|
}
|
|
75
88
|
return await vikeConfigPromise;
|
|
76
89
|
}
|
|
77
|
-
async function isV1Design(config
|
|
78
|
-
const vikeConfig = await getVikeConfig(config
|
|
90
|
+
async function isV1Design(config) {
|
|
91
|
+
const vikeConfig = await getVikeConfig(config);
|
|
79
92
|
const { pageConfigs } = vikeConfig;
|
|
80
93
|
const isV1Design = pageConfigs.length > 0;
|
|
81
94
|
return isV1Design;
|
|
82
95
|
}
|
|
83
|
-
async function loadInterfaceFiles(userRootDir
|
|
84
|
-
const plusFiles = await findPlusFiles(userRootDir,
|
|
96
|
+
async function loadInterfaceFiles(userRootDir) {
|
|
97
|
+
const plusFiles = await findPlusFiles(userRootDir, null);
|
|
85
98
|
const configFiles = [];
|
|
86
99
|
const valueFiles = [];
|
|
87
100
|
plusFiles.forEach((f) => {
|
|
@@ -190,12 +203,12 @@ function assertAllConfigsAreKnown(interfaceFilesByLocationId) {
|
|
|
190
203
|
});
|
|
191
204
|
});
|
|
192
205
|
}
|
|
193
|
-
async function loadVikeConfig_withErrorHandling(userRootDir,
|
|
206
|
+
async function loadVikeConfig_withErrorHandling(userRootDir, isDev, vikeVitePluginOptions, doNotRestartViteOnError) {
|
|
194
207
|
let hasError = false;
|
|
195
208
|
let ret;
|
|
196
209
|
let err;
|
|
197
210
|
try {
|
|
198
|
-
ret = await loadVikeConfig(userRootDir,
|
|
211
|
+
ret = await loadVikeConfig(userRootDir, vikeVitePluginOptions);
|
|
199
212
|
}
|
|
200
213
|
catch (err_) {
|
|
201
214
|
hasError = true;
|
|
@@ -217,8 +230,8 @@ async function loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev,
|
|
|
217
230
|
}
|
|
218
231
|
else {
|
|
219
232
|
logConfigError(err);
|
|
220
|
-
if (!
|
|
221
|
-
|
|
233
|
+
if (!doNotRestartViteOnError) {
|
|
234
|
+
restartVite = true;
|
|
222
235
|
}
|
|
223
236
|
const dummyData = {
|
|
224
237
|
pageConfigs: [],
|
|
@@ -226,16 +239,17 @@ async function loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev,
|
|
|
226
239
|
configDefinitions: {},
|
|
227
240
|
configValueSources: {}
|
|
228
241
|
},
|
|
229
|
-
|
|
242
|
+
vikeConfigGlobal: resolveVikeConfigGlobal({}, {})
|
|
230
243
|
};
|
|
231
244
|
return dummyData;
|
|
232
245
|
}
|
|
233
246
|
}
|
|
234
247
|
}
|
|
235
|
-
async function loadVikeConfig(userRootDir,
|
|
236
|
-
const interfaceFilesByLocationId = await loadInterfaceFiles(userRootDir
|
|
248
|
+
async function loadVikeConfig(userRootDir, vikeVitePluginOptions) {
|
|
249
|
+
const interfaceFilesByLocationId = await loadInterfaceFiles(userRootDir);
|
|
237
250
|
const importedFilesLoaded = {};
|
|
238
|
-
const {
|
|
251
|
+
const { pageConfigGlobal, pageConfigGlobalValues } = await getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded);
|
|
252
|
+
const vikeConfigGlobal = resolveVikeConfigGlobal(vikeVitePluginOptions, pageConfigGlobalValues);
|
|
239
253
|
const pageConfigs = await Promise.all(objectEntries(interfaceFilesByLocationId)
|
|
240
254
|
.filter(([_pageId, interfaceFiles]) => isDefiningPage(interfaceFiles))
|
|
241
255
|
.map(async ([locationId]) => {
|
|
@@ -285,7 +299,7 @@ async function loadVikeConfig(userRootDir, outDirRoot, crawlWithGit) {
|
|
|
285
299
|
return pageConfig;
|
|
286
300
|
}));
|
|
287
301
|
assertPageConfigs(pageConfigs);
|
|
288
|
-
return { pageConfigs, pageConfigGlobal,
|
|
302
|
+
return { pageConfigs, pageConfigGlobal, vikeConfigGlobal };
|
|
289
303
|
}
|
|
290
304
|
// TODO/soon: refactor
|
|
291
305
|
// - Dedupe: most of the assertUsageGlobalConfigs() code below is a copy-paste of the assertUsage() logic inside getGlobalConfigs()
|
|
@@ -395,7 +409,7 @@ async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importe
|
|
|
395
409
|
});
|
|
396
410
|
});
|
|
397
411
|
}
|
|
398
|
-
const
|
|
412
|
+
const pageConfigGlobalValues = {};
|
|
399
413
|
const pageConfigGlobal = {
|
|
400
414
|
configDefinitions: configDefinitionsBuiltInGlobal,
|
|
401
415
|
configValueSources: {}
|
|
@@ -415,10 +429,10 @@ async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importe
|
|
|
415
429
|
return;
|
|
416
430
|
const { filePathToShowToUser } = configValueSource.definedAtFilePath;
|
|
417
431
|
assertWarning(false, `Being able to define config ${pc.cyan(configName)} in ${filePathToShowToUser} is experimental and will likely be removed. Define the config ${pc.cyan(configName)} in Vike's Vite plugin options instead.`, { onlyOnce: true });
|
|
418
|
-
|
|
432
|
+
pageConfigGlobalValues[configName] = configValueSource.value;
|
|
419
433
|
}
|
|
420
434
|
}));
|
|
421
|
-
return { pageConfigGlobal,
|
|
435
|
+
return { pageConfigGlobal, pageConfigGlobalValues };
|
|
422
436
|
}
|
|
423
437
|
async function resolveConfigValueSources(configName, configDef, interfaceFilesRelevant, userRootDir, importedFilesLoaded) {
|
|
424
438
|
const sourcesInfo = [];
|
|
@@ -779,8 +793,8 @@ function getComputed(configValueSources, configDefinitions) {
|
|
|
779
793
|
});
|
|
780
794
|
return configValuesComputed;
|
|
781
795
|
}
|
|
782
|
-
async function findPlusFiles(userRootDir, outDirRoot
|
|
783
|
-
const files = await crawlPlusFiles(userRootDir, outDirRoot
|
|
796
|
+
async function findPlusFiles(userRootDir, outDirRoot) {
|
|
797
|
+
const files = await crawlPlusFiles(userRootDir, outDirRoot);
|
|
784
798
|
const plusFiles = files.map(({ filePathAbsoluteUserRootDir }) => getFilePathResolved({ filePathAbsoluteUserRootDir, userRootDir }));
|
|
785
799
|
return plusFiles;
|
|
786
800
|
}
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js
CHANGED
|
@@ -6,7 +6,6 @@ import { extractAssetsAddQuery } from '../../../../shared/extractAssetsQuery.js'
|
|
|
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 { getConfigVike } from '../../../../shared/getConfigVike.js';
|
|
10
9
|
import { fixServerAssets_isEnabled } from '../../buildConfig/fixServerAssets.js';
|
|
11
10
|
import { getConfigValueBuildTime } from '../../../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
12
11
|
async function getVirtualFilePageConfigValuesAll(id, isDev, config) {
|
|
@@ -19,11 +18,11 @@ async function getVirtualFilePageConfigValuesAll(id, isDev, config) {
|
|
|
19
18
|
}
|
|
20
19
|
*/
|
|
21
20
|
const { pageId, isForClientSide } = result;
|
|
22
|
-
const
|
|
21
|
+
const vikeConfig = await getVikeConfig(config, { doNotRestartViteOnError: true });
|
|
22
|
+
const { pageConfigs } = vikeConfig;
|
|
23
23
|
const pageConfig = pageConfigs.find((pageConfig) => pageConfig.pageId === pageId);
|
|
24
24
|
assert(pageConfig, { id, pageId });
|
|
25
|
-
const
|
|
26
|
-
const code = getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, configVike.includeAssetsImportedByServer, isDev);
|
|
25
|
+
const code = getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, vikeConfig.vikeConfigGlobal.includeAssetsImportedByServer, isDev);
|
|
27
26
|
debug(id, isForClientSide ? 'CLIENT-SIDE' : 'SERVER-SIDE', code);
|
|
28
27
|
return code;
|
|
29
28
|
}
|
|
@@ -5,7 +5,7 @@ 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 { pageConfigs, pageConfigGlobal } = await getVikeConfig(config,
|
|
8
|
+
const { pageConfigs, pageConfigGlobal } = await getVikeConfig(config, { doNotRestartViteOnError: true });
|
|
9
9
|
return getCode(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isClientRouting);
|
|
10
10
|
}
|
|
11
11
|
function getCode(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isClientRouting) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { previewConfig };
|
|
2
|
-
import { assertUsage, getOutDirs, resolveOutDir,
|
|
2
|
+
import { assertUsage, getOutDirs, resolveOutDir, applyPreview } from '../utils.js';
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import { addSsrMiddleware } from '../shared/addSsrMiddleware.js';
|
|
@@ -7,7 +7,7 @@ import pc from '@brillout/picocolors';
|
|
|
7
7
|
import { logDockerHint } from './devConfig/index.js';
|
|
8
8
|
function previewConfig() {
|
|
9
9
|
let config;
|
|
10
|
-
// let
|
|
10
|
+
// let vikeConfigGlobal: VikeConfigGlobal
|
|
11
11
|
return {
|
|
12
12
|
name: 'vike:previewConfig',
|
|
13
13
|
apply: applyPreview,
|
|
@@ -22,18 +22,18 @@ function previewConfig() {
|
|
|
22
22
|
async configResolved(config_) {
|
|
23
23
|
config = config_;
|
|
24
24
|
logDockerHint(config.preview.host);
|
|
25
|
-
//
|
|
25
|
+
// const vikeConfig = await getVikeConfig(config)
|
|
26
|
+
// vikeConfigGlobal = vikeConfig.vikeConfigGlobal
|
|
26
27
|
},
|
|
27
28
|
configurePreviewServer(server) {
|
|
28
29
|
/* - Couldn't make `appType: 'mpa'` work as of npm:@brillout/vite@5.0.0-beta.14.0426910c
|
|
29
30
|
- This ugly hack to set appType for preview won't be need once https://github.com/vitejs/vite/pull/14855 is merged.
|
|
30
31
|
config.appType = 'mpa'
|
|
31
32
|
*/
|
|
32
|
-
markEnvAsVitePreview();
|
|
33
33
|
return () => {
|
|
34
34
|
assertDist();
|
|
35
35
|
/* We don't use this condition (we wrongfully always use the SSR middleware) because of the regression introduced by https://github.com/vitejs/vite/pull/14756 which stops servering .html files when `appType: 'custom'`.
|
|
36
|
-
if (!
|
|
36
|
+
if (!vikeConfigGlobal.prerender || vikeConfigGlobal.prerender.partial) {
|
|
37
37
|
addSsrMiddleware(server.middlewares, config, true)
|
|
38
38
|
}
|
|
39
39
|
/*/
|