vike 0.4.143-commit-fa295e1 → 0.4.144-commit-e40e9b1
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/plugin/plugins/buildConfig.js +1 -1
- package/dist/cjs/node/plugin/plugins/config/index.js +1 -1
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +3 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +17 -8
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +4 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +69 -87
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +7 -42
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +24 -26
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/helpers.js +6 -8
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +18 -0
- package/dist/cjs/node/plugin/shared/findPageFiles.js +2 -1
- package/dist/cjs/node/plugin/utils.js +1 -1
- package/dist/cjs/node/prerender/runPrerender.js +4 -4
- package/dist/cjs/node/runtime/renderPage.js +1 -1
- package/dist/cjs/shared/assertPageContextProvidedByUser.js +1 -1
- package/dist/cjs/shared/getPageFiles/getExports.js +4 -4
- package/dist/cjs/shared/getPageFiles/parseGlobResults.js +3 -3
- package/dist/cjs/shared/page-configs/getExportPath.js +7 -8
- package/dist/cjs/shared/page-configs/loadConfigValues.js +1 -1
- package/dist/cjs/shared/page-configs/serialize/PageConfigSerialized.js +2 -0
- package/dist/cjs/shared/{getPageFiles → page-configs/serialize}/assertPageConfigs.js +1 -1
- package/dist/cjs/shared/page-configs/{parseConfigValuesImported.js → serialize/parseConfigValuesImported.js} +13 -10
- package/dist/cjs/shared/{getPageFiles/parsePageConfigsSerialized.js → page-configs/serialize/parsePageConfigs.js} +6 -6
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValue.js +58 -0
- package/dist/cjs/shared/page-configs/utils.js +11 -12
- package/dist/cjs/shared/route/loadPageRoutes.js +1 -1
- package/dist/cjs/utils/getOutDirs.js +25 -18
- package/dist/cjs/utils/getValuePrintable.js +1 -1
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/cjs/utils/warnIfErrorIsNotObject.js +1 -1
- package/dist/esm/client/client-routing-runtime/useClientRouter.js +1 -1
- package/dist/esm/node/plugin/plugins/buildConfig.js +2 -2
- package/dist/esm/node/plugin/plugins/config/index.js +2 -2
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +4 -6
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +18 -9
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +4 -4
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +69 -87
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.d.ts +1 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +6 -38
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +21 -23
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/helpers.d.ts +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/helpers.js +6 -8
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.d.ts +7 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +15 -0
- package/dist/esm/node/plugin/shared/findPageFiles.js +3 -2
- package/dist/esm/node/plugin/utils.js +1 -1
- package/dist/esm/node/prerender/runPrerender.js +5 -5
- package/dist/esm/node/runtime/renderPage.js +1 -1
- package/dist/esm/shared/assertPageContextProvidedByUser.js +1 -1
- package/dist/esm/shared/getPageFiles/getExports.js +4 -4
- package/dist/esm/shared/getPageFiles/parseGlobResults.js +3 -3
- package/dist/esm/shared/page-configs/PageConfig.d.ts +25 -62
- package/dist/esm/shared/page-configs/getExportPath.d.ts +1 -1
- package/dist/esm/shared/page-configs/getExportPath.js +7 -8
- package/dist/esm/shared/page-configs/loadConfigValues.js +1 -1
- package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.d.ts +32 -0
- package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.js +1 -0
- package/dist/esm/shared/{getPageFiles → page-configs/serialize}/assertPageConfigs.d.ts +1 -1
- package/dist/esm/shared/{getPageFiles → page-configs/serialize}/assertPageConfigs.js +1 -1
- package/dist/esm/shared/page-configs/{parseConfigValuesImported.d.ts → serialize/parseConfigValuesImported.d.ts} +2 -1
- package/dist/esm/shared/page-configs/{parseConfigValuesImported.js → serialize/parseConfigValuesImported.js} +13 -10
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.d.ts +7 -0
- package/dist/esm/shared/{getPageFiles/parsePageConfigsSerialized.js → page-configs/serialize/parsePageConfigs.js} +5 -5
- package/dist/esm/shared/page-configs/serialize/serializeConfigValue.d.ts +8 -0
- package/dist/esm/shared/page-configs/serialize/serializeConfigValue.js +52 -0
- package/dist/esm/shared/page-configs/utils.d.ts +3 -3
- package/dist/esm/shared/page-configs/utils.js +11 -12
- package/dist/esm/shared/route/loadPageRoutes.js +1 -1
- package/dist/esm/utils/getOutDirs.d.ts +0 -2
- package/dist/esm/utils/getOutDirs.js +24 -17
- package/dist/esm/utils/getValuePrintable.js +1 -1
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/dist/esm/utils/projectInfo.js +1 -1
- package/dist/esm/utils/warnIfErrorIsNotObject.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/isConfigEnvMatch.js +0 -13
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isConfigEnvMatch.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isConfigEnvMatch.js +0 -10
- package/dist/esm/shared/getPageFiles/parsePageConfigsSerialized.d.ts +0 -6
|
@@ -11,11 +11,11 @@ const stringify_1 = require("@brillout/json-serializer/stringify");
|
|
|
11
11
|
const helpers_js_1 = require("./helpers.js");
|
|
12
12
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
13
13
|
const getVikeConfig_js_1 = require("./getVikeConfig.js");
|
|
14
|
-
const
|
|
15
|
-
const getVirtualFilePageConfigValuesAll_js_1 = require("./getVirtualFilePageConfigValuesAll.js");
|
|
14
|
+
const isRuntimeEnvMatch_js_1 = require("./isRuntimeEnvMatch.js");
|
|
16
15
|
const utils_js_2 = require("../../../../../shared/page-configs/utils.js");
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const serializeConfigValue_js_1 = require("../../../../../shared/page-configs/serialize/serializeConfigValue.js");
|
|
17
|
+
async function getVirtualFilePageConfigs(userRootDir, outDirRoot, isForClientSide, isDev, id, configVike, isClientRouting) {
|
|
18
|
+
const { pageConfigs, pageConfigGlobal } = await (0, getVikeConfig_js_1.getVikeConfig)(userRootDir, outDirRoot, isDev, configVike.extensions, true);
|
|
19
19
|
return getContent(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isClientRouting);
|
|
20
20
|
}
|
|
21
21
|
exports.getVirtualFilePageConfigs = getVirtualFilePageConfigs;
|
|
@@ -33,16 +33,29 @@ function getContent(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, i
|
|
|
33
33
|
lines.push(` routeFilesystem: ${JSON.stringify(routeFilesystem)},`);
|
|
34
34
|
lines.push(` loadConfigValuesAll: async () => (await import(${JSON.stringify(virtualFileIdPageConfigValuesAll)})).default,`);
|
|
35
35
|
lines.push(` configValuesSerialized: {`);
|
|
36
|
-
Object.entries(pageConfig.
|
|
36
|
+
Object.entries(pageConfig.configValuesComputed).forEach(([configName, configValuesComputed]) => {
|
|
37
|
+
const { value, configEnv } = configValuesComputed;
|
|
38
|
+
if (!(0, isRuntimeEnvMatch_js_1.isRuntimeEnvMatch)(configEnv, { isForClientSide, isClientRouting, isEager: true }))
|
|
39
|
+
return;
|
|
40
|
+
if (pageConfig.configValueSources[configName])
|
|
41
|
+
return;
|
|
42
|
+
const configValue = pageConfig.configValues[configName];
|
|
43
|
+
(0, utils_js_1.assert)(configValue);
|
|
44
|
+
const { definedAt } = configValue;
|
|
45
|
+
const valueSerialized = getConfigValueSerialized(value, configName, definedAt);
|
|
46
|
+
(0, serializeConfigValue_js_1.serializeConfigValue)(lines, configName, { definedAt, valueSerialized });
|
|
47
|
+
});
|
|
48
|
+
Object.entries(pageConfig.configValueSources).forEach(([configName]) => {
|
|
37
49
|
const configValue = pageConfig.configValues[configName];
|
|
38
50
|
if (configValue) {
|
|
39
|
-
const configEnv = (0, helpers_js_1.getConfigEnv)(pageConfig, configName);
|
|
51
|
+
const configEnv = (0, helpers_js_1.getConfigEnv)(pageConfig.configValueSources, configName);
|
|
40
52
|
(0, utils_js_1.assert)(configEnv, configName);
|
|
41
|
-
|
|
53
|
+
const isEnvMatch = (0, isRuntimeEnvMatch_js_1.isRuntimeEnvMatch)(configEnv, { isForClientSide, isClientRouting, isEager: true });
|
|
54
|
+
if (!isEnvMatch)
|
|
42
55
|
return;
|
|
43
56
|
const { value, definedAt } = configValue;
|
|
44
57
|
const valueSerialized = getConfigValueSerialized(value, configName, definedAt);
|
|
45
|
-
serializeConfigValue(lines, configName, { definedAt, valueSerialized });
|
|
58
|
+
(0, serializeConfigValue_js_1.serializeConfigValue)(lines, configName, { definedAt, valueSerialized });
|
|
46
59
|
}
|
|
47
60
|
});
|
|
48
61
|
lines.push(` },`);
|
|
@@ -56,8 +69,7 @@ function getContent(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, i
|
|
|
56
69
|
(0, utils_js_1.assert)(configValueSource);
|
|
57
70
|
if (configValueSource.configEnv !== '_routing-eager')
|
|
58
71
|
return;
|
|
59
|
-
(0,
|
|
60
|
-
lines.push(...(0, getVirtualFilePageConfigValuesAll_js_1.serializeConfigValueImported)(configValueSource, configName, whitespace, varCounterContainer, importStatements));
|
|
72
|
+
lines.push(...(0, serializeConfigValue_js_1.serializeConfigValueImported)(configValueSource, configName, whitespace, varCounterContainer, importStatements));
|
|
61
73
|
});
|
|
62
74
|
lines.push(`${whitespace}],`);
|
|
63
75
|
// pageConfig end
|
|
@@ -86,7 +98,7 @@ function getContent(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, i
|
|
|
86
98
|
const configValueSource = sources[0];
|
|
87
99
|
(0, utils_js_1.assert)(configValueSource);
|
|
88
100
|
const whitespace = ' ';
|
|
89
|
-
lines.push(...(0,
|
|
101
|
+
lines.push(...(0, serializeConfigValue_js_1.serializeConfigValueImported)(configValueSource, configName, whitespace, varCounterContainer, importStatements));
|
|
90
102
|
});
|
|
91
103
|
lines.push(` ],`);
|
|
92
104
|
lines.push('};');
|
|
@@ -94,29 +106,15 @@ function getContent(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, i
|
|
|
94
106
|
(0, debug_js_1.debug)(id, isForClientSide ? 'CLIENT-SIDE' : 'SERVER-SIDE', code);
|
|
95
107
|
return code;
|
|
96
108
|
}
|
|
97
|
-
function serializeConfigValue(lines, configName, configValueSerialized) {
|
|
98
|
-
let whitespace = ' ';
|
|
99
|
-
lines.push(`${whitespace}['${configName}']: {`);
|
|
100
|
-
whitespace += ' ';
|
|
101
|
-
Object.entries(configValueSerialized).forEach(([key, val]) => {
|
|
102
|
-
const valSerialized = key === 'definedAt' ? JSON.stringify(val) : val;
|
|
103
|
-
lines.push(`${whitespace} ${key}: ${valSerialized},`);
|
|
104
|
-
});
|
|
105
|
-
whitespace = whitespace.slice(2);
|
|
106
|
-
lines.push(`${whitespace}},`);
|
|
107
|
-
}
|
|
108
109
|
function getConfigValueSerialized(value, configName, definedAt) {
|
|
109
|
-
let configValueSerialized;
|
|
110
110
|
const valueName = `config${(0, utils_js_1.getPropAccessNotation)(configName)}`;
|
|
111
|
+
let configValueSerialized;
|
|
111
112
|
try {
|
|
112
113
|
configValueSerialized = (0, stringify_1.stringify)(value, { valueName });
|
|
113
114
|
}
|
|
114
115
|
catch (err) {
|
|
115
116
|
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(err, 'messageCore', 'string'));
|
|
116
117
|
const configValueFilePathToShowToUser = (0, utils_js_2.getConfigValueFilePathToShowToUser)({ definedAt });
|
|
117
|
-
// definedAt is null when config value is:
|
|
118
|
-
// - computed => all computed values defined by Vike can are serializable
|
|
119
|
-
// - cumulative => the values are already ensured to be serializable
|
|
120
118
|
(0, utils_js_1.assert)(configValueFilePathToShowToUser);
|
|
121
119
|
(0, utils_js_1.assertUsage)(false, [
|
|
122
120
|
`The value of the config ${picocolors_1.default.cyan(configName)} cannot be defined inside the file ${configValueFilePathToShowToUser}:`,
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.isConfigSet = exports.getConfigEnv = void 0;
|
|
4
4
|
const utils_js_1 = require("../../../utils.js");
|
|
5
5
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
6
|
-
function getConfigEnv(
|
|
7
|
-
const configValueSource = getConfigValueSource(
|
|
6
|
+
function getConfigEnv(configValueSources, configName) {
|
|
7
|
+
const configValueSource = getConfigValueSource(configValueSources, configName);
|
|
8
8
|
if (!configValueSource)
|
|
9
9
|
return null;
|
|
10
10
|
if (configValueSource) {
|
|
@@ -23,18 +23,16 @@ function getConfigEnv(pageConfig, configName) {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
exports.getConfigEnv = getConfigEnv;
|
|
26
|
-
function isConfigSet(
|
|
27
|
-
const configValueSource = getConfigValueSource(
|
|
26
|
+
function isConfigSet(configValueSources, configName) {
|
|
27
|
+
const configValueSource = getConfigValueSource(configValueSources, configName);
|
|
28
28
|
// Enable users to suppress global config values by overriding the config's value to null
|
|
29
29
|
if (configValueSource?.value === null)
|
|
30
30
|
return false;
|
|
31
31
|
return !!configValueSource;
|
|
32
32
|
}
|
|
33
33
|
exports.isConfigSet = isConfigSet;
|
|
34
|
-
function getConfigValueSource(
|
|
35
|
-
|
|
36
|
-
(0, utils_js_1.assert)(pageConfig.configValueSources);
|
|
37
|
-
const sources = pageConfig.configValueSources[configName];
|
|
34
|
+
function getConfigValueSource(configValueSources, configName) {
|
|
35
|
+
const sources = configValueSources[configName];
|
|
38
36
|
if (!sources)
|
|
39
37
|
return null;
|
|
40
38
|
const configValueSource = sources[0];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isRuntimeEnvMatch = void 0;
|
|
4
|
+
function isRuntimeEnvMatch(configEnv, runtime) {
|
|
5
|
+
const { isForClientSide, isClientRouting, isEager } = runtime;
|
|
6
|
+
if (configEnv === 'config-only')
|
|
7
|
+
return false;
|
|
8
|
+
if (configEnv === (isForClientSide ? 'server-only' : 'client-only'))
|
|
9
|
+
return false;
|
|
10
|
+
if (configEnv === '_routing-eager' || configEnv === '_routing-lazy') {
|
|
11
|
+
if (isForClientSide && !isClientRouting)
|
|
12
|
+
return false;
|
|
13
|
+
if (isEager !== (configEnv === '_routing-eager'))
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
exports.isRuntimeEnvMatch = isRuntimeEnvMatch;
|
|
@@ -9,8 +9,9 @@ const utils_js_1 = require("../utils.js");
|
|
|
9
9
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
10
10
|
async function findPageFiles(config, fileTypes, isDev) {
|
|
11
11
|
const cwd = config.root;
|
|
12
|
+
const { outDirRoot } = (0, utils_js_1.getOutDirs)(config);
|
|
12
13
|
const timeBase = new Date().getTime();
|
|
13
|
-
let pageFiles = await (0, fast_glob_1.default)(fileTypes.map((fileType) => `**/*${fileType}.${utils_js_1.scriptFileExtensions}`), { ignore: ['**/node_modules/**'], cwd, dot: false });
|
|
14
|
+
let pageFiles = await (0, fast_glob_1.default)(fileTypes.map((fileType) => `**/*${fileType}.${utils_js_1.scriptFileExtensions}`), { ignore: ['**/node_modules/**', `${outDirRoot}/**`], cwd, dot: false });
|
|
14
15
|
pageFiles = pageFiles.map((p) => '/' + (0, utils_js_1.toPosixPath)(p));
|
|
15
16
|
const time = new Date().getTime() - timeBase;
|
|
16
17
|
if (isDev) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Utils needed by
|
|
2
|
+
// Utils needed by Vike's Vite plugin.
|
|
3
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
4
|
if (k2 === undefined) k2 = k;
|
|
5
5
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -72,7 +72,7 @@ async function runPrerender(options, manuallyTriggered) {
|
|
|
72
72
|
const viteConfig = await (0, vite_1.resolveConfig)(options.viteConfig || {}, 'vike pre-rendering', 'production');
|
|
73
73
|
assertLoadedConfig(viteConfig, options);
|
|
74
74
|
const configVike = await (0, getConfigVike_js_1.getConfigVike)(viteConfig);
|
|
75
|
-
const { outDirClient, outDirRoot } = (0, utils_js_1.
|
|
75
|
+
const { outDirClient, outDirRoot } = (0, utils_js_1.getOutDirs)(viteConfig);
|
|
76
76
|
const { root } = viteConfig;
|
|
77
77
|
const prerenderConfig = configVike.prerender;
|
|
78
78
|
if (!prerenderConfig) {
|
|
@@ -115,13 +115,13 @@ async function collectDoNoPrerenderList(renderContext, doNotPrerenderList, concu
|
|
|
115
115
|
const configName = 'prerender';
|
|
116
116
|
const configValue = (0, utils_js_2.getConfigValue)(pageConfig, configName, 'boolean');
|
|
117
117
|
if (configValue?.value === false) {
|
|
118
|
-
const
|
|
119
|
-
(0, utils_js_1.assert)(
|
|
118
|
+
const configValueFilePathToShowToUser = (0, utils_js_2.getConfigValueFilePathToShowToUser)(configValue);
|
|
119
|
+
(0, utils_js_1.assert)(configValueFilePathToShowToUser);
|
|
120
120
|
doNotPrerenderList.push({
|
|
121
121
|
pageId: pageConfig.pageId,
|
|
122
122
|
setByConfigName: 'prerender',
|
|
123
123
|
setByConfigValue: false,
|
|
124
|
-
setByConfigFile:
|
|
124
|
+
setByConfigFile: configValueFilePathToShowToUser
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
});
|
|
@@ -311,7 +311,7 @@ function getRequestId() {
|
|
|
311
311
|
}
|
|
312
312
|
function skipRequest(urlOriginal) {
|
|
313
313
|
const isViteClientRequest = urlOriginal.endsWith('/@vite/client') || urlOriginal.startsWith('/@fs/');
|
|
314
|
-
(0, utils_js_1.assertWarning)(!isViteClientRequest, `The vike middleware renderPage() was called with the URL ${urlOriginal} which is unexpected because the HTTP request should have already been handled by Vite's development middleware. Make sure to 1. install Vite's development middleware and 2. add Vite's middleware *before*
|
|
314
|
+
(0, utils_js_1.assertWarning)(!isViteClientRequest, `The vike middleware renderPage() was called with the URL ${urlOriginal} which is unexpected because the HTTP request should have already been handled by Vite's development middleware. Make sure to 1. install Vite's development middleware and 2. add Vite's middleware *before* Vike's middleware, see https://vike.dev/renderPage`, { onlyOnce: true });
|
|
315
315
|
return (urlOriginal.endsWith('/__vite_ping') ||
|
|
316
316
|
urlOriginal.endsWith('/favicon.ico') ||
|
|
317
317
|
!(0, utils_js_1.isParsable)(urlOriginal) ||
|
|
@@ -15,7 +15,7 @@ function assertPageContextProvidedByUser(pageContextProvidedByUser, { hookName,
|
|
|
15
15
|
(0, utils_js_1.assertUsage)(!('_objectCreatedByVike' in pageContextProvidedByUser), `${errPrefix} shouldn't be the whole ${picocolors_1.default.cyan('pageContext')} object, see https://vike.dev/pageContext-manipulation#do-not-return-entire-pagecontext`);
|
|
16
16
|
// In principle, it's possible to use onBeforeRoute()` to override and define the whole routing.
|
|
17
17
|
// Is that a good idea to allow users to do this? Beyond deep integration with Vue Router or React Router, is there a use case for this?
|
|
18
|
-
(0, utils_js_1.assertWarning)(!('_pageId' in pageContextProvidedByUser), `${errPrefix} sets ${picocolors_1.default.cyan('pageContext._pageId')} which means that
|
|
18
|
+
(0, utils_js_1.assertWarning)(!('_pageId' in pageContextProvidedByUser), `${errPrefix} sets ${picocolors_1.default.cyan('pageContext._pageId')} which means that Vike's routing is overriden. This is an experimental feature: make sure to contact a vike maintainer before using this.`, { onlyOnce: true });
|
|
19
19
|
(0, utils_js_1.assertUsage)(!('is404' in pageContextProvidedByUser), `${errPrefix} sets ${picocolors_1.default.cyan('pageContext.is404')} which is forbidden, use ${picocolors_1.default.cyan('throw render()')} instead, see https://vike.dev/render`);
|
|
20
20
|
}
|
|
21
21
|
exports.assertPageContextProvidedByUser = assertPageContextProvidedByUser;
|
|
@@ -34,7 +34,7 @@ function getExports(pageFiles, pageConfig) {
|
|
|
34
34
|
if (pageConfig) {
|
|
35
35
|
Object.entries(pageConfig.configValues).forEach(([configName, configValue]) => {
|
|
36
36
|
const { value } = configValue;
|
|
37
|
-
const
|
|
37
|
+
const configValueFilePathToShowToUser = (0, utils_js_2.getConfigValueFilePathToShowToUser)(configValue);
|
|
38
38
|
const configDefinedAt = (0, utils_js_2.getConfigDefinedAtString)(configName, configValue, true);
|
|
39
39
|
config[configName] = config[configName] ?? value;
|
|
40
40
|
configEntries[configName] = configEntries[configName] ?? [];
|
|
@@ -43,7 +43,7 @@ function getExports(pageFiles, pageConfig) {
|
|
|
43
43
|
configEntries[configName].push({
|
|
44
44
|
configValue: value,
|
|
45
45
|
configDefinedAt,
|
|
46
|
-
configDefinedByFile:
|
|
46
|
+
configDefinedByFile: configValueFilePathToShowToUser
|
|
47
47
|
});
|
|
48
48
|
// TODO/v1-release: remove
|
|
49
49
|
const exportName = configName;
|
|
@@ -51,8 +51,8 @@ function getExports(pageFiles, pageConfig) {
|
|
|
51
51
|
exportsAll[exportName].push({
|
|
52
52
|
exportValue: value,
|
|
53
53
|
exportSource: configDefinedAt,
|
|
54
|
-
filePath,
|
|
55
|
-
_filePath:
|
|
54
|
+
filePath: configValueFilePathToShowToUser,
|
|
55
|
+
_filePath: configValueFilePathToShowToUser,
|
|
56
56
|
_fileType: null,
|
|
57
57
|
_isFromDefaultExport: null
|
|
58
58
|
});
|
|
@@ -5,8 +5,8 @@ const utils_js_1 = require("../utils.js");
|
|
|
5
5
|
const assert_exports_old_design_js_1 = require("./assert_exports_old_design.js");
|
|
6
6
|
const getPageFileObject_js_1 = require("./getPageFileObject.js");
|
|
7
7
|
const fileTypes_js_1 = require("./fileTypes.js");
|
|
8
|
-
const assertPageConfigs_js_1 = require("
|
|
9
|
-
const
|
|
8
|
+
const assertPageConfigs_js_1 = require("../page-configs/serialize/assertPageConfigs.js");
|
|
9
|
+
const parsePageConfigs_js_1 = require("../page-configs/serialize/parsePageConfigs.js");
|
|
10
10
|
function parseGlobResults(pageFilesExports) {
|
|
11
11
|
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageFilesExports, 'isGeneratedFile'));
|
|
12
12
|
(0, utils_js_1.assert)(pageFilesExports.isGeneratedFile !== false, `vike was re-installed(/re-built). Restart your app.`);
|
|
@@ -23,7 +23,7 @@ function parseGlobResults(pageFilesExports) {
|
|
|
23
23
|
const { pageConfigsSerialized, pageConfigGlobalSerialized } = pageFilesExports;
|
|
24
24
|
(0, assertPageConfigs_js_1.assertPageConfigsSerialized)(pageConfigsSerialized);
|
|
25
25
|
(0, assertPageConfigs_js_1.assertPageConfigGlobalSerialized)(pageConfigGlobalSerialized);
|
|
26
|
-
const { pageConfigs, pageConfigGlobal } = (0,
|
|
26
|
+
const { pageConfigs, pageConfigGlobal } = (0, parsePageConfigs_js_1.parsePageConfigs)(pageConfigsSerialized, pageConfigGlobalSerialized);
|
|
27
27
|
const pageFilesMap = {};
|
|
28
28
|
parseGlobResult(pageFilesExports.pageFilesLazy).forEach(({ filePath, pageFile, globValue }) => {
|
|
29
29
|
pageFile = pageFilesMap[filePath] = pageFilesMap[filePath] ?? pageFile;
|
|
@@ -2,19 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getExportPath = void 0;
|
|
4
4
|
const utils_js_1 = require("../utils.js");
|
|
5
|
-
function getExportPath(fileExportPath) {
|
|
5
|
+
function getExportPath(fileExportPath, configName) {
|
|
6
6
|
if (!fileExportPath)
|
|
7
7
|
return null;
|
|
8
|
-
let prefix = '';
|
|
9
|
-
let suffix = '';
|
|
10
8
|
let [exportName, ...exportObjectPath] = fileExportPath;
|
|
11
9
|
if (!exportName)
|
|
12
10
|
return null;
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
if (exportObjectPath.length === 0 && ['*', 'default', configName].includes(exportName))
|
|
12
|
+
return null;
|
|
13
|
+
(0, utils_js_1.assert)(exportName !== '*');
|
|
14
|
+
let prefix = '';
|
|
15
|
+
let suffix = '';
|
|
16
|
+
if (exportName === 'default') {
|
|
18
17
|
prefix = 'export default';
|
|
19
18
|
}
|
|
20
19
|
else {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadConfigValues = void 0;
|
|
4
4
|
const utils_js_1 = require("../utils.js");
|
|
5
|
-
const parseConfigValuesImported_js_1 = require("./parseConfigValuesImported.js");
|
|
5
|
+
const parseConfigValuesImported_js_1 = require("./serialize/parseConfigValuesImported.js");
|
|
6
6
|
async function loadConfigValues(pageConfig, isDev) {
|
|
7
7
|
if ('isLoaded' in pageConfig &&
|
|
8
8
|
// We don't need to cache in dev, since Vite already caches the virtual module
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.assertPageConfigGlobalSerialized = exports.assertPageConfigsSerialized = void 0;
|
|
4
|
-
const utils_js_1 = require("
|
|
4
|
+
const utils_js_1 = require("../../utils.js");
|
|
5
5
|
function assertPageConfigsSerialized(pageConfigsSerialized) {
|
|
6
6
|
(0, utils_js_1.assert)(Array.isArray(pageConfigsSerialized));
|
|
7
7
|
pageConfigsSerialized.forEach((pageConfigSerialized) => {
|
|
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.parseConfigValuesImported = void 0;
|
|
7
|
-
const utils_js_1 = require("
|
|
8
|
-
const assertExports_js_1 = require("
|
|
7
|
+
const utils_js_1 = require("../../utils.js");
|
|
8
|
+
const assertExports_js_1 = require("../assertExports.js");
|
|
9
9
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
10
10
|
function parseConfigValuesImported(configValuesImported) {
|
|
11
11
|
const configValues = {};
|
|
@@ -13,10 +13,13 @@ function parseConfigValuesImported(configValuesImported) {
|
|
|
13
13
|
configValues[configName] = {
|
|
14
14
|
value,
|
|
15
15
|
definedAt: {
|
|
16
|
-
|
|
17
|
-
// importPath
|
|
16
|
+
file: {
|
|
17
|
+
// importPath cannot be relative to the current file, since the current file is a virtual file
|
|
18
18
|
filePathToShowToUser: importPath,
|
|
19
|
-
fileExportPath: [exportName
|
|
19
|
+
fileExportPath: [configName, 'default'].includes(exportName)
|
|
20
|
+
? []
|
|
21
|
+
: // Side-effect config
|
|
22
|
+
[exportName]
|
|
20
23
|
}
|
|
21
24
|
}
|
|
22
25
|
};
|
|
@@ -24,11 +27,11 @@ function parseConfigValuesImported(configValuesImported) {
|
|
|
24
27
|
};
|
|
25
28
|
configValuesImported.forEach((configValueLoaded) => {
|
|
26
29
|
if (configValueLoaded.isValueFile) {
|
|
27
|
-
const {
|
|
30
|
+
const { exportValues, importPath, configName } = configValueLoaded;
|
|
28
31
|
if (configName !== 'client') {
|
|
29
|
-
(0, assertExports_js_1.assertExportsOfValueFile)(
|
|
32
|
+
(0, assertExports_js_1.assertExportsOfValueFile)(exportValues, importPath, configName);
|
|
30
33
|
}
|
|
31
|
-
Object.entries(
|
|
34
|
+
Object.entries(exportValues).forEach(([exportName, exportValue]) => {
|
|
32
35
|
const isSideExport = exportName !== 'default'; // .md files may have "side-exports" such as `export { frontmatter }`
|
|
33
36
|
const configName = isSideExport ? exportName : configValueLoaded.configName;
|
|
34
37
|
if (isSideExport && configName in configValues) {
|
|
@@ -40,8 +43,8 @@ function parseConfigValuesImported(configValuesImported) {
|
|
|
40
43
|
});
|
|
41
44
|
}
|
|
42
45
|
else {
|
|
43
|
-
const { configName, importPath,
|
|
44
|
-
addConfigValue(configName,
|
|
46
|
+
const { configName, importPath, exportValue, exportName } = configValueLoaded;
|
|
47
|
+
addConfigValue(configName, exportValue, importPath, exportName);
|
|
45
48
|
}
|
|
46
49
|
});
|
|
47
50
|
return configValues;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.parsePageConfigs = void 0;
|
|
4
4
|
const parse_1 = require("@brillout/json-serializer/parse");
|
|
5
|
-
const parseConfigValuesImported_js_1 = require("
|
|
6
|
-
const utils_js_1 = require("
|
|
7
|
-
const utils_js_2 = require("../
|
|
8
|
-
function
|
|
5
|
+
const parseConfigValuesImported_js_1 = require("./parseConfigValuesImported.js");
|
|
6
|
+
const utils_js_1 = require("../../utils.js");
|
|
7
|
+
const utils_js_2 = require("../utils.js");
|
|
8
|
+
function parsePageConfigs(pageConfigsSerialized, pageConfigGlobalSerialized) {
|
|
9
9
|
const pageConfigs = pageConfigsSerialized.map((pageConfigSerialized) => {
|
|
10
10
|
const configValues = {};
|
|
11
11
|
{
|
|
@@ -44,7 +44,7 @@ function parsePageConfigsSerialized(pageConfigsSerialized, pageConfigGlobalSeria
|
|
|
44
44
|
}
|
|
45
45
|
return { pageConfigs, pageConfigGlobal };
|
|
46
46
|
}
|
|
47
|
-
exports.
|
|
47
|
+
exports.parsePageConfigs = parsePageConfigs;
|
|
48
48
|
function assertRouteConfigValue(configValues) {
|
|
49
49
|
const configName = 'route';
|
|
50
50
|
const configValue = configValues[configName];
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.serializeConfigValueImported = exports.serializeConfigValue = void 0;
|
|
7
|
+
// This file is never loaded on the client-side but we save it under the vike/shared/ directory in order to collocate it with:
|
|
8
|
+
// - vike/shared/page-configs/serialize/parsePageConfigs.ts
|
|
9
|
+
// - vike/shared/page-configs/serialize/parseConfigValuesImported.ts
|
|
10
|
+
// Both parsePageConfigs() parseConfigValuesImported() and are loaded on the client-side and server-side
|
|
11
|
+
const assertIsNotProductionRuntime_js_1 = require("../../../utils/assertIsNotProductionRuntime.js");
|
|
12
|
+
(0, assertIsNotProductionRuntime_js_1.assertIsNotProductionRuntime)();
|
|
13
|
+
const path_1 = __importDefault(require("path"));
|
|
14
|
+
const utils_js_1 = require("../../utils.js");
|
|
15
|
+
const generateEagerImport_js_1 = require("../../../node/plugin/plugins/importUserCode/generateEagerImport.js");
|
|
16
|
+
function serializeConfigValue(lines, configName, configValueSerialized) {
|
|
17
|
+
let whitespace = ' ';
|
|
18
|
+
lines.push(`${whitespace}['${configName}']: {`);
|
|
19
|
+
whitespace += ' ';
|
|
20
|
+
Object.entries(configValueSerialized).forEach(([key, val]) => {
|
|
21
|
+
const valSerialized = key === 'definedAt' ? JSON.stringify(val) : val;
|
|
22
|
+
lines.push(`${whitespace} ${key}: ${valSerialized},`);
|
|
23
|
+
});
|
|
24
|
+
whitespace = whitespace.slice(2);
|
|
25
|
+
lines.push(`${whitespace}},`);
|
|
26
|
+
}
|
|
27
|
+
exports.serializeConfigValue = serializeConfigValue;
|
|
28
|
+
function serializeConfigValueImported(configValueSource, configName, whitespace, varCounterContainer, importStatements) {
|
|
29
|
+
(0, utils_js_1.assert)(!configValueSource.valueIsFilePath);
|
|
30
|
+
(0, utils_js_1.assert)(whitespace.replaceAll(' ', '').length === 0);
|
|
31
|
+
const { valueIsImportedAtRuntime, definedAtInfo } = configValueSource;
|
|
32
|
+
(0, utils_js_1.assert)(valueIsImportedAtRuntime);
|
|
33
|
+
const { filePathRelativeToUserRootDir, importPathAbsolute, exportName } = definedAtInfo;
|
|
34
|
+
const importPath = filePathRelativeToUserRootDir ?? importPathAbsolute;
|
|
35
|
+
(0, utils_js_1.assertPosixPath)(importPath);
|
|
36
|
+
const fileName = path_1.default.posix.basename(importPath);
|
|
37
|
+
const isValueFile = fileName.startsWith('+');
|
|
38
|
+
if (isValueFile)
|
|
39
|
+
(0, utils_js_1.assert)(exportName === undefined);
|
|
40
|
+
const { importName, importStatement } = (0, generateEagerImport_js_1.generateEagerImport)(importPath, varCounterContainer.varCounter++, exportName);
|
|
41
|
+
importStatements.push(importStatement);
|
|
42
|
+
const lines = [];
|
|
43
|
+
lines.push(` {`);
|
|
44
|
+
lines.push(` configName: '${configName}',`);
|
|
45
|
+
lines.push(` importPath: '${importPath}',`);
|
|
46
|
+
lines.push(` isValueFile: ${JSON.stringify(isValueFile)},`);
|
|
47
|
+
if (isValueFile) {
|
|
48
|
+
lines.push(` exportValues: ${importName},`);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
lines.push(` exportValue: ${importName},`);
|
|
52
|
+
(0, utils_js_1.assert)(exportName);
|
|
53
|
+
lines.push(` exportName: ${JSON.stringify(exportName)},`);
|
|
54
|
+
}
|
|
55
|
+
lines.push(` },`);
|
|
56
|
+
return lines;
|
|
57
|
+
}
|
|
58
|
+
exports.serializeConfigValueImported = serializeConfigValueImported;
|
|
@@ -45,27 +45,27 @@ function getPageConfig(pageId, pageConfigs) {
|
|
|
45
45
|
}
|
|
46
46
|
exports.getPageConfig = getPageConfig;
|
|
47
47
|
function getConfigDefinedAtString(configName, { definedAt }, sentenceBegin) {
|
|
48
|
-
const configDefinedAt = `${sentenceBegin ? `Config` : `config`} ${picocolors_1.default.cyan(configName)} defined ${getSourceString(definedAt)}`;
|
|
48
|
+
const configDefinedAt = `${sentenceBegin ? `Config` : `config`} ${picocolors_1.default.cyan(configName)} defined ${getSourceString(definedAt, configName)}`;
|
|
49
49
|
return configDefinedAt;
|
|
50
50
|
}
|
|
51
51
|
exports.getConfigDefinedAtString = getConfigDefinedAtString;
|
|
52
|
-
function getSourceString(definedAt) {
|
|
52
|
+
function getSourceString(definedAt, configName) {
|
|
53
53
|
if (definedAt.isComputed) {
|
|
54
54
|
return 'internally';
|
|
55
55
|
}
|
|
56
|
-
let
|
|
56
|
+
let files;
|
|
57
57
|
if (definedAt.isCumulative) {
|
|
58
|
-
|
|
58
|
+
files = definedAt.files;
|
|
59
59
|
}
|
|
60
60
|
else {
|
|
61
|
-
|
|
61
|
+
files = [definedAt.file];
|
|
62
62
|
}
|
|
63
|
-
(0, utils_js_1.assert)(
|
|
64
|
-
const sourceString =
|
|
63
|
+
(0, utils_js_1.assert)(files.length >= 1);
|
|
64
|
+
const sourceString = files
|
|
65
65
|
.map((source) => {
|
|
66
66
|
const { filePathToShowToUser, fileExportPath } = source;
|
|
67
67
|
let s = filePathToShowToUser;
|
|
68
|
-
const exportPath = (0, getExportPath_js_1.getExportPath)(fileExportPath);
|
|
68
|
+
const exportPath = (0, getExportPath_js_1.getExportPath)(fileExportPath, configName);
|
|
69
69
|
if (exportPath) {
|
|
70
70
|
s = `${s} > ${picocolors_1.default.cyan(exportPath)}`;
|
|
71
71
|
}
|
|
@@ -77,8 +77,8 @@ function getSourceString(definedAt) {
|
|
|
77
77
|
.join(' / ');
|
|
78
78
|
return `at ${sourceString}`;
|
|
79
79
|
}
|
|
80
|
-
function getDefinedAtString(configValue) {
|
|
81
|
-
let sourceString = getSourceString(configValue.definedAt);
|
|
80
|
+
function getDefinedAtString(configValue, configName) {
|
|
81
|
+
let sourceString = getSourceString(configValue.definedAt, configName);
|
|
82
82
|
if (sourceString.startsWith('at '))
|
|
83
83
|
sourceString = sourceString.slice('at '.length);
|
|
84
84
|
return sourceString;
|
|
@@ -90,8 +90,7 @@ function getConfigValueFilePathToShowToUser({ definedAt }) {
|
|
|
90
90
|
// - computed values don't have any file path
|
|
91
91
|
if (definedAt.isComputed || definedAt.isCumulative)
|
|
92
92
|
return null;
|
|
93
|
-
const {
|
|
94
|
-
const { filePathToShowToUser } = source;
|
|
93
|
+
const { filePathToShowToUser } = definedAt.file;
|
|
95
94
|
(0, utils_js_1.assert)(filePathToShowToUser);
|
|
96
95
|
return filePathToShowToUser;
|
|
97
96
|
}
|
|
@@ -34,7 +34,7 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
|
|
|
34
34
|
const configValue = (0, utils_js_3.getConfigValue)(pageConfig, configName);
|
|
35
35
|
if (configValue) {
|
|
36
36
|
const route = configValue.value;
|
|
37
|
-
const definedAt = (0, utils_js_3.getDefinedAtString)(configValue);
|
|
37
|
+
const definedAt = (0, utils_js_3.getDefinedAtString)(configValue, configName);
|
|
38
38
|
if (typeof route === 'string') {
|
|
39
39
|
pageRoute = {
|
|
40
40
|
pageId,
|
|
@@ -3,30 +3,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.resolveOutDir = exports.
|
|
6
|
+
exports.resolveOutDir = exports.getOutDirs = void 0;
|
|
7
7
|
const viteIsSSR_js_1 = require("./viteIsSSR.js");
|
|
8
8
|
const assert_js_1 = require("./assert.js");
|
|
9
9
|
const path_shim_js_1 = require("./path-shim.js");
|
|
10
10
|
const filesystemPathHandling_js_1 = require("./filesystemPathHandling.js");
|
|
11
11
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
12
12
|
function getOutDirs(config) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
let outDirRoot;
|
|
14
|
+
{
|
|
15
|
+
const outDir = getOutDirFromViteResolvedConfig(config);
|
|
16
|
+
if (isOutDirRoot(outDir)) {
|
|
17
|
+
outDirRoot = outDir;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
assertOutDirResolved(outDir, config);
|
|
21
|
+
(0, assert_js_1.assert)(outDir.endsWith('/server') || outDir.endsWith('/client'));
|
|
22
|
+
(0, assert_js_1.assert)('/client'.length === '/server'.length);
|
|
23
|
+
outDirRoot = outDir.slice(0, -1 * '/client'.length);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
18
26
|
return getOutDirsAll(outDirRoot, config.root);
|
|
19
27
|
}
|
|
20
28
|
exports.getOutDirs = getOutDirs;
|
|
21
|
-
function getOutDirs_prerender(config) {
|
|
22
|
-
const outDirRoot = getOutDirFromResolvedConfig(config);
|
|
23
|
-
(0, assert_js_1.assert)(isOutDirRoot(outDirRoot));
|
|
24
|
-
return getOutDirsAll(outDirRoot, config.root);
|
|
25
|
-
}
|
|
26
|
-
exports.getOutDirs_prerender = getOutDirs_prerender;
|
|
27
29
|
/** Appends `client/` or `server/` to `config.build.outDir` */
|
|
28
30
|
function resolveOutDir(config) {
|
|
29
|
-
const outDir =
|
|
31
|
+
const outDir = getOutDirFromViteUserConfig(config) || 'dist';
|
|
30
32
|
// outDir may already be resolved when using Telefunc + vike (because both Telefunc and vike use this logic)
|
|
31
33
|
if (!isOutDirRoot(outDir)) {
|
|
32
34
|
assertOutDirResolved(outDir, config);
|
|
@@ -45,6 +47,7 @@ function resolveOutDir(config) {
|
|
|
45
47
|
exports.resolveOutDir = resolveOutDir;
|
|
46
48
|
function determineOutDirs(outDirRoot) {
|
|
47
49
|
(0, filesystemPathHandling_js_1.assertPosixPath)(outDirRoot);
|
|
50
|
+
(0, assert_js_1.assert)(!outDirRoot.endsWith('/'));
|
|
48
51
|
(0, assert_js_1.assert)(isOutDirRoot(outDirRoot));
|
|
49
52
|
const outDirClient = (0, path_shim_js_1.pathJoin)(outDirRoot, 'client');
|
|
50
53
|
const outDirServer = (0, path_shim_js_1.pathJoin)(outDirRoot, 'server');
|
|
@@ -95,18 +98,22 @@ function assertOutDirResolved(outDir, config) {
|
|
|
95
98
|
(0, assert_js_1.assertUsage)(outDir.endsWith('/client'), wrongUsage);
|
|
96
99
|
}
|
|
97
100
|
}
|
|
98
|
-
function
|
|
101
|
+
function getOutDirFromViteUserConfig(config) {
|
|
99
102
|
let outDir = config.build?.outDir;
|
|
100
103
|
if (outDir === undefined)
|
|
101
104
|
return undefined;
|
|
102
|
-
|
|
103
|
-
outDir = (0, filesystemPathHandling_js_1.toPosixPath)(outDir);
|
|
105
|
+
outDir = normalize(outDir);
|
|
104
106
|
return outDir;
|
|
105
107
|
}
|
|
106
|
-
function
|
|
108
|
+
function getOutDirFromViteResolvedConfig(config) {
|
|
107
109
|
let outDir = config.build.outDir;
|
|
108
|
-
|
|
110
|
+
(0, assert_js_1.assert)(outDir);
|
|
111
|
+
outDir = normalize(outDir);
|
|
112
|
+
return outDir;
|
|
113
|
+
}
|
|
114
|
+
function normalize(outDir) {
|
|
109
115
|
outDir = (0, filesystemPathHandling_js_1.toPosixPath)(outDir);
|
|
116
|
+
outDir = outDir.replace(/\/+$/, ''); // remove trailing slashes
|
|
110
117
|
return outDir;
|
|
111
118
|
}
|
|
112
119
|
function outDirIsAbsolutePath(outDir) {
|
|
@@ -4,7 +4,7 @@ exports.getValuePrintable = void 0;
|
|
|
4
4
|
function getValuePrintable(value) {
|
|
5
5
|
if ([null, undefined].includes(value))
|
|
6
6
|
return String(value);
|
|
7
|
-
if (['
|
|
7
|
+
if (['boolean', 'number', 'string'].includes(typeof value))
|
|
8
8
|
return JSON.stringify(value);
|
|
9
9
|
return null;
|
|
10
10
|
}
|