vike 0.4.217 → 0.4.218-commit-ed9b3d4
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 +21 -12
- package/dist/cjs/node/api/context.js +5 -1
- package/dist/cjs/node/api/index.js +17 -7
- package/dist/cjs/node/api/prepareViteApiCall.js +128 -26
- package/dist/cjs/node/api/utils.js +2 -0
- package/dist/cjs/node/cli/entry.js +19 -7
- package/dist/cjs/node/plugin/index.js +6 -5
- package/dist/cjs/node/plugin/plugins/autoFullBuild.js +3 -4
- 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 +2 -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 +189 -16
- 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 +22 -35
- package/dist/cjs/node/runtime/globalContext.js +76 -29
- 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/utils.js +1 -0
- 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/cjs/utils/debug.js +11 -6
- package/dist/cjs/utils/objectReplace.js +9 -0
- 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 +4 -5
- package/dist/esm/node/api/context.d.ts +3 -1
- package/dist/esm/node/api/context.js +6 -2
- package/dist/esm/node/api/prepareViteApiCall.d.ts +9 -3
- package/dist/esm/node/api/prepareViteApiCall.js +111 -22
- package/dist/esm/node/api/utils.d.ts +2 -0
- package/dist/esm/node/api/utils.js +2 -0
- package/dist/esm/node/cli/entry.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 +3 -4
- 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.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +2 -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 +189 -16
- 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 +4 -27
- package/dist/esm/node/runtime/globalContext.d.ts +6 -4
- package/dist/esm/node/runtime/globalContext.js +76 -29
- 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/runtime/utils.d.ts +1 -0
- package/dist/esm/node/runtime/utils.js +1 -0
- 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 +8 -2
- 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/debug.d.ts +1 -1
- package/dist/esm/utils/debug.js +11 -6
- package/dist/esm/utils/objectReplace.d.ts +1 -0
- package/dist/esm/utils/objectReplace.js +6 -0
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +3 -22
- 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
|
@@ -11,14 +11,14 @@ const require_shim_1 = require("@brillout/require-shim");
|
|
|
11
11
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
12
12
|
const path_1 = __importDefault(require("path"));
|
|
13
13
|
const assertResolveAlias_js_1 = require("./commonConfig/assertResolveAlias.js");
|
|
14
|
-
const pluginName_js_1 = require("./commonConfig/pluginName.js");
|
|
15
14
|
const getEnvVarObject_js_1 = require("../shared/getEnvVarObject.js");
|
|
16
15
|
const isViteCliCall_js_1 = require("../shared/isViteCliCall.js");
|
|
17
16
|
const context_js_1 = require("../../api/context.js");
|
|
18
|
-
|
|
17
|
+
const pluginName = 'vike:commonConfig';
|
|
18
|
+
function commonConfig(vikeVitePluginOptions) {
|
|
19
19
|
return [
|
|
20
20
|
{
|
|
21
|
-
name: `${
|
|
21
|
+
name: `${pluginName}:pre`,
|
|
22
22
|
enforce: 'pre',
|
|
23
23
|
config: {
|
|
24
24
|
order: 'pre',
|
|
@@ -31,14 +31,14 @@ function commonConfig(vikeVitePluginOptions = {}) {
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
|
-
name:
|
|
34
|
+
name: pluginName,
|
|
35
35
|
configResolved(config) {
|
|
36
36
|
assertSingleInstance(config);
|
|
37
37
|
(0, require_shim_1.installRequireShim_setUserRootDir)(config.root);
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
|
-
name: `${
|
|
41
|
+
name: `${pluginName}:post`,
|
|
42
42
|
enforce: 'post',
|
|
43
43
|
configResolved: {
|
|
44
44
|
order: 'post',
|
|
@@ -111,7 +111,7 @@ function assertEsm(userViteRoot) {
|
|
|
111
111
|
(0, utils_js_1.assertWarning)(packageJson.type === 'module', `We recommend setting ${dir}package.json#type to "module", see https://vike.dev/CJS`, { onlyOnce: true });
|
|
112
112
|
}
|
|
113
113
|
function assertSingleInstance(config) {
|
|
114
|
-
const numberOfInstances = config.plugins.filter((o) => o.name ===
|
|
114
|
+
const numberOfInstances = config.plugins.filter((o) => o.name === pluginName).length;
|
|
115
115
|
(0, utils_js_1.assertUsage)(numberOfInstances === 1, `Vike's Vite plugin (${picocolors_1.default.cyan("import vike from 'vike/plugin'")}) is being added ${numberOfInstances} times to the list of Vite plugins. Make sure to add it only once instead.`);
|
|
116
116
|
}
|
|
117
117
|
function assertVikeCliOrApi(config) {
|
|
@@ -145,9 +145,8 @@ const configDefinitionsBuiltInGlobal = {
|
|
|
145
145
|
env: { server: true, client: 'if-client-routing' },
|
|
146
146
|
eager: true
|
|
147
147
|
},
|
|
148
|
-
prerender: {
|
|
149
|
-
|
|
150
|
-
},
|
|
148
|
+
prerender: { env: { config: true } },
|
|
149
|
+
vite: { env: { config: true }, cumulative: true },
|
|
151
150
|
disableAutoFullBuild: { env: { config: true } },
|
|
152
151
|
includeAssetsImportedByServer: { env: { config: true } },
|
|
153
152
|
baseAssets: { env: { config: true } },
|
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);
|
|
@@ -425,20 +458,42 @@ async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importe
|
|
|
425
458
|
const configValueSource = sources[0];
|
|
426
459
|
if (!configValueSource)
|
|
427
460
|
return;
|
|
461
|
+
pageConfigGlobal.configValueSources[configName] = sources;
|
|
428
462
|
if (configName === 'onBeforeRoute' || configName === 'onPrerenderStart') {
|
|
429
463
|
(0, utils_js_1.assert)(!('value' in configValueSource));
|
|
430
|
-
pageConfigGlobal.configValueSources[configName] = [configValueSource];
|
|
431
464
|
}
|
|
432
465
|
else {
|
|
433
466
|
(0, utils_js_1.assert)('value' in configValueSource);
|
|
434
467
|
if (configName === 'prerender' && typeof configValueSource.value === 'boolean')
|
|
435
468
|
return;
|
|
436
|
-
const { filePathToShowToUser } = configValueSource.definedAtFilePath;
|
|
437
|
-
(0, utils_js_1.assertWarning)(false, `Being able to define config ${picocolors_1.default.cyan(configName)} in ${filePathToShowToUser} is experimental and will likely be removed. Define the config ${picocolors_1.default.cyan(configName)} in Vike's Vite plugin options instead.`, { onlyOnce: true });
|
|
438
469
|
pageConfigGlobalValues[configName] = configValueSource.value;
|
|
439
470
|
}
|
|
440
471
|
}));
|
|
441
|
-
|
|
472
|
+
const vikeConfigGlobal = resolveVikeConfigGlobal(vikeVitePluginOptions, pageConfigGlobalValues);
|
|
473
|
+
{
|
|
474
|
+
(0, utils_js_1.assert)((0, utils_js_1.isObject)(vikeVitePluginOptions));
|
|
475
|
+
Object.entries(vikeVitePluginOptions).forEach(([configName, value]) => {
|
|
476
|
+
if (pageConfigGlobal.configValueSources[configName])
|
|
477
|
+
return;
|
|
478
|
+
pageConfigGlobal.configValueSources[configName] = [];
|
|
479
|
+
pageConfigGlobal.configValueSources[configName].push({
|
|
480
|
+
value,
|
|
481
|
+
configEnv: { config: true },
|
|
482
|
+
definedAtFilePath: {
|
|
483
|
+
...(0, getFilePath_js_1.getFilePathResolved)({
|
|
484
|
+
userRootDir,
|
|
485
|
+
filePathAbsoluteUserRootDir: '/vite.config.js'
|
|
486
|
+
}),
|
|
487
|
+
fileExportPathToShowToUser: null
|
|
488
|
+
},
|
|
489
|
+
locationId: '/',
|
|
490
|
+
isOverriden: false,
|
|
491
|
+
valueIsImportedAtRuntime: false,
|
|
492
|
+
valueIsDefinedByPlusFile: false
|
|
493
|
+
});
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
return { pageConfigGlobal, pageConfigGlobalValues, vikeConfigGlobal };
|
|
442
497
|
}
|
|
443
498
|
async function resolveConfigValueSources(configName, configDef, interfaceFilesRelevant, userRootDir, importedFilesLoaded) {
|
|
444
499
|
const sourcesInfo = [];
|
|
@@ -799,8 +854,8 @@ function getComputed(configValueSources, configDefinitions) {
|
|
|
799
854
|
});
|
|
800
855
|
return configValuesComputed;
|
|
801
856
|
}
|
|
802
|
-
async function findPlusFiles(userRootDir, outDirRoot
|
|
803
|
-
const files = await (0, crawlPlusFiles_js_1.crawlPlusFiles)(userRootDir, outDirRoot
|
|
857
|
+
async function findPlusFiles(userRootDir, outDirRoot) {
|
|
858
|
+
const files = await (0, crawlPlusFiles_js_1.crawlPlusFiles)(userRootDir, outDirRoot);
|
|
804
859
|
const plusFiles = files.map(({ filePathAbsoluteUserRootDir }) => (0, getFilePath_js_1.getFilePathResolved)({ filePathAbsoluteUserRootDir, userRootDir }));
|
|
805
860
|
return plusFiles;
|
|
806
861
|
}
|
|
@@ -1016,3 +1071,121 @@ function sortConfigValueSources(configValueSources, locationIdPage) {
|
|
|
1016
1071
|
function getConfigValueInterfaceFile(interfaceFile, configName) {
|
|
1017
1072
|
return interfaceFile.fileExportsByConfigName[configName]?.configValue;
|
|
1018
1073
|
}
|
|
1074
|
+
// TODO: refactor code below
|
|
1075
|
+
function resolveVikeConfigGlobal(vikeVitePluginOptions, pageConfigGlobalValues) {
|
|
1076
|
+
// TODO/v1-release: remove
|
|
1077
|
+
assertVikeConfigGlobal(vikeVitePluginOptions, ({ prop, errMsg }) => `vite.config.js > vike option ${prop} ${errMsg}`);
|
|
1078
|
+
const configs = [vikeVitePluginOptions];
|
|
1079
|
+
assertVikeConfigGlobal(pageConfigGlobalValues, ({ prop, errMsg }) => {
|
|
1080
|
+
// Can we add the config file path ?
|
|
1081
|
+
return `config ${picocolors_1.default.cyan(prop)} ${errMsg}`;
|
|
1082
|
+
});
|
|
1083
|
+
configs.push(pageConfigGlobalValues);
|
|
1084
|
+
const vikeConfigGlobal = {
|
|
1085
|
+
disableAutoFullBuild: pickFirst(configs.map((c) => c.disableAutoFullBuild)) ?? null,
|
|
1086
|
+
prerender: resolvePrerenderOptions(configs),
|
|
1087
|
+
includeAssetsImportedByServer: pickFirst(configs.map((c) => c.includeAssetsImportedByServer)) ?? true,
|
|
1088
|
+
baseServer: pickFirst(configs.map((c) => c.baseServer)) ?? null,
|
|
1089
|
+
baseAssets: pickFirst(configs.map((c) => c.baseAssets)) ?? null,
|
|
1090
|
+
redirects: merge(configs.map((c) => c.redirects)) ?? {},
|
|
1091
|
+
disableUrlNormalization: pickFirst(configs.map((c) => c.disableUrlNormalization)) ?? false,
|
|
1092
|
+
trailingSlash: pickFirst(configs.map((c) => c.trailingSlash)) ?? false
|
|
1093
|
+
};
|
|
1094
|
+
return vikeConfigGlobal;
|
|
1095
|
+
}
|
|
1096
|
+
function resolvePrerenderOptions(configs) {
|
|
1097
|
+
if (!configs.some((c) => c.prerender)) {
|
|
1098
|
+
return false;
|
|
1099
|
+
}
|
|
1100
|
+
const configsPrerender = configs.map((c) => c.prerender).filter(isObject2);
|
|
1101
|
+
return {
|
|
1102
|
+
partial: pickFirst(configsPrerender.map((c) => c.partial)) ?? false,
|
|
1103
|
+
noExtraDir: pickFirst(configsPrerender.map((c) => c.noExtraDir)) ?? false,
|
|
1104
|
+
parallel: pickFirst(configsPrerender.map((c) => c.parallel)) ?? true,
|
|
1105
|
+
disableAutoRun: pickFirst(configsPrerender.map((c) => c.disableAutoRun)) ?? false
|
|
1106
|
+
};
|
|
1107
|
+
}
|
|
1108
|
+
function isObject2(p) {
|
|
1109
|
+
return typeof p === 'object';
|
|
1110
|
+
}
|
|
1111
|
+
function merge(objs) {
|
|
1112
|
+
const obj = {};
|
|
1113
|
+
objs.forEach((e) => {
|
|
1114
|
+
Object.assign(obj, e);
|
|
1115
|
+
});
|
|
1116
|
+
return obj;
|
|
1117
|
+
}
|
|
1118
|
+
function pickFirst(arr) {
|
|
1119
|
+
return arr.filter((v) => v !== undefined)[0];
|
|
1120
|
+
}
|
|
1121
|
+
function assertVikeConfigGlobal(vikeConfigGlobal, wrongUsageMsg) {
|
|
1122
|
+
const wrongUsageError = check(vikeConfigGlobal);
|
|
1123
|
+
if (wrongUsageError) {
|
|
1124
|
+
(0, utils_js_1.assertUsage)(false, wrongUsageMsg(wrongUsageError));
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
function check(vikeConfigGlobal) {
|
|
1128
|
+
(0, utils_js_1.assert)((0, utils_js_1.isObject)(vikeConfigGlobal));
|
|
1129
|
+
{
|
|
1130
|
+
const prop = 'disableUrlNormalization';
|
|
1131
|
+
if (!(0, utils_js_1.hasProp)(vikeConfigGlobal, prop, 'boolean') && !(0, utils_js_1.hasProp)(vikeConfigGlobal, prop, 'undefined'))
|
|
1132
|
+
return { prop, errMsg: 'should be a boolean' };
|
|
1133
|
+
}
|
|
1134
|
+
{
|
|
1135
|
+
const prop = 'trailingSlash';
|
|
1136
|
+
if (!(0, utils_js_1.hasProp)(vikeConfigGlobal, prop, 'boolean') && !(0, utils_js_1.hasProp)(vikeConfigGlobal, prop, 'undefined'))
|
|
1137
|
+
return { prop, errMsg: 'should be a boolean' };
|
|
1138
|
+
}
|
|
1139
|
+
{
|
|
1140
|
+
const prop = 'redirects';
|
|
1141
|
+
const { redirects } = vikeConfigGlobal;
|
|
1142
|
+
if (!(redirects === undefined ||
|
|
1143
|
+
((0, utils_js_1.isObject)(redirects) && Object.values(redirects).every((v) => typeof v === 'string'))))
|
|
1144
|
+
return { prop, errMsg: 'should be an object of strings' };
|
|
1145
|
+
}
|
|
1146
|
+
{
|
|
1147
|
+
const prop = 'disableAutoFullBuild';
|
|
1148
|
+
if (!(0, utils_js_1.hasProp)(vikeConfigGlobal, prop, 'boolean') &&
|
|
1149
|
+
!(0, utils_js_1.hasProp)(vikeConfigGlobal, prop, 'undefined') &&
|
|
1150
|
+
!(vikeConfigGlobal[prop] === 'prerender'))
|
|
1151
|
+
return { prop, errMsg: "should be a boolean or 'prerender'" };
|
|
1152
|
+
}
|
|
1153
|
+
{
|
|
1154
|
+
const prop = 'includeAssetsImportedByServer';
|
|
1155
|
+
if (!(0, utils_js_1.hasProp)(vikeConfigGlobal, prop, 'boolean') && !(0, utils_js_1.hasProp)(vikeConfigGlobal, prop, 'undefined'))
|
|
1156
|
+
return { prop, errMsg: 'should be a boolean' };
|
|
1157
|
+
}
|
|
1158
|
+
{
|
|
1159
|
+
const prop = 'prerender';
|
|
1160
|
+
if (!(0, utils_js_1.hasProp)(vikeConfigGlobal, prop, 'object') &&
|
|
1161
|
+
!(0, utils_js_1.hasProp)(vikeConfigGlobal, prop, 'boolean') &&
|
|
1162
|
+
!(0, utils_js_1.hasProp)(vikeConfigGlobal, prop, 'undefined'))
|
|
1163
|
+
return { prop, errMsg: 'should be an object or a boolean' };
|
|
1164
|
+
}
|
|
1165
|
+
const configVikePrerender = vikeConfigGlobal.prerender;
|
|
1166
|
+
if (typeof configVikePrerender === 'object') {
|
|
1167
|
+
{
|
|
1168
|
+
const p = 'partial';
|
|
1169
|
+
if (!(0, utils_js_1.hasProp)(configVikePrerender, p, 'boolean') && !(0, utils_js_1.hasProp)(configVikePrerender, p, 'undefined'))
|
|
1170
|
+
return { prop: `prerender.${p}`, errMsg: 'should be a boolean' };
|
|
1171
|
+
}
|
|
1172
|
+
{
|
|
1173
|
+
const p = 'noExtraDir';
|
|
1174
|
+
if (!(0, utils_js_1.hasProp)(configVikePrerender, p, 'boolean') && !(0, utils_js_1.hasProp)(configVikePrerender, p, 'undefined'))
|
|
1175
|
+
return { prop: `prerender.${p}`, errMsg: 'should be a boolean' };
|
|
1176
|
+
}
|
|
1177
|
+
{
|
|
1178
|
+
const p = 'disableAutoRun';
|
|
1179
|
+
if (!(0, utils_js_1.hasProp)(configVikePrerender, p, 'boolean') && !(0, utils_js_1.hasProp)(configVikePrerender, p, 'undefined'))
|
|
1180
|
+
return { prop: `prerender.${p}`, errMsg: 'should be a boolean' };
|
|
1181
|
+
}
|
|
1182
|
+
{
|
|
1183
|
+
const p = 'parallel';
|
|
1184
|
+
if (!(0, utils_js_1.hasProp)(configVikePrerender, p, 'boolean') &&
|
|
1185
|
+
!(0, utils_js_1.hasProp)(configVikePrerender, p, 'number') &&
|
|
1186
|
+
!(0, utils_js_1.hasProp)(configVikePrerender, p, 'undefined'))
|
|
1187
|
+
return { prop: `prerender.${p}`, errMsg: 'should be a boolean or a number' };
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
return null;
|
|
1191
|
+
}
|
|
@@ -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
|
+
}
|