vike 0.4.171-commit-75e1588 → 0.4.171-commit-6e37128
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 +3 -4
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +18 -15
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +3 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +30 -74
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +4 -42
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +9 -49
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +6 -0
- package/dist/cjs/node/prerender/runPrerender.js +33 -13
- package/dist/cjs/node/prerender/utils.js +1 -0
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +9 -7
- package/dist/cjs/node/runtime/renderPage/createHttpResponseObject/getCacheControl.js +1 -1
- package/dist/cjs/node/runtime/renderPage/executeOnRenderHtmlHook.js +7 -7
- package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +4 -5
- package/dist/cjs/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.js +2 -2
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +6 -5
- package/dist/cjs/node/shared/assertV1Design.js +3 -4
- package/dist/cjs/shared/{addUrlComputedProps.js → getPageContextUrlComputed.js} +52 -42
- package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +2 -2
- package/dist/cjs/shared/hooks/getHook.js +2 -2
- package/dist/cjs/shared/page-configs/getConfigValue.js +14 -17
- package/dist/cjs/shared/page-configs/getConfigValueBuildTime.js +70 -0
- package/dist/cjs/shared/page-configs/loadConfigValues.js +3 -12
- package/dist/cjs/shared/page-configs/serialize/assertPageConfigsSerialized.js +1 -2
- package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +110 -16
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +198 -0
- package/dist/cjs/shared/route/index.js +2 -2
- package/dist/cjs/shared/route/loadPageRoutes.js +2 -2
- package/dist/cjs/shared/route/resolveRouteFunction.js +2 -2
- package/dist/cjs/shared/utils.js +2 -0
- package/dist/cjs/utils/changeEnumerable.js +9 -0
- package/dist/cjs/utils/hasProp.js +5 -7
- package/dist/cjs/utils/objectAssign.js +1 -1
- package/dist/cjs/utils/objectDefineProperty.js +8 -0
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/client/client-routing-runtime/createPageContext.d.ts +6 -4
- package/dist/esm/client/client-routing-runtime/createPageContext.js +4 -3
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +14 -10
- package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +4 -4
- package/dist/esm/client/shared/loadUserFilesClientSide.js +4 -4
- package/dist/esm/node/plugin/plugins/buildConfig.js +3 -4
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +18 -15
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +2 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +30 -74
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +4 -42
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +9 -49
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.d.ts +1 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +6 -0
- package/dist/esm/node/prerender/runPrerender.js +35 -15
- package/dist/esm/node/prerender/utils.d.ts +1 -0
- package/dist/esm/node/prerender/utils.js +1 -0
- package/dist/esm/node/runtime/renderPage/analyzePage.js +9 -7
- package/dist/esm/node/runtime/renderPage/createHttpResponseObject/getCacheControl.js +2 -2
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.js +7 -7
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +1 -9
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +4 -5
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.js +2 -2
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +27 -50
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +6 -5
- package/dist/esm/node/shared/assertV1Design.d.ts +2 -2
- package/dist/esm/node/shared/assertV1Design.js +3 -4
- package/dist/esm/shared/{addUrlComputedProps.d.ts → getPageContextUrlComputed.d.ts} +23 -21
- package/dist/esm/shared/{addUrlComputedProps.js → getPageContextUrlComputed.js} +52 -42
- package/dist/esm/shared/getPageFiles/analyzeClientSide.js +3 -3
- package/dist/esm/shared/hooks/getHook.d.ts +2 -2
- package/dist/esm/shared/hooks/getHook.js +3 -3
- package/dist/esm/shared/page-configs/PageConfig.d.ts +10 -4
- package/dist/esm/shared/page-configs/getConfigValue.d.ts +12 -12
- package/dist/esm/shared/page-configs/getConfigValue.js +13 -16
- package/dist/esm/shared/page-configs/getConfigValueBuildTime.d.ts +9 -0
- package/dist/esm/shared/page-configs/getConfigValueBuildTime.js +67 -0
- package/dist/esm/shared/page-configs/loadConfigValues.js +3 -12
- package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.d.ts +15 -19
- package/dist/esm/shared/page-configs/serialize/assertPageConfigsSerialized.js +1 -2
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.d.ts +4 -1
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +109 -15
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +5 -0
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +192 -0
- package/dist/esm/shared/route/index.d.ts +3 -3
- package/dist/esm/shared/route/index.js +2 -2
- package/dist/esm/shared/route/loadPageRoutes.js +3 -3
- package/dist/esm/shared/route/resolveRouteFunction.d.ts +2 -2
- package/dist/esm/shared/route/resolveRouteFunction.js +2 -2
- package/dist/esm/shared/types.d.ts +4 -4
- package/dist/esm/shared/utils.d.ts +2 -0
- package/dist/esm/shared/utils.js +2 -0
- package/dist/esm/types/index.d.ts +1 -1
- package/dist/esm/utils/changeEnumerable.d.ts +2 -0
- package/dist/esm/utils/changeEnumerable.js +5 -0
- package/dist/esm/utils/hasProp.d.ts +4 -13
- package/dist/esm/utils/hasProp.js +5 -7
- package/dist/esm/utils/objectAssign.js +1 -1
- package/dist/esm/utils/objectDefineProperty.d.ts +4 -0
- package/dist/esm/utils/objectDefineProperty.js +4 -0
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +0 -101
- package/dist/cjs/node/plugin/shared/getConfigValueSourcesNotOverriden.js +0 -14
- package/dist/cjs/node/shared/getClientEntry.js +0 -12
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +0 -85
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesSerialized.js +0 -24
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValue.js +0 -49
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.d.ts +0 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +0 -95
- package/dist/esm/node/plugin/shared/getConfigValueSourcesNotOverriden.d.ts +0 -5
- package/dist/esm/node/plugin/shared/getConfigValueSourcesNotOverriden.js +0 -11
- package/dist/esm/node/shared/getClientEntry.d.ts +0 -3
- package/dist/esm/node/shared/getClientEntry.js +0 -9
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.d.ts +0 -4
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +0 -82
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesSerialized.d.ts +0 -4
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesSerialized.js +0 -21
- package/dist/esm/shared/page-configs/serialize/serializeConfigValue.d.ts +0 -6
- package/dist/esm/shared/page-configs/serialize/serializeConfigValue.js +0 -46
|
@@ -1,45 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
Object.assign(pageContext2, pageContext)
|
|
15
|
-
// ❌ Also breaks the property getters
|
|
16
|
-
const pageContext3 = { ...pageContext }
|
|
17
|
-
// ✅ Preserves property getters of pageContext (see objectAssign() implementation)
|
|
18
|
-
objectAssign(pageContext2, pageContext)
|
|
19
|
-
```
|
|
20
|
-
*/
|
|
21
|
-
assert(isPropertyGetter(pageContext, 'urlPathname'));
|
|
22
|
-
}
|
|
23
|
-
if ('urlParsed' in pageContext)
|
|
24
|
-
assert(isPropertyGetter(pageContext, 'urlParsed'));
|
|
25
|
-
// TODO/v1-release: move pageContext.urlParsed to pageContext.url
|
|
26
|
-
if ('url' in pageContext)
|
|
27
|
-
assert(isPropertyGetter(pageContext, 'url'));
|
|
28
|
-
Object.defineProperty(pageContext, 'urlPathname', {
|
|
1
|
+
export { getPageContextUrlComputed };
|
|
2
|
+
export { assertPageContextUrl };
|
|
3
|
+
// =====================
|
|
4
|
+
// File determining the URL logic.
|
|
5
|
+
// URLs need to be computed, because the user can modify the URL e.g. with onBeforeRoute() for i18n.
|
|
6
|
+
// =====================
|
|
7
|
+
import { objectDefineProperty } from '../utils/objectDefineProperty.js';
|
|
8
|
+
import { assert, parseUrl, assertWarning, isPlainObject, isPropertyGetter, isBrowser, changeEnumerable } from './utils.js';
|
|
9
|
+
function getPageContextUrlComputed(pageContext) {
|
|
10
|
+
assert(typeof pageContext.urlOriginal === 'string');
|
|
11
|
+
assertPageContextUrlComputed(pageContext);
|
|
12
|
+
const pageContextUrlComputed = {};
|
|
13
|
+
objectDefineProperty(pageContextUrlComputed, 'urlPathname', {
|
|
29
14
|
get: urlPathnameGetter,
|
|
30
|
-
enumerable,
|
|
15
|
+
enumerable: true,
|
|
31
16
|
configurable: true
|
|
32
17
|
});
|
|
33
|
-
|
|
18
|
+
objectDefineProperty(pageContextUrlComputed, 'url', {
|
|
34
19
|
get: urlGetter,
|
|
35
20
|
enumerable: false,
|
|
36
21
|
configurable: true
|
|
37
22
|
});
|
|
38
|
-
|
|
23
|
+
objectDefineProperty(pageContextUrlComputed, 'urlParsed', {
|
|
39
24
|
get: urlParsedGetter,
|
|
40
|
-
enumerable,
|
|
25
|
+
enumerable: true,
|
|
41
26
|
configurable: true
|
|
42
27
|
});
|
|
28
|
+
return pageContextUrlComputed;
|
|
43
29
|
}
|
|
44
30
|
function getUrlParsed(pageContext) {
|
|
45
31
|
// We need a url handler function because the onBeforeRoute() hook may set pageContext.urlLogical (typically for i18n)
|
|
@@ -90,7 +76,7 @@ function urlParsedGetter() {
|
|
|
90
76
|
const { origin, pathname, pathnameOriginal, search, searchAll, searchOriginal, hash, hashOriginal } = urlParsedOriginal;
|
|
91
77
|
const hashIsAvailable = isBrowser();
|
|
92
78
|
const warnHashNotAvailable = (prop) => {
|
|
93
|
-
assertWarning(hashIsAvailable, `pageContext.urlParsed.${prop} isn't available on the server-side (HTTP requests don't include the URL hash
|
|
79
|
+
assertWarning(hashIsAvailable, `pageContext.urlParsed.${prop} isn't available on the server-side (HTTP requests don't include the URL hash)`, { onlyOnce: true, showStackTrace: true });
|
|
94
80
|
};
|
|
95
81
|
const urlParsed = {
|
|
96
82
|
origin,
|
|
@@ -120,21 +106,45 @@ function urlParsedGetter() {
|
|
|
120
106
|
return searchOriginal;
|
|
121
107
|
}
|
|
122
108
|
};
|
|
123
|
-
|
|
124
|
-
|
|
109
|
+
changeEnumerable(urlParsed, 'hashString', false);
|
|
110
|
+
changeEnumerable(urlParsed, 'searchString', false);
|
|
125
111
|
if (!hashIsAvailable) {
|
|
126
|
-
|
|
127
|
-
|
|
112
|
+
changeEnumerable(urlParsed, 'hash', false);
|
|
113
|
+
changeEnumerable(urlParsed, 'hashOriginal', false);
|
|
128
114
|
}
|
|
129
115
|
return urlParsed;
|
|
130
116
|
}
|
|
131
|
-
function
|
|
132
|
-
const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
|
|
133
|
-
Object.defineProperty(obj, prop, { ...descriptor, enumerable: false });
|
|
134
|
-
}
|
|
135
|
-
function assertPageContextUrlComputedProps(pageContext) {
|
|
117
|
+
function assertPageContextUrl(pageContext) {
|
|
136
118
|
assert(typeof pageContext.urlOriginal === 'string');
|
|
137
119
|
assert(typeof pageContext.urlPathname === 'string');
|
|
138
120
|
assert(isPlainObject(pageContext.urlParsed));
|
|
139
121
|
assert(pageContext.urlPathname === pageContext.urlParsed.pathname);
|
|
122
|
+
assertPageContextUrlComputed(pageContext);
|
|
123
|
+
}
|
|
124
|
+
function assertPageContextUrlComputed(pageContext) {
|
|
125
|
+
/*
|
|
126
|
+
If the isPropertyGetter() assertions fail then it's most likely because Object.assign() was used instead of `objectAssign()`:
|
|
127
|
+
```js
|
|
128
|
+
const PageContextUrlComputed = getPageContextUrlComputed(pageContext)
|
|
129
|
+
|
|
130
|
+
// ❌ Breaks the property descriptors/getters of pageContext defined by getPageContextUrlComputed() such as pageContext.urlPathname
|
|
131
|
+
Object.assign(pageContext, pageContextUrlComputed)
|
|
132
|
+
|
|
133
|
+
// ❌ Also breaks property descriptors/getters
|
|
134
|
+
const pageContext = { ...pageContextUrlComputed }
|
|
135
|
+
|
|
136
|
+
// ✅ Preserves property descriptors/getters (see objectAssign() implementation)
|
|
137
|
+
objectAssign(pageContext, pageContextUrlComputed)
|
|
138
|
+
```
|
|
139
|
+
*/
|
|
140
|
+
if ('urlPathname' in pageContext) {
|
|
141
|
+
assert(typeof pageContext.urlPathname === 'string');
|
|
142
|
+
assert(isPropertyGetter(pageContext, 'urlPathname'));
|
|
143
|
+
assert(isPropertyGetter(pageContext, 'urlParsed'));
|
|
144
|
+
assert(isPropertyGetter(pageContext, 'url'));
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
assert(!('urlParsed' in pageContext));
|
|
148
|
+
assert(!('url' in pageContext));
|
|
149
|
+
}
|
|
140
150
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { analyzeClientSide };
|
|
2
|
-
import {
|
|
2
|
+
import { getConfigValueRuntime } from '../page-configs/getConfigValue.js';
|
|
3
3
|
import { analyzePageClientSide } from './analyzePageClientSide.js';
|
|
4
4
|
function analyzeClientSide(pageConfig, pageFilesAll, pageId) {
|
|
5
5
|
// V1 design
|
|
6
6
|
if (pageConfig) {
|
|
7
|
-
const isClientRouting =
|
|
8
|
-
const isClientSideRenderable =
|
|
7
|
+
const isClientRouting = getConfigValueRuntime(pageConfig, 'clientRouting', 'boolean')?.value ?? false;
|
|
8
|
+
const isClientSideRenderable = getConfigValueRuntime(pageConfig, 'isClientSideRenderable', 'boolean')?.value ?? false;
|
|
9
9
|
return { isClientSideRenderable, isClientRouting };
|
|
10
10
|
}
|
|
11
11
|
else {
|
|
@@ -11,7 +11,7 @@ export type { HooksTimeoutProvidedByUser };
|
|
|
11
11
|
export { getHookTimeoutDefault };
|
|
12
12
|
import type { PageContextExports } from '../getPageFiles.js';
|
|
13
13
|
import type { HookName, HookNamePage, HookNameGlobal } from '../page-configs/Config.js';
|
|
14
|
-
import type {
|
|
14
|
+
import type { PageConfigGlobalRuntime, PageConfigRuntime } from '../page-configs/PageConfig.js';
|
|
15
15
|
type Hook = HookLoc & {
|
|
16
16
|
hookFn: HookFn;
|
|
17
17
|
hookTimeout: HookTimeout;
|
|
@@ -27,7 +27,7 @@ type HookTimeout = {
|
|
|
27
27
|
};
|
|
28
28
|
type HooksTimeoutProvidedByUser = false | Partial<Record<HookName, false | Partial<HookTimeout>>>;
|
|
29
29
|
declare function getHook(pageContext: PageContextExports, hookName: HookName): null | Hook;
|
|
30
|
-
declare function getHookFromPageConfig(pageConfig: PageConfigRuntime
|
|
30
|
+
declare function getHookFromPageConfig(pageConfig: PageConfigRuntime, hookName: HookNamePage): null | Hook;
|
|
31
31
|
declare function getHookFromPageConfigGlobal(pageConfigGlobal: PageConfigGlobalRuntime, hookName: HookNameGlobal): null | Hook;
|
|
32
32
|
declare function assertHook<TPageContext extends PageContextExports, THookName extends PropertyKey & HookName>(pageContext: TPageContext, hookName: THookName): asserts pageContext is TPageContext & {
|
|
33
33
|
exports: Record<THookName, Function | undefined>;
|
|
@@ -8,7 +8,7 @@ export { setIsPrerenderering };
|
|
|
8
8
|
export { getHookTimeoutDefault };
|
|
9
9
|
import { getGlobalObject } from '../../utils/getGlobalObject.js';
|
|
10
10
|
import { getHookFilePathToShowToUser } from '../page-configs/helpers.js';
|
|
11
|
-
import {
|
|
11
|
+
import { getConfigValueRuntime } from '../page-configs/getConfigValue.js';
|
|
12
12
|
import { assert, assertUsage, checkType, isCallable, isObject } from '../utils.js';
|
|
13
13
|
import pc from '@brillout/picocolors';
|
|
14
14
|
const globalObject = getGlobalObject('getHook.ts', {
|
|
@@ -32,8 +32,8 @@ function getHook(pageContext, hookName) {
|
|
|
32
32
|
return { hookFn, hookName, hookFilePath, hookTimeout };
|
|
33
33
|
}
|
|
34
34
|
function getHookFromPageConfig(pageConfig, hookName) {
|
|
35
|
-
const configValue =
|
|
36
|
-
const hooksTimeout =
|
|
35
|
+
const configValue = getConfigValueRuntime(pageConfig, hookName);
|
|
36
|
+
const hooksTimeout = getConfigValueRuntime(pageConfig, 'hooksTimeout')?.value;
|
|
37
37
|
if (!configValue)
|
|
38
38
|
return null;
|
|
39
39
|
const hookFn = configValue.value;
|
|
@@ -16,9 +16,10 @@ export type { ConfigValuesComputed };
|
|
|
16
16
|
export type { DefinedAtData };
|
|
17
17
|
export type { DefinedAtFile };
|
|
18
18
|
export type { DefinedAtFilePath };
|
|
19
|
-
import type {
|
|
19
|
+
import type { ConfigValueSerialized } from './serialize/PageConfigSerialized.js';
|
|
20
20
|
import type { LocationId } from '../../node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js';
|
|
21
21
|
import type { FilePath } from './FilePath.js';
|
|
22
|
+
import type { ConfigDefinitions } from '../../node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js';
|
|
22
23
|
type PageConfigBase = {
|
|
23
24
|
pageId: string;
|
|
24
25
|
isErrorPage?: true;
|
|
@@ -26,13 +27,12 @@ type PageConfigBase = {
|
|
|
26
27
|
routeString: string;
|
|
27
28
|
definedBy: string;
|
|
28
29
|
};
|
|
29
|
-
configValues: ConfigValues;
|
|
30
30
|
};
|
|
31
31
|
/** Page config data structure available at runtime */
|
|
32
32
|
type PageConfigRuntime = PageConfigBase & {
|
|
33
|
+
configValues: ConfigValues;
|
|
33
34
|
/** Load config values that are lazily loaded such as config.Page */
|
|
34
35
|
loadConfigValuesAll: () => Promise<{
|
|
35
|
-
configValuesImported: ConfigValueImported[];
|
|
36
36
|
configValuesSerialized: Record<string, ConfigValueSerialized>;
|
|
37
37
|
}>;
|
|
38
38
|
};
|
|
@@ -43,6 +43,7 @@ type PageConfigRuntimeLoaded = PageConfigRuntime & {
|
|
|
43
43
|
};
|
|
44
44
|
/** Page config data structure available at build-time */
|
|
45
45
|
type PageConfigBuildTime = PageConfigBase & {
|
|
46
|
+
configDefinitions: ConfigDefinitions;
|
|
46
47
|
configValueSources: ConfigValueSources;
|
|
47
48
|
configValuesComputed: ConfigValuesComputed;
|
|
48
49
|
};
|
|
@@ -52,6 +53,7 @@ type PageConfigGlobalRuntime = {
|
|
|
52
53
|
};
|
|
53
54
|
type PageConfigGlobalBuildTime = {
|
|
54
55
|
configValueSources: ConfigValueSources;
|
|
56
|
+
configDefinitions: ConfigDefinitions;
|
|
55
57
|
};
|
|
56
58
|
/** In what environment(s) the config value is loaded.
|
|
57
59
|
*
|
|
@@ -65,18 +67,22 @@ type ConfigEnv = {
|
|
|
65
67
|
/** For Vike internal use */
|
|
66
68
|
type ConfigEnvInternal = Omit<ConfigEnv, 'client'> & {
|
|
67
69
|
client?: boolean | 'if-client-routing';
|
|
70
|
+
/** Always load value, not matter what page is loaded. */
|
|
68
71
|
eager?: boolean;
|
|
72
|
+
/** Load value only in production or only in development. */
|
|
73
|
+
production?: boolean;
|
|
69
74
|
};
|
|
70
75
|
type ConfigValueSource = {
|
|
71
76
|
value?: unknown;
|
|
72
77
|
configEnv: ConfigEnvInternal;
|
|
73
78
|
definedAtFilePath: DefinedAtFilePath;
|
|
74
79
|
locationId: LocationId;
|
|
80
|
+
isOverriden: boolean;
|
|
75
81
|
/** Wether the config value is loaded at runtime, for example config.Page or config.onBeforeRender */
|
|
76
82
|
valueIsImportedAtRuntime: boolean;
|
|
77
83
|
/** Whether the config value is a file path, for example config.client */
|
|
78
84
|
valueIsFilePath?: true;
|
|
79
|
-
|
|
85
|
+
valueIsDefinedByPlusFile: boolean;
|
|
80
86
|
};
|
|
81
87
|
type DefinedAtFilePath = DefinedAtFile & FilePath & {
|
|
82
88
|
fileExportName?: string;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
1
|
+
export { getConfigValueRuntime };
|
|
2
|
+
export { getConfigValueTyped };
|
|
3
|
+
export type { TypeAsString };
|
|
4
|
+
import { type ResolveTypeAsString } from '../utils.js';
|
|
5
|
+
import type { PageConfigRuntime, ConfigValue } from './PageConfig.js';
|
|
3
6
|
import type { ConfigNameBuiltIn } from './Config.js';
|
|
4
|
-
type PageConfigCommon = PageConfigRuntime | PageConfigBuildTime;
|
|
5
7
|
type ConfigName = ConfigNameBuiltIn;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
value: unknown;
|
|
14
|
-
};
|
|
8
|
+
type TypeAsString = 'string' | 'boolean' | undefined;
|
|
9
|
+
declare function getConfigValueTyped<Type extends TypeAsString = undefined>(configValue: ConfigValue, configName: ConfigName, type?: Type): null | (ConfigValue & {
|
|
10
|
+
value: ResolveTypeAsString<Type>;
|
|
11
|
+
});
|
|
12
|
+
declare function getConfigValueRuntime<Type extends TypeAsString = undefined>(pageConfig: PageConfigRuntime, configName: ConfigName, type?: Type): null | (ConfigValue & {
|
|
13
|
+
value: ResolveTypeAsString<Type>;
|
|
14
|
+
});
|
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { getConfigValueRuntime };
|
|
2
|
+
export { getConfigValueTyped };
|
|
2
3
|
import { assert, assertUsage, getValuePrintable } from '../utils.js';
|
|
3
4
|
import pc from '@brillout/picocolors';
|
|
4
5
|
import { getConfigDefinedAtOptional } from './getConfigDefinedAt.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return null;
|
|
6
|
+
function getConfigValueTyped(configValue, configName, type) {
|
|
7
|
+
/* [NULL_HANDLING] Do we really need this? This doesn't seem to make sense, let's eventually (re)move this.
|
|
8
|
+
// Enable users to suppress global config values by setting the local config value to null
|
|
9
|
+
if (configValue.value === null) return null
|
|
10
|
+
*/
|
|
11
11
|
const { value, definedAtData } = configValue;
|
|
12
12
|
if (type)
|
|
13
13
|
assertConfigValueType(value, type, configName, definedAtData);
|
|
14
14
|
return configValue;
|
|
15
15
|
}
|
|
16
|
+
function getConfigValueRuntime(pageConfig, configName, type) {
|
|
17
|
+
const configValue = pageConfig.configValues[configName];
|
|
18
|
+
if (!configValue)
|
|
19
|
+
return null;
|
|
20
|
+
return getConfigValueTyped(configValue, configName, type);
|
|
21
|
+
}
|
|
16
22
|
function assertConfigValueType(value, type, configName, definedAtData) {
|
|
17
23
|
assert(value !== null);
|
|
18
24
|
const typeActual = typeof value;
|
|
@@ -26,12 +32,3 @@ function assertConfigValueType(value, type, configName, definedAtData) {
|
|
|
26
32
|
const errMsg = `${configDefinedAt} has an invalid ${problem}: it should be a ${pc.cyan(type)} instead`;
|
|
27
33
|
assertUsage(false, errMsg);
|
|
28
34
|
}
|
|
29
|
-
function getConfigValueEntry(pageConfig, configName) {
|
|
30
|
-
const configValue = pageConfig.configValues[configName];
|
|
31
|
-
if (!configValue)
|
|
32
|
-
return null;
|
|
33
|
-
// Enable users to suppress global config values by setting the local config value to null
|
|
34
|
-
if (configValue.value === null)
|
|
35
|
-
return null;
|
|
36
|
-
return configValue;
|
|
37
|
-
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { getConfigValueBuildTime };
|
|
2
|
+
import { type ResolveTypeAsString } from '../utils.js';
|
|
3
|
+
import type { PageConfigBuildTime, ConfigValue } from './PageConfig.js';
|
|
4
|
+
import type { ConfigNameBuiltIn } from './Config.js';
|
|
5
|
+
import { type TypeAsString } from './getConfigValue.js';
|
|
6
|
+
type ConfigName = ConfigNameBuiltIn;
|
|
7
|
+
declare function getConfigValueBuildTime<Type extends TypeAsString = undefined>(pageConfig: PageConfigBuildTime, configName: ConfigName, type?: Type): null | (ConfigValue & {
|
|
8
|
+
value: ResolveTypeAsString<Type>;
|
|
9
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export { getConfigValueBuildTime };
|
|
2
|
+
import { assert } from '../utils.js';
|
|
3
|
+
import { getConfigValueTyped } from './getConfigValue.js';
|
|
4
|
+
import { assertIsNotProductionRuntime } from '../../utils/assertIsNotProductionRuntime.js';
|
|
5
|
+
assertIsNotProductionRuntime();
|
|
6
|
+
function getConfigValueBuildTime(pageConfig, configName, type) {
|
|
7
|
+
const configValue = getConfigValue(pageConfig, configName);
|
|
8
|
+
if (!configValue)
|
|
9
|
+
return null;
|
|
10
|
+
return getConfigValueTyped(configValue, configName, type);
|
|
11
|
+
}
|
|
12
|
+
function getConfigValue(pageConfig, configName) {
|
|
13
|
+
const { configValueSources, configValuesComputed, configDefinitions } = pageConfig;
|
|
14
|
+
const configValueComputed = configValuesComputed[configName];
|
|
15
|
+
if (configValueComputed) {
|
|
16
|
+
return {
|
|
17
|
+
type: 'computed',
|
|
18
|
+
value: configValueComputed.value,
|
|
19
|
+
definedAtData: null
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const sources = configValueSources[configName];
|
|
23
|
+
if (!sources)
|
|
24
|
+
return null;
|
|
25
|
+
assert(sources.every((s) => s.configEnv.config === true));
|
|
26
|
+
const configDef = configDefinitions[configName];
|
|
27
|
+
assert(configDef);
|
|
28
|
+
if (!configDef.cumulative) {
|
|
29
|
+
const configValueSource = sources[0];
|
|
30
|
+
assert(configValueSource);
|
|
31
|
+
assert(configValueSource.isOverriden === false);
|
|
32
|
+
assert(sources.slice(1).every((s) => s.isOverriden === true));
|
|
33
|
+
assert('value' in configValueSource);
|
|
34
|
+
return {
|
|
35
|
+
type: 'standard',
|
|
36
|
+
value: configValueSource.value,
|
|
37
|
+
definedAtData: getDefinedAtFile(configValueSource)
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
const { value, definedAtData } = mergeCumulative(sources);
|
|
42
|
+
assert(value.length === definedAtData.length);
|
|
43
|
+
return {
|
|
44
|
+
type: 'cumulative',
|
|
45
|
+
value,
|
|
46
|
+
definedAtData
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function mergeCumulative(configValueSources) {
|
|
51
|
+
const value = [];
|
|
52
|
+
const definedAtData = [];
|
|
53
|
+
configValueSources.forEach((configValueSource) => {
|
|
54
|
+
assert(configValueSource.isOverriden === false);
|
|
55
|
+
assert(configValueSource.configEnv.config === true);
|
|
56
|
+
assert('value' in configValueSource);
|
|
57
|
+
value.push(configValueSource.value);
|
|
58
|
+
definedAtData.push(getDefinedAtFile(configValueSource));
|
|
59
|
+
});
|
|
60
|
+
return { value, definedAtData };
|
|
61
|
+
}
|
|
62
|
+
function getDefinedAtFile(configValueSource) {
|
|
63
|
+
return {
|
|
64
|
+
filePathToShowToUser: configValueSource.definedAtFilePath.filePathToShowToUser,
|
|
65
|
+
fileExportPathToShowToUser: configValueSource.definedAtFilePath.fileExportPathToShowToUser
|
|
66
|
+
};
|
|
67
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { loadConfigValues };
|
|
2
2
|
import { objectAssign } from '../utils.js';
|
|
3
|
-
import {
|
|
4
|
-
import { parseConfigValuesSerialized } from './serialize/parseConfigValuesSerialized.js';
|
|
3
|
+
import { parseConfigValuesSerialized } from './serialize/parsePageConfigs.js';
|
|
5
4
|
async function loadConfigValues(pageConfig, isDev) {
|
|
6
5
|
if ('isAllLoaded' in pageConfig &&
|
|
7
6
|
// We don't need to cache in dev, since Vite already caches the virtual module
|
|
@@ -9,16 +8,8 @@ async function loadConfigValues(pageConfig, isDev) {
|
|
|
9
8
|
return pageConfig;
|
|
10
9
|
}
|
|
11
10
|
const configValuesLoaded = await pageConfig.loadConfigValuesAll();
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const configValuesAddendum = parseConfigValuesImported(configValuesImported);
|
|
15
|
-
Object.assign(pageConfig.configValues, configValuesAddendum);
|
|
16
|
-
}
|
|
17
|
-
{
|
|
18
|
-
const { configValuesSerialized } = configValuesLoaded;
|
|
19
|
-
const configValuesAddendum = parseConfigValuesSerialized(configValuesSerialized);
|
|
20
|
-
Object.assign(pageConfig.configValues, configValuesAddendum);
|
|
21
|
-
}
|
|
11
|
+
const configValues = parseConfigValuesSerialized(configValuesLoaded.configValuesSerialized);
|
|
12
|
+
Object.assign(pageConfig.configValues, configValues);
|
|
22
13
|
objectAssign(pageConfig, { isAllLoaded: true });
|
|
23
14
|
return pageConfig;
|
|
24
15
|
}
|
|
@@ -1,35 +1,31 @@
|
|
|
1
1
|
export type { PageConfigRuntimeSerialized };
|
|
2
2
|
export type { PageConfigGlobalRuntimeSerialized };
|
|
3
3
|
export type { ConfigValueSerialized };
|
|
4
|
-
export type {
|
|
4
|
+
export type { ValueSerialized };
|
|
5
5
|
import type { ConfigValueStandard, ConfigValueComputed, ConfigValueCumulative, PageConfigRuntime } from '../PageConfig.js';
|
|
6
6
|
/** Page config data structure serialized in virtual files: parsing it results in PageConfigRuntime */
|
|
7
7
|
type PageConfigRuntimeSerialized = Omit<PageConfigRuntime, 'configValues'> & {
|
|
8
8
|
/** Config values that are serializable and loaded eagerly such as config.passToClient */
|
|
9
9
|
configValuesSerialized: Record<string, ConfigValueSerialized>;
|
|
10
|
-
/** Config values imported eagerly such as config.route */
|
|
11
|
-
configValuesImported: ConfigValueImported[];
|
|
12
10
|
};
|
|
13
11
|
type PageConfigGlobalRuntimeSerialized = {
|
|
14
|
-
|
|
12
|
+
configValuesSerialized: Record<string, ConfigValueSerialized>;
|
|
13
|
+
};
|
|
14
|
+
type ValueSerialized = {
|
|
15
|
+
type: 'js-serialized';
|
|
16
|
+
value: unknown;
|
|
17
|
+
} | {
|
|
18
|
+
type: 'plus-file';
|
|
19
|
+
exportValues: Record<string, unknown>;
|
|
20
|
+
} | {
|
|
21
|
+
type: 'pointer-import';
|
|
22
|
+
value: unknown;
|
|
15
23
|
};
|
|
16
24
|
/** Value is serialized */
|
|
17
25
|
type ConfigValueSerialized = (Omit<ConfigValueStandard, 'value'> & {
|
|
18
|
-
valueSerialized:
|
|
26
|
+
valueSerialized: ValueSerialized;
|
|
19
27
|
}) | (Omit<ConfigValueCumulative, 'value'> & {
|
|
20
|
-
valueSerialized:
|
|
28
|
+
valueSerialized: ValueSerialized[];
|
|
21
29
|
}) | (Omit<ConfigValueComputed, 'value'> & {
|
|
22
|
-
valueSerialized:
|
|
23
|
-
});
|
|
24
|
-
/** Value is imported */
|
|
25
|
-
type ConfigValueImported = {
|
|
26
|
-
configName: string;
|
|
27
|
-
importPath: string;
|
|
28
|
-
} & ({
|
|
29
|
-
isValueFile: true;
|
|
30
|
-
exportValues: Record<string, unknown>;
|
|
31
|
-
} | {
|
|
32
|
-
isValueFile: false;
|
|
33
|
-
exportName: string;
|
|
34
|
-
exportValue: unknown;
|
|
30
|
+
valueSerialized: ValueSerialized;
|
|
35
31
|
});
|
|
@@ -8,9 +8,8 @@ function assertPageConfigsSerialized(pageConfigsSerialized) {
|
|
|
8
8
|
assert(hasProp(pageConfigSerialized, 'pageId', 'string'));
|
|
9
9
|
assert(hasProp(pageConfigSerialized, 'routeFilesystem'));
|
|
10
10
|
assert(hasProp(pageConfigSerialized, 'configValuesSerialized'));
|
|
11
|
-
assert(hasProp(pageConfigSerialized, 'configValuesImported'));
|
|
12
11
|
});
|
|
13
12
|
}
|
|
14
13
|
function assertPageConfigGlobalSerialized(pageConfigGlobalSerialized) {
|
|
15
|
-
assert(hasProp(pageConfigGlobalSerialized, '
|
|
14
|
+
assert(hasProp(pageConfigGlobalSerialized, 'configValuesSerialized'));
|
|
16
15
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export { parsePageConfigs };
|
|
2
|
-
|
|
2
|
+
export { parseConfigValuesSerialized };
|
|
3
|
+
import type { ConfigValues, PageConfigRuntime, PageConfigGlobalRuntime } from '../PageConfig.js';
|
|
3
4
|
import type { PageConfigGlobalRuntimeSerialized, PageConfigRuntimeSerialized } from './PageConfigSerialized.js';
|
|
5
|
+
import type { ConfigValueSerialized } from './PageConfigSerialized.js';
|
|
6
|
+
declare function parseConfigValuesSerialized(configValuesSerialized: Record<string, ConfigValueSerialized>): ConfigValues;
|
|
4
7
|
declare function parsePageConfigs(pageConfigsSerialized: PageConfigRuntimeSerialized[], pageConfigGlobalSerialized: PageConfigGlobalRuntimeSerialized): {
|
|
5
8
|
pageConfigs: PageConfigRuntime[];
|
|
6
9
|
pageConfigGlobal: PageConfigGlobalRuntime;
|
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
export { parsePageConfigs };
|
|
2
|
-
|
|
2
|
+
export { parseConfigValuesSerialized };
|
|
3
3
|
import { assert, assertUsage, isCallable } from '../../utils.js';
|
|
4
4
|
import { getConfigDefinedAt } from '../getConfigDefinedAt.js';
|
|
5
|
-
import {
|
|
5
|
+
import { parseTransform } from '@brillout/json-serializer/parse';
|
|
6
|
+
import { assertPlusFileExport } from '../assertPlusFileExport.js';
|
|
7
|
+
function parseConfigValuesSerialized(configValuesSerialized) {
|
|
8
|
+
const configValues = parseConfigValuesSerialized_tmp(configValuesSerialized);
|
|
9
|
+
return configValues;
|
|
10
|
+
}
|
|
6
11
|
function parsePageConfigs(pageConfigsSerialized, pageConfigGlobalSerialized) {
|
|
12
|
+
// pageConfigs
|
|
7
13
|
const pageConfigs = pageConfigsSerialized.map((pageConfigSerialized) => {
|
|
8
|
-
const configValues =
|
|
9
|
-
{
|
|
10
|
-
const { configValuesSerialized } = pageConfigSerialized;
|
|
11
|
-
const configValuesAddendum = parseConfigValuesSerialized(configValuesSerialized);
|
|
12
|
-
Object.assign(configValues, configValuesAddendum);
|
|
13
|
-
}
|
|
14
|
-
{
|
|
15
|
-
const { configValuesImported } = pageConfigSerialized;
|
|
16
|
-
const configValuesAddendum = parseConfigValuesImported(configValuesImported);
|
|
17
|
-
Object.assign(configValues, configValuesAddendum);
|
|
18
|
-
}
|
|
14
|
+
const configValues = parseConfigValuesSerialized(pageConfigSerialized.configValuesSerialized);
|
|
19
15
|
const { pageId, isErrorPage, routeFilesystem, loadConfigValuesAll } = pageConfigSerialized;
|
|
20
16
|
assertRouteConfigValue(configValues);
|
|
21
17
|
return {
|
|
@@ -26,10 +22,11 @@ function parsePageConfigs(pageConfigsSerialized, pageConfigGlobalSerialized) {
|
|
|
26
22
|
loadConfigValuesAll
|
|
27
23
|
};
|
|
28
24
|
});
|
|
25
|
+
// pageConfigsGlobal
|
|
29
26
|
const pageConfigGlobal = { configValues: {} };
|
|
30
27
|
{
|
|
31
|
-
const
|
|
32
|
-
Object.assign(pageConfigGlobal.configValues,
|
|
28
|
+
const configValues = parseConfigValuesSerialized(pageConfigGlobalSerialized.configValuesSerialized);
|
|
29
|
+
Object.assign(pageConfigGlobal.configValues, configValues);
|
|
33
30
|
}
|
|
34
31
|
return { pageConfigs, pageConfigGlobal };
|
|
35
32
|
}
|
|
@@ -52,3 +49,100 @@ function assertRouteConfigValue(configValues) {
|
|
|
52
49
|
}
|
|
53
50
|
*/
|
|
54
51
|
}
|
|
52
|
+
function parseConfigValuesSerialized_tmp(configValuesSerialized) {
|
|
53
|
+
const configValues = {};
|
|
54
|
+
Object.entries(configValuesSerialized).forEach(([configName, configValueSeriliazed]) => {
|
|
55
|
+
let configValue;
|
|
56
|
+
if (configValueSeriliazed.type === 'cumulative') {
|
|
57
|
+
const { valueSerialized, ...common } = configValueSeriliazed;
|
|
58
|
+
const value = valueSerialized.map((valueSerializedElement, i) => {
|
|
59
|
+
const { value, sideExports } = parseValueSerialized(valueSerializedElement, configName, () => {
|
|
60
|
+
const definedAtFile = configValueSeriliazed.definedAtData[i];
|
|
61
|
+
assert(definedAtFile);
|
|
62
|
+
return definedAtFile;
|
|
63
|
+
});
|
|
64
|
+
addSideExports(sideExports);
|
|
65
|
+
return value;
|
|
66
|
+
});
|
|
67
|
+
configValue = { value, ...common };
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
const { valueSerialized, ...common } = configValueSeriliazed;
|
|
71
|
+
const { value, sideExports } = parseValueSerialized(valueSerialized, configName, () => {
|
|
72
|
+
assert(configValueSeriliazed.type !== 'computed');
|
|
73
|
+
return configValueSeriliazed.definedAtData;
|
|
74
|
+
});
|
|
75
|
+
addSideExports(sideExports);
|
|
76
|
+
configValue = { value, ...common };
|
|
77
|
+
}
|
|
78
|
+
configValues[configName] = configValue;
|
|
79
|
+
});
|
|
80
|
+
return configValues;
|
|
81
|
+
function addSideExports(sideExports) {
|
|
82
|
+
sideExports.forEach((sideExport) => {
|
|
83
|
+
const { configName, configValue } = sideExport;
|
|
84
|
+
if (!configValues[configName]) {
|
|
85
|
+
configValues[configName] = configValue;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
// Side-exports have lower precedence.
|
|
89
|
+
// We can't avoid side-export conflicts upstream. (We cannot know about side-exports at build-time.)
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function parseValueSerialized(valueSerialized, configName, getDefinedAtFile) {
|
|
95
|
+
if (valueSerialized.type === 'js-serialized') {
|
|
96
|
+
let { value } = valueSerialized;
|
|
97
|
+
value = parseTransform(value);
|
|
98
|
+
return { value, sideExports: [] };
|
|
99
|
+
}
|
|
100
|
+
if (valueSerialized.type === 'pointer-import') {
|
|
101
|
+
const { value } = valueSerialized;
|
|
102
|
+
return { value, sideExports: [] };
|
|
103
|
+
}
|
|
104
|
+
if (valueSerialized.type === 'plus-file') {
|
|
105
|
+
const definedAtFile = getDefinedAtFile();
|
|
106
|
+
const { exportValues } = valueSerialized;
|
|
107
|
+
assertPlusFileExport(exportValues, definedAtFile.filePathToShowToUser, configName);
|
|
108
|
+
let value;
|
|
109
|
+
let valueWasFound = false;
|
|
110
|
+
const sideExports = [];
|
|
111
|
+
Object.entries(exportValues).forEach(([exportName, exportValue]) => {
|
|
112
|
+
const isSideExport = exportName !== 'default' && exportName !== configName;
|
|
113
|
+
if (!isSideExport) {
|
|
114
|
+
value = exportValue;
|
|
115
|
+
assert(!valueWasFound);
|
|
116
|
+
valueWasFound = true;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
sideExports.push({
|
|
120
|
+
configName: exportName,
|
|
121
|
+
configValue: {
|
|
122
|
+
type: 'standard', // We don't support side exports for cumulative values. We could support it but it isn't trivial.
|
|
123
|
+
value: exportValue,
|
|
124
|
+
definedAtData: {
|
|
125
|
+
filePathToShowToUser: definedAtFile.filePathToShowToUser,
|
|
126
|
+
fileExportPathToShowToUser: [exportName]
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
assert(valueWasFound);
|
|
133
|
+
return { value, sideExports };
|
|
134
|
+
}
|
|
135
|
+
assert(false);
|
|
136
|
+
}
|
|
137
|
+
/* [NULL_HANDLING] Do we really need this?
|
|
138
|
+
function assertIsNotNull(configValue: unknown, configName: string, filePathToShowToUser: string) {
|
|
139
|
+
assert(!filePathToShowToUser.includes('+config.'))
|
|
140
|
+
// Re-use this for:
|
|
141
|
+
// - upcoming config.requestPageContextOnNavigation
|
|
142
|
+
// - for cumulative values in the future: we don't need this for now because, currently, cumulative values are never imported.
|
|
143
|
+
assertUsage(
|
|
144
|
+
configValue !== null,
|
|
145
|
+
`Set ${pc.cyan(configName)} to ${pc.cyan('null')} in a +config.js file instead of ${filePathToShowToUser}`
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
*/
|