vike 0.4.237-commit-e549c30 → 0.4.237-commit-92dc549
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/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +0 -8
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js +51 -21
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +20 -36
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +0 -8
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.d.ts +5 -1
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js +52 -22
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.d.ts +3 -2
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +21 -37
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal.d.ts +2 -0
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/package.json +2 -2
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* We create a file `dist/server/package.json` to support ESM users.
|
|
4
|
-
* Otherwise, following error is thrown:
|
|
5
|
-
* Must use import to load ES Module: dist/server/pageFiles.js
|
|
6
|
-
* require() of ES modules is not supported.
|
|
7
|
-
* require() of dist/server/pageFiles.js from node_modules/vike/dist/esm/node/runtime/page-files/setup.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
|
|
8
|
-
* Reproduction: https://github.com/brillout/vite-plugin-ssr-server-import-syntax
|
|
9
|
-
*/
|
|
10
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
3
|
exports.pluginDistPackageJsonFile = pluginDistPackageJsonFile;
|
|
12
4
|
const rollupIsEsm_js_1 = require("../../shared/rollupIsEsm.js");
|
|
@@ -1,30 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getConfigValueSourcesRelevant = getConfigValueSourcesRelevant;
|
|
4
|
+
exports.getConfigValueSourceRelevantAnyEnv = getConfigValueSourceRelevantAnyEnv;
|
|
4
5
|
exports.isRuntimeEnvMatch = isRuntimeEnvMatch;
|
|
6
|
+
exports.isConfigSourceValueNull = isConfigSourceValueNull;
|
|
5
7
|
const utils_js_1 = require("../../utils.js");
|
|
8
|
+
(0, utils_js_1.assertIsNotBrowser)();
|
|
6
9
|
function getConfigValueSourcesRelevant(configName, runtimeEnv, pageConfig) {
|
|
7
10
|
const configDef = pageConfig.configDefinitions[configName];
|
|
8
11
|
(0, utils_js_1.assert)(configDef);
|
|
9
12
|
let sourcesRelevant = pageConfig.configValueSources[configName];
|
|
10
13
|
if (!sourcesRelevant)
|
|
11
14
|
return [];
|
|
12
|
-
|
|
15
|
+
// Ignore configs with value `undefined`
|
|
16
|
+
sourcesRelevant = sourcesRelevant.filter((source) => !isConfigSourceValueUndefined(source));
|
|
17
|
+
// Environment filtering
|
|
18
|
+
sourcesRelevant = sourcesRelevant.filter((source) => isRuntimeEnvMatch(source.configEnv, runtimeEnv));
|
|
19
|
+
// Overriding - non-cumulative configs
|
|
20
|
+
if (!configDef.cumulative && sourcesRelevant.length > 1) {
|
|
13
21
|
const source = sourcesRelevant[0];
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
(0, utils_js_1.assert)(sourcesRelevant.length === 0);
|
|
19
|
-
}
|
|
22
|
+
(0, utils_js_1.assert)(source);
|
|
23
|
+
sourcesRelevant = [source];
|
|
20
24
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
sourcesRelevant = sourcesRelevant
|
|
25
|
+
// Overriding - cumulative configs
|
|
26
|
+
if (configDef.cumulative && sourcesRelevant.length > 0) {
|
|
27
|
+
sourcesRelevant = applyFilenameSuffix(sourcesRelevant);
|
|
24
28
|
}
|
|
25
|
-
sourcesRelevant = sourcesRelevant.filter((source) => isRuntimeEnvMatch(source.configEnv, runtimeEnv));
|
|
26
29
|
return sourcesRelevant;
|
|
27
30
|
}
|
|
31
|
+
function getConfigValueSourceRelevantAnyEnv(configName, pageConfig) {
|
|
32
|
+
const configDef = pageConfig.configDefinitions[configName];
|
|
33
|
+
(0, utils_js_1.assert)(configDef);
|
|
34
|
+
(0, utils_js_1.assert)(!configDef.cumulative); // So far, this function is only used by non-cumulative configs
|
|
35
|
+
let sourcesRelevant = pageConfig.configValueSources[configName];
|
|
36
|
+
if (!sourcesRelevant)
|
|
37
|
+
return null;
|
|
38
|
+
// Ignore configs with value `undefined`
|
|
39
|
+
sourcesRelevant = sourcesRelevant.filter((source) => !isConfigSourceValueUndefined(source));
|
|
40
|
+
const source = sourcesRelevant[0];
|
|
41
|
+
if (!source)
|
|
42
|
+
return null;
|
|
43
|
+
if (isConfigSourceValueNull(source))
|
|
44
|
+
return null;
|
|
45
|
+
return source;
|
|
46
|
+
}
|
|
28
47
|
function isRuntimeEnvMatch(configEnv, runtimeEnv) {
|
|
29
48
|
if ('isForConfig' in runtimeEnv)
|
|
30
49
|
return !!configEnv.config;
|
|
@@ -54,14 +73,25 @@ function isRuntimeEnvMatch(configEnv, runtimeEnv) {
|
|
|
54
73
|
}
|
|
55
74
|
return true;
|
|
56
75
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
(
|
|
66
|
-
|
|
76
|
+
// Setting a config to `undefined` should be equivalent to not setting it at all
|
|
77
|
+
function isConfigSourceValueUndefined(source) {
|
|
78
|
+
if (!source.valueIsLoaded)
|
|
79
|
+
return null;
|
|
80
|
+
return source.value === undefined;
|
|
81
|
+
}
|
|
82
|
+
// Setting a config to `null` enables the user to suppress inherited config by overriding it with `null` (this only works when setting the config value to `null` inside a +config.js file — it doesn't work when setting the config value to `null` with a +{configName}.js file).
|
|
83
|
+
function isConfigSourceValueNull(source) {
|
|
84
|
+
if (!source.valueIsLoaded)
|
|
85
|
+
return null;
|
|
86
|
+
return source.value === null;
|
|
87
|
+
}
|
|
88
|
+
function applyFilenameSuffix(sourcesRelevant) {
|
|
89
|
+
const getFileName = (source) => source.plusFile?.filePath.fileName ?? '';
|
|
90
|
+
// Apply `clear`: truncate at first clear file
|
|
91
|
+
const clearIndex = sourcesRelevant.findIndex((source) => getFileName(source).includes('.clear.'));
|
|
92
|
+
if (clearIndex !== -1)
|
|
93
|
+
sourcesRelevant = sourcesRelevant.slice(0, clearIndex + 1);
|
|
94
|
+
// Apply `default`: exclude defaults if any non-defaults exist, otherwise keep only first default
|
|
95
|
+
const nonDefaults = sourcesRelevant.filter((source) => !getFileName(source).includes('.default.'));
|
|
96
|
+
return nonDefaults.length > 0 ? nonDefaults : sourcesRelevant.slice(0, 1);
|
|
67
97
|
}
|
|
@@ -110,7 +110,9 @@ const configDefinitionsBuiltIn = {
|
|
|
110
110
|
}, pageConfig))
|
|
111
111
|
.flat(1)
|
|
112
112
|
// Server-only
|
|
113
|
-
.filter((source) => !source.configEnv.client)
|
|
113
|
+
.filter((source) => !source.configEnv.client)
|
|
114
|
+
// Config value isn't `null`
|
|
115
|
+
.filter((source) => !(0, getConfigValueSourcesRelevant_js_1.isConfigSourceValueNull)(source));
|
|
114
116
|
return sources.length > 0;
|
|
115
117
|
},
|
|
116
118
|
},
|
|
@@ -122,22 +124,19 @@ const configDefinitionsBuiltIn = {
|
|
|
122
124
|
env: { server: true, client: true },
|
|
123
125
|
eager: true,
|
|
124
126
|
_computed: (pageConfig) => {
|
|
125
|
-
const { configValueSources } = pageConfig;
|
|
126
127
|
{
|
|
127
|
-
const source =
|
|
128
|
+
const source = (0, getConfigValueSourcesRelevant_js_1.getConfigValueSourceRelevantAnyEnv)('clientHooks', pageConfig);
|
|
128
129
|
if (source) {
|
|
129
130
|
(0, utils_js_1.assert)(source.valueIsLoaded);
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return value;
|
|
135
|
-
}
|
|
131
|
+
const { value, definedAt } = source;
|
|
132
|
+
const configDefinedAt = (0, getConfigDefinedAt_js_1.getConfigDefinedAt)('Config', 'clientHooks', definedAt);
|
|
133
|
+
(0, utils_js_1.assertUsage)(typeof value === 'boolean', `${configDefinedAt} should be a boolean`);
|
|
134
|
+
return value;
|
|
136
135
|
}
|
|
137
136
|
}
|
|
138
|
-
return (isConfigSet(
|
|
139
|
-
isConfigSet(
|
|
140
|
-
!!getConfigEnv(
|
|
137
|
+
return (isConfigSet(pageConfig, 'onRenderClient') &&
|
|
138
|
+
isConfigSet(pageConfig, 'Page') &&
|
|
139
|
+
!!getConfigEnv(pageConfig, 'Page')?.client);
|
|
141
140
|
},
|
|
142
141
|
},
|
|
143
142
|
// TO-DO/soon/cumulative-hooks: remove and replace with new computed prop `clientOnlyHooks: string[]` (see other TO-DO/soon/cumulative-hooks entries)
|
|
@@ -145,10 +144,7 @@ const configDefinitionsBuiltIn = {
|
|
|
145
144
|
env: { client: true },
|
|
146
145
|
eager: true,
|
|
147
146
|
_computed: (pageConfig) => {
|
|
148
|
-
|
|
149
|
-
return !isConfigSet(configValueSources, 'onBeforeRender')
|
|
150
|
-
? null
|
|
151
|
-
: getConfigEnv(configValueSources, 'onBeforeRender');
|
|
147
|
+
return !isConfigSet(pageConfig, 'onBeforeRender') ? null : getConfigEnv(pageConfig, 'onBeforeRender');
|
|
152
148
|
},
|
|
153
149
|
},
|
|
154
150
|
// TO-DO/soon/cumulative-hooks: remove and replace with new computed prop `clientOnlyHooks: string[]` (see other TO-DO/soon/cumulative-hooks entries)
|
|
@@ -156,8 +152,7 @@ const configDefinitionsBuiltIn = {
|
|
|
156
152
|
env: { client: true },
|
|
157
153
|
eager: true,
|
|
158
154
|
_computed: (pageConfig) => {
|
|
159
|
-
|
|
160
|
-
return !isConfigSet(configValueSources, 'data') ? null : getConfigEnv(configValueSources, 'data');
|
|
155
|
+
return !isConfigSet(pageConfig, 'data') ? null : getConfigEnv(pageConfig, 'data');
|
|
161
156
|
},
|
|
162
157
|
},
|
|
163
158
|
hooksTimeout: {
|
|
@@ -246,11 +241,11 @@ const configDefinitionsBuiltIn = {
|
|
|
246
241
|
},
|
|
247
242
|
};
|
|
248
243
|
exports.configDefinitionsBuiltIn = configDefinitionsBuiltIn;
|
|
249
|
-
function getConfigEnv(
|
|
250
|
-
const
|
|
251
|
-
if (!
|
|
244
|
+
function getConfigEnv(pageConfig, configName) {
|
|
245
|
+
const source = (0, getConfigValueSourcesRelevant_js_1.getConfigValueSourceRelevantAnyEnv)(configName, pageConfig);
|
|
246
|
+
if (!source)
|
|
252
247
|
return null;
|
|
253
|
-
const { configEnv } =
|
|
248
|
+
const { configEnv } = source;
|
|
254
249
|
const env = {};
|
|
255
250
|
if (configEnv.client)
|
|
256
251
|
env.client = true;
|
|
@@ -258,18 +253,7 @@ function getConfigEnv(configValueSources, configName) {
|
|
|
258
253
|
env.server = true;
|
|
259
254
|
return env;
|
|
260
255
|
}
|
|
261
|
-
function isConfigSet(
|
|
262
|
-
const source =
|
|
263
|
-
return
|
|
264
|
-
!(source.valueIsLoaded &&
|
|
265
|
-
// Enable users to suppress inherited config by overriding it with `null`
|
|
266
|
-
source.value === null));
|
|
267
|
-
}
|
|
268
|
-
function getConfigValueSource(configValueSources, configName) {
|
|
269
|
-
const sources = configValueSources[configName];
|
|
270
|
-
if (!sources)
|
|
271
|
-
return null;
|
|
272
|
-
const configValueSource = sources[0];
|
|
273
|
-
(0, utils_js_1.assert)(configValueSource);
|
|
274
|
-
return configValueSource;
|
|
256
|
+
function isConfigSet(pageConfig, configName) {
|
|
257
|
+
const source = (0, getConfigValueSourcesRelevant_js_1.getConfigValueSourceRelevantAnyEnv)(configName, pageConfig);
|
|
258
|
+
return !!source;
|
|
275
259
|
}
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* We create a file `dist/server/package.json` to support ESM users.
|
|
3
|
-
* Otherwise, following error is thrown:
|
|
4
|
-
* Must use import to load ES Module: dist/server/pageFiles.js
|
|
5
|
-
* require() of ES modules is not supported.
|
|
6
|
-
* require() of dist/server/pageFiles.js from node_modules/vike/dist/esm/node/runtime/page-files/setup.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
|
|
7
|
-
* Reproduction: https://github.com/brillout/vite-plugin-ssr-server-import-syntax
|
|
8
|
-
*/
|
|
9
1
|
export { pluginDistPackageJsonFile };
|
|
10
2
|
import { rollupIsEsm } from '../../shared/rollupIsEsm.js';
|
|
11
3
|
import { isViteServerSide } from '../../shared/isViteServerSide.js';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { getConfigValueSourcesRelevant };
|
|
2
|
+
export { getConfigValueSourceRelevantAnyEnv };
|
|
2
3
|
export { isRuntimeEnvMatch };
|
|
4
|
+
export { isConfigSourceValueNull };
|
|
3
5
|
export type { RuntimeEnv };
|
|
4
6
|
import type { ConfigEnvInternal, ConfigValueSource, PageConfigBuildTime, PageConfigGlobalBuildTime } from '../../../../types/PageConfig.js';
|
|
5
7
|
type RuntimeEnv = {
|
|
@@ -9,6 +11,8 @@ type RuntimeEnv = {
|
|
|
9
11
|
} | {
|
|
10
12
|
isForConfig: true;
|
|
11
13
|
};
|
|
14
|
+
type PageConfigPartial = Pick<PageConfigBuildTime | PageConfigGlobalBuildTime, 'configValueSources' | 'configDefinitions'>;
|
|
12
15
|
declare function getConfigValueSourcesRelevant(configName: string, runtimeEnv: RuntimeEnv, pageConfig: PageConfigPartial): ConfigValueSource[];
|
|
16
|
+
declare function getConfigValueSourceRelevantAnyEnv(configName: string, pageConfig: PageConfigPartial): null | ConfigValueSource;
|
|
13
17
|
declare function isRuntimeEnvMatch(configEnv: ConfigEnvInternal, runtimeEnv: RuntimeEnv): boolean;
|
|
14
|
-
|
|
18
|
+
declare function isConfigSourceValueNull(source: ConfigValueSource): boolean | null;
|
|
@@ -1,28 +1,47 @@
|
|
|
1
1
|
export { getConfigValueSourcesRelevant };
|
|
2
|
+
export { getConfigValueSourceRelevantAnyEnv };
|
|
2
3
|
export { isRuntimeEnvMatch };
|
|
3
|
-
|
|
4
|
+
export { isConfigSourceValueNull };
|
|
5
|
+
import { assert, assertIsNotBrowser } from '../../utils.js';
|
|
6
|
+
assertIsNotBrowser();
|
|
4
7
|
function getConfigValueSourcesRelevant(configName, runtimeEnv, pageConfig) {
|
|
5
8
|
const configDef = pageConfig.configDefinitions[configName];
|
|
6
9
|
assert(configDef);
|
|
7
10
|
let sourcesRelevant = pageConfig.configValueSources[configName];
|
|
8
11
|
if (!sourcesRelevant)
|
|
9
12
|
return [];
|
|
10
|
-
|
|
13
|
+
// Ignore configs with value `undefined`
|
|
14
|
+
sourcesRelevant = sourcesRelevant.filter((source) => !isConfigSourceValueUndefined(source));
|
|
15
|
+
// Environment filtering
|
|
16
|
+
sourcesRelevant = sourcesRelevant.filter((source) => isRuntimeEnvMatch(source.configEnv, runtimeEnv));
|
|
17
|
+
// Overriding - non-cumulative configs
|
|
18
|
+
if (!configDef.cumulative && sourcesRelevant.length > 1) {
|
|
11
19
|
const source = sourcesRelevant[0];
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
assert(sourcesRelevant.length === 0);
|
|
17
|
-
}
|
|
20
|
+
assert(source);
|
|
21
|
+
sourcesRelevant = [source];
|
|
18
22
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
sourcesRelevant = sourcesRelevant
|
|
23
|
+
// Overriding - cumulative configs
|
|
24
|
+
if (configDef.cumulative && sourcesRelevant.length > 0) {
|
|
25
|
+
sourcesRelevant = applyFilenameSuffix(sourcesRelevant);
|
|
22
26
|
}
|
|
23
|
-
sourcesRelevant = sourcesRelevant.filter((source) => isRuntimeEnvMatch(source.configEnv, runtimeEnv));
|
|
24
27
|
return sourcesRelevant;
|
|
25
28
|
}
|
|
29
|
+
function getConfigValueSourceRelevantAnyEnv(configName, pageConfig) {
|
|
30
|
+
const configDef = pageConfig.configDefinitions[configName];
|
|
31
|
+
assert(configDef);
|
|
32
|
+
assert(!configDef.cumulative); // So far, this function is only used by non-cumulative configs
|
|
33
|
+
let sourcesRelevant = pageConfig.configValueSources[configName];
|
|
34
|
+
if (!sourcesRelevant)
|
|
35
|
+
return null;
|
|
36
|
+
// Ignore configs with value `undefined`
|
|
37
|
+
sourcesRelevant = sourcesRelevant.filter((source) => !isConfigSourceValueUndefined(source));
|
|
38
|
+
const source = sourcesRelevant[0];
|
|
39
|
+
if (!source)
|
|
40
|
+
return null;
|
|
41
|
+
if (isConfigSourceValueNull(source))
|
|
42
|
+
return null;
|
|
43
|
+
return source;
|
|
44
|
+
}
|
|
26
45
|
function isRuntimeEnvMatch(configEnv, runtimeEnv) {
|
|
27
46
|
if ('isForConfig' in runtimeEnv)
|
|
28
47
|
return !!configEnv.config;
|
|
@@ -52,14 +71,25 @@ function isRuntimeEnvMatch(configEnv, runtimeEnv) {
|
|
|
52
71
|
}
|
|
53
72
|
return true;
|
|
54
73
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
74
|
+
// Setting a config to `undefined` should be equivalent to not setting it at all
|
|
75
|
+
function isConfigSourceValueUndefined(source) {
|
|
76
|
+
if (!source.valueIsLoaded)
|
|
77
|
+
return null;
|
|
78
|
+
return source.value === undefined;
|
|
79
|
+
}
|
|
80
|
+
// Setting a config to `null` enables the user to suppress inherited config by overriding it with `null` (this only works when setting the config value to `null` inside a +config.js file — it doesn't work when setting the config value to `null` with a +{configName}.js file).
|
|
81
|
+
function isConfigSourceValueNull(source) {
|
|
82
|
+
if (!source.valueIsLoaded)
|
|
83
|
+
return null;
|
|
84
|
+
return source.value === null;
|
|
85
|
+
}
|
|
86
|
+
function applyFilenameSuffix(sourcesRelevant) {
|
|
87
|
+
const getFileName = (source) => source.plusFile?.filePath.fileName ?? '';
|
|
88
|
+
// Apply `clear`: truncate at first clear file
|
|
89
|
+
const clearIndex = sourcesRelevant.findIndex((source) => getFileName(source).includes('.clear.'));
|
|
90
|
+
if (clearIndex !== -1)
|
|
91
|
+
sourcesRelevant = sourcesRelevant.slice(0, clearIndex + 1);
|
|
92
|
+
// Apply `default`: exclude defaults if any non-defaults exist, otherwise keep only first default
|
|
93
|
+
const nonDefaults = sourcesRelevant.filter((source) => !getFileName(source).includes('.default.'));
|
|
94
|
+
return nonDefaults.length > 0 ? nonDefaults : sourcesRelevant.slice(0, 1);
|
|
65
95
|
}
|
|
@@ -4,9 +4,10 @@ export type { ConfigDefinitions };
|
|
|
4
4
|
export type { ConfigDefinitionsInternal };
|
|
5
5
|
export type { ConfigDefinitionInternal };
|
|
6
6
|
export type { ConfigEffect };
|
|
7
|
-
import type { ConfigEnvInternal, ConfigEnv, DefinedAtFilePath
|
|
7
|
+
import type { ConfigEnvInternal, ConfigEnv, DefinedAtFilePath } from '../../../../types/PageConfig.js';
|
|
8
8
|
import type { Config, ConfigNameBuiltIn, ConfigNameGlobal } from '../../../../types/Config.js';
|
|
9
9
|
import { type ConfigDefinedAt } from '../../../../shared/page-configs/getConfigDefinedAt.js';
|
|
10
|
+
import type { PageConfigBuildTimeBeforeComputed } from '../resolveVikeConfigInternal.js';
|
|
10
11
|
/** The meta definition of a config.
|
|
11
12
|
*
|
|
12
13
|
* https://vike.dev/meta
|
|
@@ -75,7 +76,7 @@ type ConfigEffect = (config: {
|
|
|
75
76
|
}) => Config | undefined;
|
|
76
77
|
/** For Vike internal use */
|
|
77
78
|
type ConfigDefinitionInternal = Omit<ConfigDefinition_, 'env'> & {
|
|
78
|
-
_computed?: (pageConfig:
|
|
79
|
+
_computed?: (pageConfig: PageConfigBuildTimeBeforeComputed) => unknown;
|
|
79
80
|
_valueIsFilePath?: true;
|
|
80
81
|
_userEffectDefinedAtFilePath?: DefinedAtFilePath;
|
|
81
82
|
env: ConfigEnvInternal;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { configDefinitionsBuiltIn };
|
|
2
2
|
import { assert, assertUsage } from '../../utils.js';
|
|
3
3
|
import { getConfigDefinedAt } from '../../../../shared/page-configs/getConfigDefinedAt.js';
|
|
4
|
-
import { getConfigValueSourcesRelevant } from '../../plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js';
|
|
4
|
+
import { getConfigValueSourceRelevantAnyEnv, getConfigValueSourcesRelevant, isConfigSourceValueNull, } from '../../plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js';
|
|
5
5
|
const configDefinitionsBuiltIn = {
|
|
6
6
|
onRenderHtml: {
|
|
7
7
|
env: { server: true },
|
|
@@ -108,7 +108,9 @@ const configDefinitionsBuiltIn = {
|
|
|
108
108
|
}, pageConfig))
|
|
109
109
|
.flat(1)
|
|
110
110
|
// Server-only
|
|
111
|
-
.filter((source) => !source.configEnv.client)
|
|
111
|
+
.filter((source) => !source.configEnv.client)
|
|
112
|
+
// Config value isn't `null`
|
|
113
|
+
.filter((source) => !isConfigSourceValueNull(source));
|
|
112
114
|
return sources.length > 0;
|
|
113
115
|
},
|
|
114
116
|
},
|
|
@@ -120,22 +122,19 @@ const configDefinitionsBuiltIn = {
|
|
|
120
122
|
env: { server: true, client: true },
|
|
121
123
|
eager: true,
|
|
122
124
|
_computed: (pageConfig) => {
|
|
123
|
-
const { configValueSources } = pageConfig;
|
|
124
125
|
{
|
|
125
|
-
const source =
|
|
126
|
+
const source = getConfigValueSourceRelevantAnyEnv('clientHooks', pageConfig);
|
|
126
127
|
if (source) {
|
|
127
128
|
assert(source.valueIsLoaded);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return value;
|
|
133
|
-
}
|
|
129
|
+
const { value, definedAt } = source;
|
|
130
|
+
const configDefinedAt = getConfigDefinedAt('Config', 'clientHooks', definedAt);
|
|
131
|
+
assertUsage(typeof value === 'boolean', `${configDefinedAt} should be a boolean`);
|
|
132
|
+
return value;
|
|
134
133
|
}
|
|
135
134
|
}
|
|
136
|
-
return (isConfigSet(
|
|
137
|
-
isConfigSet(
|
|
138
|
-
!!getConfigEnv(
|
|
135
|
+
return (isConfigSet(pageConfig, 'onRenderClient') &&
|
|
136
|
+
isConfigSet(pageConfig, 'Page') &&
|
|
137
|
+
!!getConfigEnv(pageConfig, 'Page')?.client);
|
|
139
138
|
},
|
|
140
139
|
},
|
|
141
140
|
// TO-DO/soon/cumulative-hooks: remove and replace with new computed prop `clientOnlyHooks: string[]` (see other TO-DO/soon/cumulative-hooks entries)
|
|
@@ -143,10 +142,7 @@ const configDefinitionsBuiltIn = {
|
|
|
143
142
|
env: { client: true },
|
|
144
143
|
eager: true,
|
|
145
144
|
_computed: (pageConfig) => {
|
|
146
|
-
|
|
147
|
-
return !isConfigSet(configValueSources, 'onBeforeRender')
|
|
148
|
-
? null
|
|
149
|
-
: getConfigEnv(configValueSources, 'onBeforeRender');
|
|
145
|
+
return !isConfigSet(pageConfig, 'onBeforeRender') ? null : getConfigEnv(pageConfig, 'onBeforeRender');
|
|
150
146
|
},
|
|
151
147
|
},
|
|
152
148
|
// TO-DO/soon/cumulative-hooks: remove and replace with new computed prop `clientOnlyHooks: string[]` (see other TO-DO/soon/cumulative-hooks entries)
|
|
@@ -154,8 +150,7 @@ const configDefinitionsBuiltIn = {
|
|
|
154
150
|
env: { client: true },
|
|
155
151
|
eager: true,
|
|
156
152
|
_computed: (pageConfig) => {
|
|
157
|
-
|
|
158
|
-
return !isConfigSet(configValueSources, 'data') ? null : getConfigEnv(configValueSources, 'data');
|
|
153
|
+
return !isConfigSet(pageConfig, 'data') ? null : getConfigEnv(pageConfig, 'data');
|
|
159
154
|
},
|
|
160
155
|
},
|
|
161
156
|
hooksTimeout: {
|
|
@@ -243,11 +238,11 @@ const configDefinitionsBuiltIn = {
|
|
|
243
238
|
cumulative: true,
|
|
244
239
|
},
|
|
245
240
|
};
|
|
246
|
-
function getConfigEnv(
|
|
247
|
-
const
|
|
248
|
-
if (!
|
|
241
|
+
function getConfigEnv(pageConfig, configName) {
|
|
242
|
+
const source = getConfigValueSourceRelevantAnyEnv(configName, pageConfig);
|
|
243
|
+
if (!source)
|
|
249
244
|
return null;
|
|
250
|
-
const { configEnv } =
|
|
245
|
+
const { configEnv } = source;
|
|
251
246
|
const env = {};
|
|
252
247
|
if (configEnv.client)
|
|
253
248
|
env.client = true;
|
|
@@ -255,18 +250,7 @@ function getConfigEnv(configValueSources, configName) {
|
|
|
255
250
|
env.server = true;
|
|
256
251
|
return env;
|
|
257
252
|
}
|
|
258
|
-
function isConfigSet(
|
|
259
|
-
const source =
|
|
260
|
-
return
|
|
261
|
-
!(source.valueIsLoaded &&
|
|
262
|
-
// Enable users to suppress inherited config by overriding it with `null`
|
|
263
|
-
source.value === null));
|
|
264
|
-
}
|
|
265
|
-
function getConfigValueSource(configValueSources, configName) {
|
|
266
|
-
const sources = configValueSources[configName];
|
|
267
|
-
if (!sources)
|
|
268
|
-
return null;
|
|
269
|
-
const configValueSource = sources[0];
|
|
270
|
-
assert(configValueSource);
|
|
271
|
-
return configValueSource;
|
|
253
|
+
function isConfigSet(pageConfig, configName) {
|
|
254
|
+
const source = getConfigValueSourceRelevantAnyEnv(configName, pageConfig);
|
|
255
|
+
return !!source;
|
|
272
256
|
}
|
|
@@ -8,6 +8,7 @@ export { getConfVal };
|
|
|
8
8
|
export { getConfigDefinitionOptional };
|
|
9
9
|
export { getVikeConfigFromCliOrEnv };
|
|
10
10
|
export type { VikeConfigInternal };
|
|
11
|
+
export type { PageConfigBuildTimeBeforeComputed };
|
|
11
12
|
export { getVikeConfig };
|
|
12
13
|
export type { VikeConfig };
|
|
13
14
|
import type { PageConfigGlobalBuildTime, PageConfigBuildTime } from '../../../types/PageConfig.js';
|
|
@@ -57,6 +58,7 @@ declare function getVikeConfigFromCliOrEnv(): {
|
|
|
57
58
|
configFromCliOptions: import("../../cli/parseCli.js").CliOptions | null;
|
|
58
59
|
configFromEnvVar: Record<string, unknown> | null;
|
|
59
60
|
};
|
|
61
|
+
type PageConfigBuildTimeBeforeComputed = Omit<PageConfigBuildTime, 'configValuesComputed'>;
|
|
60
62
|
declare function getConfigDefinitionOptional(configDefinitions: ConfigDefinitionsInternal, configName: string): ConfigDefinitionInternal | null;
|
|
61
63
|
declare function getConfVal(plusFile: PlusFile, configName: string): null | {
|
|
62
64
|
value: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.237-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.237-commit-92dc549";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.237-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.237-commit-92dc549';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.237-commit-
|
|
3
|
+
"version": "0.4.237-commit-92dc549",
|
|
4
4
|
"repository": "https://github.com/vikejs/vike",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": {
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
},
|
|
130
130
|
"dependencies": {
|
|
131
131
|
"@brillout/import": "^0.2.6",
|
|
132
|
-
"@brillout/json-serializer": "^0.5.
|
|
132
|
+
"@brillout/json-serializer": "^0.5.20",
|
|
133
133
|
"@brillout/picocolors": "^1.0.26",
|
|
134
134
|
"@brillout/require-shim": "^0.1.2",
|
|
135
135
|
"@brillout/vite-plugin-server-entry": "^0.7.12",
|