vike 0.4.219 → 0.4.220-commit-9a798ce
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/node/api/build.js +23 -58
- package/dist/cjs/node/api/context.js +6 -8
- package/dist/cjs/node/api/prepareViteApiCall.js +6 -7
- package/dist/cjs/node/api/utils.js +1 -1
- package/dist/cjs/node/cli/context.js +16 -0
- package/dist/cjs/node/cli/entry.js +2 -0
- package/dist/cjs/node/cli/utils.js +1 -0
- package/dist/cjs/{utils → node/plugin}/getOutDirs.js +11 -11
- package/dist/cjs/node/plugin/index.js +1 -7
- package/dist/cjs/node/plugin/onLoad.js +6 -1
- package/dist/cjs/node/plugin/plugins/autoFullBuild.js +43 -31
- package/dist/cjs/node/plugin/plugins/baseUrls.js +2 -2
- package/dist/cjs/node/plugin/plugins/buildConfig.js +6 -3
- package/dist/cjs/node/plugin/plugins/buildEntry/index.js +24 -21
- package/dist/cjs/node/plugin/plugins/commonConfig.js +11 -8
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +4 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +10 -7
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +3 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/assertExtensions.js +10 -9
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +8 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +158 -176
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +3 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +3 -2
- package/dist/cjs/node/plugin/plugins/previewConfig.js +3 -4
- package/dist/cjs/node/plugin/utils.js +1 -1
- package/dist/cjs/node/prerender/context.js +26 -0
- package/dist/cjs/node/prerender/resolvePrerenderConfig.js +25 -0
- package/dist/cjs/node/prerender/runPrerender.js +64 -37
- package/dist/cjs/node/prerender/utils.js +3 -2
- package/dist/cjs/node/runtime/globalContext.js +44 -58
- package/dist/cjs/node/runtime/page-files/setup.js +1 -1
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +6 -3
- package/dist/cjs/node/runtime/renderPage/resolveRedirects.js +6 -5
- package/dist/cjs/node/runtime/renderPage.js +10 -5
- package/dist/cjs/node/runtime/utils.js +3 -2
- package/dist/cjs/node/shared/resolveBase.js +9 -0
- package/dist/cjs/shared/page-configs/getPageConfigUserFriendly.js +2 -2
- package/dist/cjs/shared/page-configs/loadConfigValues.js +5 -1
- package/dist/cjs/shared/utils.js +1 -1
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assertSetup.js +15 -1
- package/dist/cjs/utils/catchInfiniteLoop.js +34 -0
- package/dist/cjs/utils/findFile.js +3 -3
- package/dist/cjs/utils/isDev.js +4 -1
- package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +2 -2
- package/dist/cjs/utils/makePublicCopy.js +32 -0
- package/dist/cjs/utils/requireResolve.js +3 -3
- package/dist/esm/client/client-routing-runtime/history.d.ts +3 -1
- package/dist/esm/client/client-routing-runtime/history.js +23 -18
- package/dist/esm/client/client-routing-runtime/index.d.ts +0 -1
- package/dist/esm/client/client-routing-runtime/index.js +0 -1
- package/dist/esm/client/client-routing-runtime/initClientRouter.js +2 -2
- package/dist/esm/client/client-routing-runtime/initOnLinkClick.js +3 -4
- package/dist/esm/client/client-routing-runtime/initOnPopState.d.ts +0 -10
- package/dist/esm/client/client-routing-runtime/initOnPopState.js +50 -62
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +15 -15
- package/dist/esm/client/client-routing-runtime/scrollRestoration.d.ts +4 -6
- package/dist/esm/client/client-routing-runtime/scrollRestoration.js +17 -12
- package/dist/esm/client/client-routing-runtime/setScrollPosition.d.ts +1 -1
- package/dist/esm/client/client-routing-runtime/setScrollPosition.js +29 -5
- package/dist/esm/client/client-routing-runtime/utils.d.ts +1 -0
- package/dist/esm/client/client-routing-runtime/utils.js +1 -0
- package/dist/esm/client/shared/normalizeClientSideUrl.js +2 -3
- package/dist/esm/node/api/build.d.ts +1 -6
- package/dist/esm/node/api/build.js +20 -25
- package/dist/esm/node/api/context.d.ts +4 -4
- package/dist/esm/node/api/context.js +6 -9
- package/dist/esm/node/api/prepareViteApiCall.d.ts +0 -1
- package/dist/esm/node/api/prepareViteApiCall.js +7 -8
- package/dist/esm/node/api/utils.d.ts +1 -1
- package/dist/esm/node/api/utils.js +1 -1
- package/dist/esm/node/cli/context.d.ts +5 -0
- package/dist/esm/node/cli/context.js +14 -0
- package/dist/esm/node/cli/entry.js +2 -0
- package/dist/esm/node/cli/parseCli.d.ts +3 -1
- package/dist/esm/node/cli/utils.d.ts +1 -0
- package/dist/esm/node/cli/utils.js +1 -0
- package/dist/esm/{utils → node/plugin}/getOutDirs.js +5 -5
- package/dist/esm/node/plugin/index.d.ts +29 -1
- package/dist/esm/node/plugin/index.js +2 -8
- package/dist/esm/node/plugin/onLoad.js +7 -2
- package/dist/esm/node/plugin/plugins/autoFullBuild.js +43 -31
- package/dist/esm/node/plugin/plugins/baseUrls.js +2 -2
- package/dist/esm/node/plugin/plugins/buildConfig.js +7 -4
- package/dist/esm/node/plugin/plugins/buildEntry/index.d.ts +3 -3
- package/dist/esm/node/plugin/plugins/buildEntry/index.js +25 -22
- package/dist/esm/node/plugin/plugins/commonConfig.d.ts +8 -2
- package/dist/esm/node/plugin/plugins/commonConfig.js +9 -6
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +4 -2
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +10 -7
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +3 -4
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/assertExtensions.d.ts +3 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/assertExtensions.js +10 -9
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +8 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +2 -95
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +159 -177
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +3 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +3 -2
- package/dist/esm/node/plugin/plugins/previewConfig.js +3 -4
- package/dist/esm/node/plugin/utils.js +1 -1
- package/dist/esm/node/prerender/context.d.ts +9 -0
- package/dist/esm/node/prerender/context.js +24 -0
- package/dist/esm/node/prerender/resolvePrerenderConfig.d.ts +5 -0
- package/dist/esm/node/prerender/resolvePrerenderConfig.js +23 -0
- package/dist/esm/node/prerender/runPrerender.d.ts +42 -1
- package/dist/esm/node/prerender/runPrerender.js +65 -38
- package/dist/esm/node/prerender/utils.d.ts +3 -2
- package/dist/esm/node/prerender/utils.js +3 -2
- package/dist/esm/node/runtime/globalContext.d.ts +15 -9
- package/dist/esm/node/runtime/globalContext.js +45 -59
- package/dist/esm/node/runtime/page-files/setup.js +1 -1
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +5 -5
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +6 -3
- package/dist/esm/node/runtime/renderPage/resolveRedirects.d.ts +2 -0
- package/dist/esm/node/runtime/renderPage/resolveRedirects.js +5 -5
- package/dist/esm/node/runtime/renderPage.js +10 -5
- package/dist/esm/node/runtime/utils.d.ts +3 -2
- package/dist/esm/node/runtime/utils.js +3 -2
- package/dist/esm/node/shared/resolveBase.d.ts +4 -1
- package/dist/esm/node/shared/resolveBase.js +9 -0
- package/dist/esm/shared/page-configs/Config.d.ts +76 -3
- package/dist/esm/shared/page-configs/PageConfig.d.ts +25 -16
- package/dist/esm/shared/page-configs/getPageConfigUserFriendly.d.ts +1 -1
- package/dist/esm/shared/page-configs/getPageConfigUserFriendly.js +2 -2
- package/dist/esm/shared/page-configs/loadConfigValues.js +6 -2
- package/dist/esm/shared/utils.d.ts +1 -1
- package/dist/esm/shared/utils.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.js +15 -1
- package/dist/esm/utils/catchInfiniteLoop.d.ts +2 -0
- package/dist/esm/utils/catchInfiniteLoop.js +32 -0
- package/dist/esm/utils/findFile.js +1 -1
- package/dist/esm/utils/isDev.js +4 -1
- package/dist/esm/utils/isFilePathAbsoluteFilesystem.js +1 -1
- package/dist/esm/utils/makePublicCopy.d.ts +3 -0
- package/dist/esm/utils/makePublicCopy.js +30 -0
- 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/buildEntry/getVikeManifest.js +0 -17
- package/dist/cjs/node/prerender/isPrerenderAutoRunEnabled.js +0 -16
- package/dist/cjs/node/shared/assertPluginManifest.js +0 -20
- package/dist/cjs/node/shared/assertRuntimeManifest.js +0 -16
- package/dist/esm/node/plugin/plugins/buildEntry/getVikeManifest.d.ts +0 -5
- package/dist/esm/node/plugin/plugins/buildEntry/getVikeManifest.js +0 -15
- package/dist/esm/node/prerender/isPrerenderAutoRunEnabled.d.ts +0 -5
- package/dist/esm/node/prerender/isPrerenderAutoRunEnabled.js +0 -14
- package/dist/esm/node/shared/assertPluginManifest.d.ts +0 -12
- package/dist/esm/node/shared/assertPluginManifest.js +0 -18
- package/dist/esm/node/shared/assertRuntimeManifest.d.ts +0 -10
- package/dist/esm/node/shared/assertRuntimeManifest.js +0 -14
- /package/dist/cjs/utils/{filesystemPathHandling.js → toPosixPath.js} +0 -0
- /package/dist/esm/{utils → node/plugin}/getOutDirs.d.ts +0 -0
- /package/dist/esm/utils/{filesystemPathHandling.d.ts → toPosixPath.d.ts} +0 -0
- /package/dist/esm/utils/{filesystemPathHandling.js → toPosixPath.js} +0 -0
|
@@ -16,7 +16,8 @@ const isViteCliCall_js_1 = require("../shared/isViteCliCall.js");
|
|
|
16
16
|
const context_js_1 = require("../../api/context.js");
|
|
17
17
|
const getVikeConfig_js_1 = require("./importUserCode/v1-design/getVikeConfig.js");
|
|
18
18
|
const prepareViteApiCall_js_1 = require("../../api/prepareViteApiCall.js");
|
|
19
|
-
const
|
|
19
|
+
const context_js_2 = require("../../prerender/context.js");
|
|
20
|
+
const resolvePrerenderConfig_js_1 = require("../../prerender/resolvePrerenderConfig.js");
|
|
20
21
|
const pluginName = 'vike:commonConfig';
|
|
21
22
|
function commonConfig(vikeVitePluginOptions) {
|
|
22
23
|
return [
|
|
@@ -35,9 +36,11 @@ function commonConfig(vikeVitePluginOptions) {
|
|
|
35
36
|
_isDev: isDev,
|
|
36
37
|
_root: root,
|
|
37
38
|
_vikeVitePluginOptions: vikeVitePluginOptions,
|
|
38
|
-
vike: vikeConfig,
|
|
39
|
-
// TODO/v1-release: remove
|
|
40
|
-
configVikePromise: Promise.resolve(
|
|
39
|
+
vike: { global: vikeConfig.global },
|
|
40
|
+
// TODO/v1-release: remove https://github.com/vikejs/vike/issues/2122
|
|
41
|
+
configVikePromise: Promise.resolve({
|
|
42
|
+
prerender: !!(0, resolvePrerenderConfig_js_1.resolvePrerenderConfig)(vikeConfig.global.config.prerender)
|
|
43
|
+
})
|
|
41
44
|
};
|
|
42
45
|
}
|
|
43
46
|
}
|
|
@@ -80,7 +83,7 @@ function commonConfig(vikeVitePluginOptions) {
|
|
|
80
83
|
// VITE_CONFIG
|
|
81
84
|
const configFromEnvVar = (0, getEnvVarObject_js_1.getEnvVarObject)('VITE_CONFIG');
|
|
82
85
|
if (configFromEnvVar)
|
|
83
|
-
configFromVike = (0, vite_1.mergeConfig)(
|
|
86
|
+
configFromVike = (0, vite_1.mergeConfig)(configFromVike, configFromEnvVar);
|
|
84
87
|
return configFromVike;
|
|
85
88
|
}
|
|
86
89
|
}
|
|
@@ -147,7 +150,7 @@ function assertVikeCliOrApi(config) {
|
|
|
147
150
|
onlyOnce: true
|
|
148
151
|
});
|
|
149
152
|
}
|
|
150
|
-
// TODO/v1-release: remove
|
|
153
|
+
// TODO/v1-release: remove https://github.com/vikejs/vike/issues/2122
|
|
151
154
|
function temp_supportOldInterface(config) {
|
|
152
155
|
if (!('vitePluginSsr' in config))
|
|
153
156
|
return;
|
|
@@ -155,14 +158,14 @@ function temp_supportOldInterface(config) {
|
|
|
155
158
|
if ((0, utils_js_1.hasProp)(config.vitePluginSsr, 'prerender', 'object')) {
|
|
156
159
|
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(config.vitePluginSsr.prerender, 'disableAutoRun', 'boolean'));
|
|
157
160
|
if (config.vitePluginSsr.prerender.disableAutoRun) {
|
|
158
|
-
(0,
|
|
161
|
+
(0, context_js_2.temp_disablePrerenderAutoRun)();
|
|
159
162
|
}
|
|
160
163
|
return;
|
|
161
164
|
}
|
|
162
165
|
if ((0, utils_js_1.hasProp)(config.vitePluginSsr, 'disableAutoFullBuild')) {
|
|
163
166
|
if (config.vitePluginSsr.disableAutoFullBuild) {
|
|
164
167
|
(0, utils_js_1.assert)(config.vitePluginSsr.disableAutoFullBuild === 'prerender');
|
|
165
|
-
(0,
|
|
168
|
+
(0, context_js_2.temp_disablePrerenderAutoRun)();
|
|
166
169
|
}
|
|
167
170
|
return;
|
|
168
171
|
}
|
|
@@ -45,7 +45,8 @@ function extractAssetsPlugin() {
|
|
|
45
45
|
(0, assertV1Design_js_1.assertV1Design)(vikeConfig.pageConfigs, true);
|
|
46
46
|
(0, utils_js_1.assert)(false);
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
// TODO/now: add meta.default
|
|
49
|
+
(0, utils_js_1.assert)(vikeConfig.global.config.includeAssetsImportedByServer ?? true);
|
|
49
50
|
(0, utils_js_1.assert)(!(0, utils_js_1.viteIsSSR_options)(options));
|
|
50
51
|
const importStatements = await (0, parseEsModule_js_1.getImportStatements)(src);
|
|
51
52
|
const moduleNames = getImportedModules(importStatements);
|
|
@@ -78,7 +79,8 @@ function extractAssetsPlugin() {
|
|
|
78
79
|
if (!extractAssetsRE.test(importer)) {
|
|
79
80
|
return;
|
|
80
81
|
}
|
|
81
|
-
|
|
82
|
+
// TODO/now: add meta.default
|
|
83
|
+
(0, utils_js_1.assert)(vikeConfig.global.config.includeAssetsImportedByServer ?? true);
|
|
82
84
|
let resolution = null;
|
|
83
85
|
try {
|
|
84
86
|
resolution = await this.resolve(source, importer, { skipSelf: true, ...options });
|
|
@@ -11,16 +11,17 @@ const fileTypes_js_1 = require("../../../../shared/getPageFiles/fileTypes.js");
|
|
|
11
11
|
const path_1 = __importDefault(require("path"));
|
|
12
12
|
const getVirtualFilePageConfigs_js_1 = require("./v1-design/getVirtualFilePageConfigs.js");
|
|
13
13
|
const getVikeConfig_js_1 = require("./v1-design/getVikeConfig.js");
|
|
14
|
-
|
|
14
|
+
const resolvePrerenderConfig_js_1 = require("../../../prerender/resolvePrerenderConfig.js");
|
|
15
|
+
async function getVirtualFileImportUserCode(id, options, vikeConfig, config, isDev) {
|
|
15
16
|
const idParsed = (0, virtualFileImportUserCode_js_1.isVirtualFileIdImportUserCode)(id);
|
|
16
17
|
(0, utils_js_1.assert)(idParsed);
|
|
17
18
|
const { isForClientSide, isClientRouting } = idParsed;
|
|
18
19
|
(0, utils_js_1.assert)(isForClientSide === !(0, utils_js_1.viteIsSSR_options)(options));
|
|
19
|
-
const isPrerendering = !!
|
|
20
|
-
const code = await getCode(config,
|
|
20
|
+
const isPrerendering = !!(0, resolvePrerenderConfig_js_1.resolvePrerenderConfig)(vikeConfig.global.config.prerender);
|
|
21
|
+
const code = await getCode(config, vikeConfig, isForClientSide, isClientRouting, isPrerendering, isDev, id);
|
|
21
22
|
return code;
|
|
22
23
|
}
|
|
23
|
-
async function getCode(config,
|
|
24
|
+
async function getCode(config, vikeConfig, isForClientSide, isClientRouting, isPrerendering, isDev, id) {
|
|
24
25
|
const { command } = config;
|
|
25
26
|
(0, utils_js_1.assert)(command === 'serve' || command === 'build');
|
|
26
27
|
const isBuild = command === 'build';
|
|
@@ -29,7 +30,7 @@ async function getCode(config, vikeConfigGlobal, isForClientSide, isClientRoutin
|
|
|
29
30
|
{
|
|
30
31
|
const globRoots = getGlobRoots(config);
|
|
31
32
|
(0, utils_js_1.debugGlob)('Glob roots: ', globRoots);
|
|
32
|
-
content += await generateGlobImports(globRoots, isBuild, isForClientSide, isClientRouting,
|
|
33
|
+
content += await generateGlobImports(globRoots, isBuild, isForClientSide, isClientRouting, vikeConfig, isPrerendering, config, isDev, id);
|
|
33
34
|
}
|
|
34
35
|
(0, utils_js_1.debugGlob)(`Glob imports for ${isForClientSide ? 'client' : 'server'}:\n`, content);
|
|
35
36
|
return content;
|
|
@@ -59,7 +60,7 @@ function determineInjection({ fileType, isForClientSide, isClientRouting, isPrer
|
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
|
-
async function generateGlobImports(globRoots, isBuild, isForClientSide, isClientRouting,
|
|
63
|
+
async function generateGlobImports(globRoots, isBuild, isForClientSide, isClientRouting, vikeConfig, isPrerendering, config, isDev, id) {
|
|
63
64
|
let fileContent = `// Generated by https://github.com/vikejs/vike/blob/main/vike/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.ts
|
|
64
65
|
|
|
65
66
|
export const pageFilesLazy = {};
|
|
@@ -91,7 +92,9 @@ ${await (0, getVirtualFilePageConfigs_js_1.getVirtualFilePageConfigs)(isForClien
|
|
|
91
92
|
fileContent += getGlobs(globRoots, isBuild, fileType, 'extractExportNames', isV1Design);
|
|
92
93
|
}
|
|
93
94
|
});
|
|
94
|
-
|
|
95
|
+
// TODO/now: add meta.default
|
|
96
|
+
const includeAssetsImportedByServer = vikeConfig.global.config.includeAssetsImportedByServer ?? true;
|
|
97
|
+
if (includeAssetsImportedByServer && isForClientSide) {
|
|
95
98
|
fileContent += getGlobs(globRoots, isBuild, '.page.server', 'extractAssets', isV1Design);
|
|
96
99
|
}
|
|
97
100
|
return fileContent;
|
|
@@ -17,12 +17,11 @@ const loggerNotProd_js_1 = require("../../shared/loggerNotProd.js");
|
|
|
17
17
|
const getFilePath_js_1 = require("../../shared/getFilePath.js");
|
|
18
18
|
function importUserCode() {
|
|
19
19
|
let config;
|
|
20
|
-
let
|
|
20
|
+
let vikeConfig;
|
|
21
21
|
return {
|
|
22
22
|
name: 'vike:importUserCode',
|
|
23
23
|
async configResolved(config_) {
|
|
24
|
-
|
|
25
|
-
vikeConfigGlobal = vikeConfig.vikeConfigGlobal;
|
|
24
|
+
vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig)(config_);
|
|
26
25
|
config = config_;
|
|
27
26
|
// TODO/v1-release: remove
|
|
28
27
|
{
|
|
@@ -57,7 +56,7 @@ function importUserCode() {
|
|
|
57
56
|
return code;
|
|
58
57
|
}
|
|
59
58
|
if ((0, virtualFileImportUserCode_js_1.isVirtualFileIdImportUserCode)(id)) {
|
|
60
|
-
const code = await (0, getVirtualFileImportUserCode_js_1.getVirtualFileImportUserCode)(id, options,
|
|
59
|
+
const code = await (0, getVirtualFileImportUserCode_js_1.getVirtualFileImportUserCode)(id, options, vikeConfig, config, isDev);
|
|
61
60
|
return code;
|
|
62
61
|
}
|
|
63
62
|
},
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.assertExtensionsConventions = assertExtensionsConventions;
|
|
7
|
-
exports.
|
|
7
|
+
exports.assertExtensionsRequire = assertExtensionsRequire;
|
|
8
8
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
9
9
|
const isObjectOfStrings_js_1 = require("../../../../../utils/isObjectOfStrings.js");
|
|
10
10
|
const utils_js_1 = require("../../../utils.js");
|
|
@@ -23,32 +23,33 @@ function assertConfigExportPath(interfaceFile) {
|
|
|
23
23
|
(0, utils_js_1.assert)(!p.includes('node_modules'));
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
const name =
|
|
26
|
+
const name = getNameValue(interfaceFile);
|
|
27
27
|
(0, utils_js_1.assert)(name); // already asserted in assertExtensionName()
|
|
28
28
|
const importPathAbsoluteExpected = `${name}/config`;
|
|
29
29
|
(0, utils_js_1.assertWarning)(importPathAbsolute === importPathAbsoluteExpected, `The Vike configuration of ${picocolors_1.default.bold(name)} is exported at ${picocolors_1.default.bold(importPathAbsolute)}, but it should be exported at ${picocolors_1.default.bold(importPathAbsoluteExpected)} instead.`, { onlyOnce: true });
|
|
30
30
|
}
|
|
31
31
|
function assertExtensionName(interfaceFile) {
|
|
32
32
|
const filePathToShowToUser = getFilePathToShowToUser(interfaceFile);
|
|
33
|
-
const name =
|
|
33
|
+
const name = getNameValue(interfaceFile);
|
|
34
34
|
(0, utils_js_1.assertUsage)(name, `Vike extension name missing: the config ${filePathToShowToUser} must define the setting ${picocolors_1.default.cyan('name')}`);
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
|
|
36
|
+
function assertExtensionsRequire(pageConfig) {
|
|
37
|
+
const interfaceFilesRelevantList = Object.values(pageConfig.interfaceFiles).flat(1);
|
|
38
|
+
// Collect extensions
|
|
38
39
|
const extensions = {};
|
|
39
40
|
interfaceFilesRelevantList.forEach((interfaceFile) => {
|
|
40
|
-
const name =
|
|
41
|
+
const name = getNameValue(interfaceFile);
|
|
41
42
|
if (name) {
|
|
42
43
|
const version = getExtensionVersion(name, interfaceFile);
|
|
43
44
|
extensions[name] = version;
|
|
44
45
|
}
|
|
45
46
|
});
|
|
46
|
-
// Enforce
|
|
47
|
+
// Enforce `require`
|
|
47
48
|
interfaceFilesRelevantList.forEach((interfaceFile) => {
|
|
48
49
|
const require = getConfigRequireValue(interfaceFile);
|
|
49
50
|
if (!require)
|
|
50
51
|
return;
|
|
51
|
-
const name =
|
|
52
|
+
const name = getNameValue(interfaceFile);
|
|
52
53
|
const filePathToShowToUser = getFilePathToShowToUser(interfaceFile);
|
|
53
54
|
(0, utils_js_1.assertUsage)(name, `Setting ${picocolors_1.default.bold('name')} is required for being able to use setting ${picocolors_1.default.bold('require')} in ${filePathToShowToUser}.`);
|
|
54
55
|
Object.entries(require).forEach(([reqName, reqVersion]) => {
|
|
@@ -72,7 +73,7 @@ function getConfigRequireValue(interfaceFile) {
|
|
|
72
73
|
(0, utils_js_1.assertUsage)((0, isObjectOfStrings_js_1.isObjectOfStrings)(require), `The setting ${picocolors_1.default.bold('require')} defined at ${filePathToShowToUserResolved} should be an object with string values (${picocolors_1.default.bold('Record<string, string>')}).`);
|
|
73
74
|
return require;
|
|
74
75
|
}
|
|
75
|
-
function
|
|
76
|
+
function getNameValue(interfaceFile) {
|
|
76
77
|
const name = (0, getVikeConfig_js_1.getConfigValueInterfaceFile)(interfaceFile, 'name');
|
|
77
78
|
if (!name)
|
|
78
79
|
return null;
|
|
@@ -141,7 +141,12 @@ const configDefinitionsBuiltInAll = {
|
|
|
141
141
|
eager: true,
|
|
142
142
|
global: true
|
|
143
143
|
},
|
|
144
|
-
prerender: {
|
|
144
|
+
prerender: {
|
|
145
|
+
env: { config: true },
|
|
146
|
+
global: (value) => typeof value === 'object',
|
|
147
|
+
type: ['boolean', 'object'],
|
|
148
|
+
cumulative: true
|
|
149
|
+
},
|
|
145
150
|
vite: { env: { config: true }, global: true, cumulative: true, type: 'object' },
|
|
146
151
|
disableAutoFullBuild: {
|
|
147
152
|
env: { config: true },
|
|
@@ -153,8 +158,8 @@ const configDefinitionsBuiltInAll = {
|
|
|
153
158
|
]
|
|
154
159
|
},
|
|
155
160
|
includeAssetsImportedByServer: { env: { config: true }, global: true, type: 'boolean' },
|
|
156
|
-
baseAssets: { env: { config: true }, global: true, type: 'string' },
|
|
157
|
-
baseServer: { env: { config: true }, global: true, type: 'string' },
|
|
161
|
+
baseAssets: { env: { config: true, server: true }, global: true, type: 'string' },
|
|
162
|
+
baseServer: { env: { config: true, server: true }, global: true, type: 'string' },
|
|
158
163
|
redirects: { env: { server: true }, global: true, type: 'string{}', cumulative: true },
|
|
159
164
|
trailingSlash: { env: { server: true }, global: true, type: 'boolean' },
|
|
160
165
|
disableUrlNormalization: { env: { server: true }, global: true, type: 'boolean' }
|