vike 0.4.171-commit-f9548df → 0.4.171-commit-3b2cb88
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/devConfig/index.js +2 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +0 -1
- 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 +3 -2
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +3 -3
- package/dist/cjs/node/runtime/html/injectAssets/getViteDevScripts.js +2 -1
- package/dist/cjs/node/runtime/html/injectAssets/mergeScriptTags.js +2 -8
- 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/renderPageAlreadyRouted.js +2 -2
- package/dist/cjs/node/shared/assertV1Design.js +3 -4
- package/dist/cjs/shared/getPageContextUrlComputed.js +8 -6
- package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +2 -2
- package/dist/cjs/shared/getPageFiles/parseGlobResults.js +15 -8
- 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 +0 -18
- 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/loadPageRoutes.js +2 -2
- package/dist/cjs/utils/hasProp.js +5 -7
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/client/client-routing-runtime/createPageContext.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +3 -3
- package/dist/esm/client/client-routing-runtime/installClientRouter.js +18 -10
- package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +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/devConfig/index.js +2 -1
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +0 -1
- 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 +4 -3
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +3 -3
- package/dist/esm/node/runtime/html/injectAssets/getViteDevScripts.js +3 -2
- package/dist/esm/node/runtime/html/injectAssets/mergeScriptTags.d.ts +1 -1
- package/dist/esm/node/runtime/html/injectAssets/mergeScriptTags.js +2 -8
- 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/loadUserFilesServerSide.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +4 -4
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +2 -2
- package/dist/esm/node/shared/assertV1Design.d.ts +2 -2
- package/dist/esm/node/shared/assertV1Design.js +3 -4
- package/dist/esm/shared/getPageContextUrlComputed.js +8 -6
- package/dist/esm/shared/getPageFiles/analyzeClientSide.js +3 -3
- package/dist/esm/shared/getPageFiles/parseGlobResults.js +14 -7
- 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.d.ts +1 -5
- package/dist/esm/shared/page-configs/serialize/assertPageConfigsSerialized.js +1 -16
- 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/loadPageRoutes.js +3 -3
- package/dist/esm/utils/hasProp.d.ts +4 -13
- package/dist/esm/utils/hasProp.js +5 -7
- 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
|
@@ -14,12 +14,12 @@ import { logConfigError, logConfigErrorRecover } from '../../../shared/loggerNot
|
|
|
14
14
|
import { removeSuperfluousViteLog_enable, removeSuperfluousViteLog_disable } from '../../../shared/loggerVite/removeSuperfluousViteLog.js';
|
|
15
15
|
import pc from '@brillout/picocolors';
|
|
16
16
|
import { getConfigDefinedAt } from '../../../../../shared/page-configs/getConfigDefinedAt.js';
|
|
17
|
-
import { assertConfigValueIsSerializable } from './getConfigValuesSerialized.js';
|
|
18
17
|
import { crawlPlusFiles } from './getVikeConfig/crawlPlusFiles.js';
|
|
19
18
|
import { getConfigFileExport } from './getConfigFileExport.js';
|
|
20
19
|
import { loadConfigFile, loadImportedFile, loadValueFile } from './getVikeConfig/loadFileAtConfigTime.js';
|
|
21
20
|
import { clearFilesEnvMap, resolvePointerImportOfConfig } from './getVikeConfig/resolvePointerImport.js';
|
|
22
21
|
import { getFilePathResolved } from '../../../shared/getFilePath.js';
|
|
22
|
+
import { getConfigValueBuildTime } from '../../../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
23
23
|
assertIsNotProductionRuntime();
|
|
24
24
|
let devServerIsCorrupt = false;
|
|
25
25
|
let wasConfigInvalid = null;
|
|
@@ -166,7 +166,7 @@ async function loadInterfaceFiles(userRootDir, outDirRoot, isDev) {
|
|
|
166
166
|
// - If `configDef` is `undefined` => we load the file +{configName}.js later.
|
|
167
167
|
// - We already need to load +meta.js here (to get the custom config definitions defined by the user)
|
|
168
168
|
const configDef = getConfigDefinitionOptional(configDefinitionsBuiltIn, configName);
|
|
169
|
-
if (configDef &&
|
|
169
|
+
if (configDef && isLoadableAtBuildTime(configDef)) {
|
|
170
170
|
await loadValueFile(interfaceFile, configName, userRootDir);
|
|
171
171
|
}
|
|
172
172
|
}
|
|
@@ -241,6 +241,7 @@ async function loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev,
|
|
|
241
241
|
const dummyData = {
|
|
242
242
|
pageConfigs: [],
|
|
243
243
|
pageConfigGlobal: {
|
|
244
|
+
configDefinitions: {},
|
|
244
245
|
configValueSources: {}
|
|
245
246
|
},
|
|
246
247
|
globalVikeConfig: {}
|
|
@@ -266,7 +267,7 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev) {
|
|
|
266
267
|
if (isGlobalConfig(configName))
|
|
267
268
|
return;
|
|
268
269
|
const configDef = getConfigDefinition(configDefinitions, configName, interfaceFile.filePath.filePathToShowToUser);
|
|
269
|
-
if (!
|
|
270
|
+
if (!isLoadableAtBuildTime(configDef))
|
|
270
271
|
return;
|
|
271
272
|
const isAlreadyLoaded = interfacefileIsAlreaydLoaded(interfaceFile);
|
|
272
273
|
if (isAlreadyLoaded)
|
|
@@ -288,14 +289,13 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev) {
|
|
|
288
289
|
const { routeFilesystem, isErrorPage } = determineRouteFilesystem(locationId, configValueSources);
|
|
289
290
|
applyEffectsAll(configValueSources, configDefinitions);
|
|
290
291
|
const configValuesComputed = getComputed(configValueSources, configDefinitions);
|
|
291
|
-
const configValues = getConfigValues(configValueSources, configValuesComputed, configDefinitions);
|
|
292
292
|
const pageConfig = {
|
|
293
293
|
pageId: locationId,
|
|
294
294
|
isErrorPage,
|
|
295
295
|
routeFilesystem,
|
|
296
|
+
configDefinitions,
|
|
296
297
|
configValueSources,
|
|
297
|
-
configValuesComputed
|
|
298
|
-
configValues
|
|
298
|
+
configValuesComputed
|
|
299
299
|
};
|
|
300
300
|
return pageConfig;
|
|
301
301
|
}));
|
|
@@ -328,7 +328,7 @@ function assertOnBeforeRenderEnv(pageConfig) {
|
|
|
328
328
|
if (!onBeforeRenderConfig)
|
|
329
329
|
return;
|
|
330
330
|
const onBeforeRenderEnv = onBeforeRenderConfig.configEnv;
|
|
331
|
-
const isClientRouting =
|
|
331
|
+
const isClientRouting = getConfigValueBuildTime(pageConfig, 'clientRouting', 'boolean');
|
|
332
332
|
// When using Server Routing, loading a onBeforeRender() hook on the client-side hasn't any effect (the Server Routing's client runtime never calls it); it unnecessarily bloats client bundle sizes
|
|
333
333
|
assertUsage(!(onBeforeRenderEnv.client && !isClientRouting), `Page ${pageConfig.pageId} has an onBeforeRender() hook with env ${pc.cyan(JSON.stringify(onBeforeRenderEnv))} which doesn't make sense because the page is using Server Routing: onBeforeRender() can be run in the client only when using Client Routing.`);
|
|
334
334
|
}
|
|
@@ -389,6 +389,7 @@ async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importe
|
|
|
389
389
|
}
|
|
390
390
|
const globalVikeConfig = {};
|
|
391
391
|
const pageConfigGlobal = {
|
|
392
|
+
configDefinitions: configDefinitionsBuiltInGlobal,
|
|
392
393
|
configValueSources: {}
|
|
393
394
|
};
|
|
394
395
|
await Promise.all(objectEntries(configDefinitionsBuiltInGlobal).map(async ([configName, configDef]) => {
|
|
@@ -422,7 +423,15 @@ async function resolveConfigValueSources(configName, configDef, interfaceFilesRe
|
|
|
422
423
|
const add = (interfaceFile) => {
|
|
423
424
|
assert(!visited.has(interfaceFile));
|
|
424
425
|
visited.add(interfaceFile);
|
|
425
|
-
sourcesInfo.
|
|
426
|
+
const isHighestInheritancePrecedence = sourcesInfo.length === 0;
|
|
427
|
+
sourcesInfo.push([
|
|
428
|
+
configName,
|
|
429
|
+
interfaceFile,
|
|
430
|
+
configDef,
|
|
431
|
+
userRootDir,
|
|
432
|
+
importedFilesLoaded,
|
|
433
|
+
isHighestInheritancePrecedence
|
|
434
|
+
]);
|
|
426
435
|
};
|
|
427
436
|
// Main resolution logic
|
|
428
437
|
{
|
|
@@ -493,7 +502,7 @@ function warnOverridenConfigValues(interfaceFileWinner, interfaceFilesOverriden,
|
|
|
493
502
|
function isInterfaceFileUserLand(interfaceFile) {
|
|
494
503
|
return (interfaceFile.isConfigFile && !interfaceFile.isConfigExtend) || interfaceFile.isValueFile;
|
|
495
504
|
}
|
|
496
|
-
async function getConfigValueSource(configName, interfaceFile, configDef, userRootDir, importedFilesLoaded) {
|
|
505
|
+
async function getConfigValueSource(configName, interfaceFile, configDef, userRootDir, importedFilesLoaded, isHighestInheritancePrecedence) {
|
|
497
506
|
const conf = interfaceFile.fileExportsByConfigName[configName];
|
|
498
507
|
assert(conf);
|
|
499
508
|
const configEnv = deriveConfigEnvFromFileName(configDef.env, interfaceFile.filePath.fileName);
|
|
@@ -502,6 +511,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
502
511
|
...interfaceFile.filePath,
|
|
503
512
|
fileExportPathToShowToUser: ['default', configName]
|
|
504
513
|
};
|
|
514
|
+
const isOverriden = configDef.cumulative ? false : !isHighestInheritancePrecedence;
|
|
505
515
|
// +client.js
|
|
506
516
|
if (configDef._valueIsFilePath) {
|
|
507
517
|
let definedAtFilePath;
|
|
@@ -528,7 +538,8 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
528
538
|
valueIsFilePath: true,
|
|
529
539
|
configEnv,
|
|
530
540
|
valueIsImportedAtRuntime: true,
|
|
531
|
-
|
|
541
|
+
valueIsDefinedByPlusFile: false,
|
|
542
|
+
isOverriden,
|
|
532
543
|
definedAtFilePath
|
|
533
544
|
};
|
|
534
545
|
return configValueSource;
|
|
@@ -544,11 +555,12 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
544
555
|
locationId,
|
|
545
556
|
configEnv,
|
|
546
557
|
valueIsImportedAtRuntime: true,
|
|
547
|
-
|
|
558
|
+
valueIsDefinedByPlusFile: false,
|
|
559
|
+
isOverriden,
|
|
548
560
|
definedAtFilePath: pointerImport
|
|
549
561
|
};
|
|
550
562
|
// Load pointer import
|
|
551
|
-
if (
|
|
563
|
+
if (isLoadableAtBuildTime(configDef) &&
|
|
552
564
|
// The value of `extends` was already loaded and already used: we don't need the value of `extends` anymore
|
|
553
565
|
configName !== 'extends') {
|
|
554
566
|
if (pointerImport.filePathAbsoluteFilesystem) {
|
|
@@ -568,7 +580,8 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
568
580
|
value: configValue,
|
|
569
581
|
configEnv,
|
|
570
582
|
valueIsImportedAtRuntime: false,
|
|
571
|
-
|
|
583
|
+
valueIsDefinedByPlusFile: false,
|
|
584
|
+
isOverriden,
|
|
572
585
|
definedAtFilePath: definedAtFilePath_
|
|
573
586
|
};
|
|
574
587
|
return configValueSource;
|
|
@@ -581,7 +594,8 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
581
594
|
locationId,
|
|
582
595
|
configEnv,
|
|
583
596
|
valueIsImportedAtRuntime: !valueAlreadyLoaded,
|
|
584
|
-
|
|
597
|
+
valueIsDefinedByPlusFile: true,
|
|
598
|
+
isOverriden,
|
|
585
599
|
definedAtFilePath: {
|
|
586
600
|
...interfaceFile.filePath,
|
|
587
601
|
fileExportPathToShowToUser: configName === interfaceFile.configName
|
|
@@ -876,59 +890,6 @@ function determineIsErrorPage(routeFilesystem) {
|
|
|
876
890
|
function isVikeConfigFile(filePath) {
|
|
877
891
|
return !!getConfigName(filePath);
|
|
878
892
|
}
|
|
879
|
-
function getConfigValues(configValueSources, configValuesComputed, configDefinitions) {
|
|
880
|
-
const configValues = {};
|
|
881
|
-
Object.entries(configValuesComputed).forEach(([configName, configValueComputed]) => {
|
|
882
|
-
configValues[configName] = {
|
|
883
|
-
type: 'computed',
|
|
884
|
-
value: configValueComputed.value,
|
|
885
|
-
definedAtData: null
|
|
886
|
-
};
|
|
887
|
-
});
|
|
888
|
-
Object.entries(configValueSources).forEach(([configName, sources]) => {
|
|
889
|
-
const configDef = configDefinitions[configName];
|
|
890
|
-
assert(configDef);
|
|
891
|
-
if (!configDef.cumulative) {
|
|
892
|
-
const configValueSource = sources[0];
|
|
893
|
-
if ('value' in configValueSource) {
|
|
894
|
-
configValues[configName] = {
|
|
895
|
-
type: 'standard',
|
|
896
|
-
value: configValueSource.value,
|
|
897
|
-
definedAtData: getDefinedAtFile(configValueSource)
|
|
898
|
-
};
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
else {
|
|
902
|
-
const value = mergeCumulative(configName, sources);
|
|
903
|
-
const definedAtData = sources.map((source) => getDefinedAtFile(source));
|
|
904
|
-
assert(value.length === definedAtData.length);
|
|
905
|
-
configValues[configName] = {
|
|
906
|
-
type: 'cumulative',
|
|
907
|
-
value,
|
|
908
|
-
definedAtData
|
|
909
|
-
};
|
|
910
|
-
}
|
|
911
|
-
});
|
|
912
|
-
return configValues;
|
|
913
|
-
}
|
|
914
|
-
function getDefinedAtFile(configValueSource) {
|
|
915
|
-
return {
|
|
916
|
-
filePathToShowToUser: configValueSource.definedAtFilePath.filePathToShowToUser,
|
|
917
|
-
fileExportPathToShowToUser: configValueSource.definedAtFilePath.fileExportPathToShowToUser
|
|
918
|
-
};
|
|
919
|
-
}
|
|
920
|
-
function mergeCumulative(configName, configValueSources) {
|
|
921
|
-
const configValues = [];
|
|
922
|
-
configValueSources.forEach((configValueSource) => {
|
|
923
|
-
// We could, in principle, also support cumulative for values that aren't loaded at config-time but it isn't completely trivial to implement.
|
|
924
|
-
assert('value' in configValueSource);
|
|
925
|
-
// Make sure configValueSource.value is serializable
|
|
926
|
-
assertConfigValueIsSerializable(configValueSource.value, configName, getDefinedAtFile(configValueSource));
|
|
927
|
-
const { value } = configValueSource;
|
|
928
|
-
configValues.push(value);
|
|
929
|
-
});
|
|
930
|
-
return configValues;
|
|
931
|
-
}
|
|
932
893
|
function getConfigEnvValue(val, errMsgIntro) {
|
|
933
894
|
const errInvalidValue = `${errMsgIntro} an invalid value ${pc.cyan(JSON.stringify(val))}`;
|
|
934
895
|
// Legacy outdated values
|
|
@@ -971,13 +932,8 @@ function getConfigDefinition(configDefinitions, configName, filePathToShowToUser
|
|
|
971
932
|
function getConfigDefinitionOptional(configDefinitions, configName) {
|
|
972
933
|
return configDefinitions[configName] ?? null;
|
|
973
934
|
}
|
|
974
|
-
function
|
|
975
|
-
|
|
976
|
-
if (configDef.cumulative) {
|
|
977
|
-
// In principle we could lift that requirement (but it requires non-trivial modifications)
|
|
978
|
-
assertUsage(configEnv.config, `Config ${pc.cyan(configName)} needs its ${pc.cyan('env')} to have ${pc.cyan('{ config: true }')} (because ${pc.cyan(configName)} is a ${pc.cyan('cumulative')} config)`);
|
|
979
|
-
}
|
|
980
|
-
return !!configEnv.config;
|
|
935
|
+
function isLoadableAtBuildTime(configDef) {
|
|
936
|
+
return !!configDef.env.config && !configDef._valueIsFilePath;
|
|
981
937
|
}
|
|
982
938
|
function isGlobalConfig(configName) {
|
|
983
939
|
if (configName === 'prerender')
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js
CHANGED
|
@@ -4,13 +4,11 @@ import { getVirtualFileIdPageConfigValuesAll, isVirtualFileIdPageConfigValuesAll
|
|
|
4
4
|
import { getVikeConfig } from './getVikeConfig.js';
|
|
5
5
|
import { extractAssetsAddQuery } from '../../../../shared/extractAssetsQuery.js';
|
|
6
6
|
import { debug } from './debug.js';
|
|
7
|
-
import { getConfigValue } from '../../../../../shared/page-configs/getConfigValue.js';
|
|
8
|
-
import { getConfigValueSourcesNotOverriden } from '../../../shared/getConfigValueSourcesNotOverriden.js';
|
|
9
7
|
import { isRuntimeEnvMatch } from './isRuntimeEnvMatch.js';
|
|
10
|
-
import {
|
|
8
|
+
import { serializeConfigValues } from '../../../../../shared/page-configs/serialize/serializeConfigValues.js';
|
|
11
9
|
import { getConfigVike } from '../../../../shared/getConfigVike.js';
|
|
12
|
-
import { getConfigValuesSerialized } from './getConfigValuesSerialized.js';
|
|
13
10
|
import { fixServerAssets_isEnabled } from '../../buildConfig/fixServerAssets.js';
|
|
11
|
+
import { getConfigValueBuildTime } from '../../../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
14
12
|
async function getVirtualFilePageConfigValuesAll(id, isDev, config) {
|
|
15
13
|
const result = isVirtualFileIdPageConfigValuesAll(id);
|
|
16
14
|
assert(result);
|
|
@@ -32,16 +30,9 @@ async function getVirtualFilePageConfigValuesAll(id, isDev, config) {
|
|
|
32
30
|
function getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, includeAssetsImportedByServer, isDev) {
|
|
33
31
|
const lines = [];
|
|
34
32
|
const importStatements = [];
|
|
35
|
-
const isClientRouting =
|
|
36
|
-
lines.push('export const configValuesImported = [');
|
|
37
|
-
lines.push(getConfigValuesImported(pageConfig, isForClientSide, isClientRouting, importStatements));
|
|
38
|
-
lines.push('];');
|
|
33
|
+
const isClientRouting = getConfigValueBuildTime(pageConfig, 'clientRouting', 'boolean')?.value ?? false;
|
|
39
34
|
lines.push('export const configValuesSerialized = {');
|
|
40
|
-
lines.push(
|
|
41
|
-
isImport: false,
|
|
42
|
-
isForClientSide,
|
|
43
|
-
isClientRouting
|
|
44
|
-
})));
|
|
35
|
+
lines.push(...serializeConfigValues(pageConfig, importStatements, (configEnv) => isRuntimeEnvMatch(configEnv, { isForClientSide, isClientRouting, isEager: false, isDev }), ''));
|
|
45
36
|
lines.push('};');
|
|
46
37
|
if (!fixServerAssets_isEnabled() && includeAssetsImportedByServer && isForClientSide && !isDev) {
|
|
47
38
|
importStatements.push(`import '${extractAssetsAddQuery(getVirtualFileIdPageConfigValuesAll(pageId, false))}'`);
|
|
@@ -49,32 +40,3 @@ function getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, includeAsse
|
|
|
49
40
|
const code = [...importStatements, ...lines].join('\n');
|
|
50
41
|
return code;
|
|
51
42
|
}
|
|
52
|
-
function getConfigValuesImported(pageConfig, isForClientSide, isClientRouting, importStatements) {
|
|
53
|
-
const lines = [];
|
|
54
|
-
getConfigValueSourcesNotOverriden(pageConfig).forEach((configValueSource) => {
|
|
55
|
-
if (!isEnvMatch(configValueSource.configEnv, checkWhetherIsImport(configValueSource), {
|
|
56
|
-
isImport: true,
|
|
57
|
-
isForClientSide,
|
|
58
|
-
isClientRouting
|
|
59
|
-
}))
|
|
60
|
-
return;
|
|
61
|
-
const whitespace = ' ';
|
|
62
|
-
lines.push(...serializeConfigValueImported(configValueSource, configValueSource.configName, whitespace, importStatements));
|
|
63
|
-
});
|
|
64
|
-
const code = lines.join('\n');
|
|
65
|
-
return code;
|
|
66
|
-
}
|
|
67
|
-
function checkWhetherIsImport(configValueSource) {
|
|
68
|
-
const { valueIsImportedAtRuntime, valueIsFilePath } = configValueSource;
|
|
69
|
-
return valueIsImportedAtRuntime && !valueIsFilePath;
|
|
70
|
-
}
|
|
71
|
-
function isEnvMatch(configEnv, isImport, runtime) {
|
|
72
|
-
// Whether config value is imported or serialized
|
|
73
|
-
if (isImport !== runtime.isImport)
|
|
74
|
-
return false;
|
|
75
|
-
// Runtime match
|
|
76
|
-
const { isForClientSide, isClientRouting } = runtime;
|
|
77
|
-
if (!isRuntimeEnvMatch(configEnv, { isForClientSide, isClientRouting, isEager: false }))
|
|
78
|
-
return false;
|
|
79
|
-
return true;
|
|
80
|
-
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
export { getVirtualFilePageConfigs };
|
|
2
|
-
import { assert, objectEntries } from '../../../utils.js';
|
|
3
2
|
import { getVirtualFileIdPageConfigValuesAll } from '../../../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
|
|
4
3
|
import { debug } from './debug.js';
|
|
5
4
|
import { getVikeConfig } from './getVikeConfig.js';
|
|
6
5
|
import { isRuntimeEnvMatch } from './isRuntimeEnvMatch.js';
|
|
7
|
-
import {
|
|
8
|
-
import { getConfigValuesSerialized } from './getConfigValuesSerialized.js';
|
|
6
|
+
import { serializeConfigValues } from '../../../../../shared/page-configs/serialize/serializeConfigValues.js';
|
|
9
7
|
async function getVirtualFilePageConfigs(isForClientSide, isDev, id, isClientRouting, config) {
|
|
10
8
|
const { pageConfigs, pageConfigGlobal } = await getVikeConfig(config, isDev, true);
|
|
11
9
|
return getCode(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isClientRouting);
|
|
@@ -14,16 +12,16 @@ function getCode(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isCl
|
|
|
14
12
|
const lines = [];
|
|
15
13
|
const importStatements = [];
|
|
16
14
|
lines.push('export const pageConfigsSerialized = [');
|
|
17
|
-
lines.push(getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRouting, importStatements));
|
|
15
|
+
lines.push(getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRouting, isDev, importStatements));
|
|
18
16
|
lines.push('];');
|
|
19
17
|
lines.push('export const pageConfigGlobalSerialized = {');
|
|
20
|
-
lines.push(getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, isDev, importStatements));
|
|
18
|
+
lines.push(getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, isClientRouting, isDev, importStatements));
|
|
21
19
|
lines.push('};');
|
|
22
20
|
const code = [...importStatements, ...lines].join('\n');
|
|
23
21
|
debug(id, isForClientSide ? 'CLIENT-SIDE' : 'SERVER-SIDE', code);
|
|
24
22
|
return code;
|
|
25
23
|
}
|
|
26
|
-
function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRouting, importStatements) {
|
|
24
|
+
function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRouting, isDev, importStatements) {
|
|
27
25
|
const lines = [];
|
|
28
26
|
pageConfigs.forEach((pageConfig) => {
|
|
29
27
|
const { pageId, routeFilesystem, isErrorPage } = pageConfig;
|
|
@@ -33,57 +31,19 @@ function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRout
|
|
|
33
31
|
lines.push(` isErrorPage: ${JSON.stringify(isErrorPage)},`);
|
|
34
32
|
lines.push(` routeFilesystem: ${JSON.stringify(routeFilesystem)},`);
|
|
35
33
|
lines.push(` loadConfigValuesAll: () => import(${JSON.stringify(virtualFileIdPageConfigValuesAll)}),`);
|
|
36
|
-
// Serialized config values
|
|
37
34
|
lines.push(` configValuesSerialized: {`);
|
|
38
|
-
lines.push(
|
|
35
|
+
lines.push(...serializeConfigValues(pageConfig, importStatements, (configEnv) => isRuntimeEnvMatch(configEnv, { isForClientSide, isClientRouting, isEager: true, isDev }), ' '));
|
|
39
36
|
lines.push(` },`);
|
|
40
|
-
// Imported config values
|
|
41
|
-
const whitespace = ' ';
|
|
42
|
-
lines.push(`${whitespace}configValuesImported: [`);
|
|
43
|
-
Object.entries(pageConfig.configValueSources).forEach(([configName, sources]) => {
|
|
44
|
-
const configValue = pageConfig.configValues[configName];
|
|
45
|
-
if (configValue)
|
|
46
|
-
return;
|
|
47
|
-
const configValueSource = sources[0];
|
|
48
|
-
assert(configValueSource);
|
|
49
|
-
if (!configValueSource.configEnv.eager)
|
|
50
|
-
return;
|
|
51
|
-
if (!isRuntimeEnvMatch(configValueSource.configEnv, { isForClientSide, isClientRouting, isEager: true }))
|
|
52
|
-
return;
|
|
53
|
-
lines.push(...serializeConfigValueImported(configValueSource, configName, whitespace, importStatements));
|
|
54
|
-
});
|
|
55
|
-
lines.push(`${whitespace}],`);
|
|
56
37
|
lines.push(` },`);
|
|
57
38
|
});
|
|
58
39
|
const code = lines.join('\n');
|
|
59
40
|
return code;
|
|
60
41
|
}
|
|
61
|
-
function getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, isDev, importStatements) {
|
|
42
|
+
function getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, isClientRouting, isDev, importStatements) {
|
|
62
43
|
const lines = [];
|
|
63
|
-
|
|
64
|
-
lines.push(
|
|
65
|
-
lines.push(` },`)
|
|
66
|
-
*/
|
|
67
|
-
lines.push(` configValuesImported: [`);
|
|
68
|
-
objectEntries(pageConfigGlobal.configValueSources).forEach(([configName, sources]) => {
|
|
69
|
-
if (configName === 'onBeforeRoute') {
|
|
70
|
-
// if( isForClientSide && !isClientRouting ) return
|
|
71
|
-
}
|
|
72
|
-
else if (configName === 'onPrerenderStart') {
|
|
73
|
-
if (isDev || isForClientSide) {
|
|
74
|
-
// Only load onPrerenderStart() in server production runtime
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
assert(false);
|
|
80
|
-
}
|
|
81
|
-
const configValueSource = sources[0];
|
|
82
|
-
assert(configValueSource);
|
|
83
|
-
const whitespace = ' ';
|
|
84
|
-
lines.push(...serializeConfigValueImported(configValueSource, configName, whitespace, importStatements));
|
|
85
|
-
});
|
|
86
|
-
lines.push(` ],`);
|
|
44
|
+
lines.push(` configValuesSerialized: {`);
|
|
45
|
+
lines.push(...serializeConfigValues(pageConfigGlobal, importStatements, (configEnv) => isRuntimeEnvMatch(configEnv, { isForClientSide, isClientRouting, isEager: true, isDev }), ' '));
|
|
46
|
+
lines.push(` },`);
|
|
87
47
|
const code = lines.join('\n');
|
|
88
48
|
return code;
|
|
89
49
|
}
|
|
@@ -14,5 +14,11 @@ function isRuntimeEnvMatch(configEnv, runtime) {
|
|
|
14
14
|
// Eager
|
|
15
15
|
if (runtime.isEager !== !!configEnv.eager)
|
|
16
16
|
return false;
|
|
17
|
+
// Production/development
|
|
18
|
+
if (
|
|
19
|
+
//
|
|
20
|
+
(configEnv.production === true && runtime.isDev) ||
|
|
21
|
+
(configEnv.production === false && !runtime.isDev))
|
|
22
|
+
return false;
|
|
17
23
|
return true;
|
|
18
24
|
}
|
|
@@ -16,7 +16,7 @@ import { getPageFilesServerSide } from '../../shared/getPageFiles.js';
|
|
|
16
16
|
import { getPageContextRequestUrl } from '../../shared/getPageContextRequestUrl.js';
|
|
17
17
|
import { getUrlFromRouteString } from '../../shared/route/resolveRouteString.js';
|
|
18
18
|
import { getConfigValueFilePathToShowToUser } from '../../shared/page-configs/helpers.js';
|
|
19
|
-
import {
|
|
19
|
+
import { getConfigValueRuntime } from '../../shared/page-configs/getConfigValue.js';
|
|
20
20
|
import { loadConfigValues } from '../../shared/page-configs/loadConfigValues.js';
|
|
21
21
|
import { isErrorPage } from '../../shared/error-page.js';
|
|
22
22
|
import { getPageContextUrlComputed } from '../../shared/getPageContextUrlComputed.js';
|
|
@@ -27,6 +27,7 @@ import { noRouteMatch } from '../../shared/route/noRouteMatch.js';
|
|
|
27
27
|
import { getVikeConfig } from '../plugin/plugins/importUserCode/v1-design/getVikeConfig.js';
|
|
28
28
|
import { logErrorHint } from '../runtime/renderPage/logErrorHint.js';
|
|
29
29
|
import { executeHook, isUserHookError } from '../../shared/hooks/executeHook.js';
|
|
30
|
+
import { getConfigValueBuildTime } from '../../shared/page-configs/getConfigValueBuildTime.js';
|
|
30
31
|
async function runPrerenderFromAPI(options = {}) {
|
|
31
32
|
await runPrerender(options, 'prerender()');
|
|
32
33
|
// - We purposely propagate the error to the user land, so that the error interrupts the user land. It's also, I guess, a nice-to-have that the user has control over the error.
|
|
@@ -114,7 +115,7 @@ async function collectDoNoPrerenderList(renderContext, pageConfigs, doNotPrerend
|
|
|
114
115
|
// V1 design
|
|
115
116
|
pageConfigs.forEach((pageConfig) => {
|
|
116
117
|
const configName = 'prerender';
|
|
117
|
-
const configValue =
|
|
118
|
+
const configValue = getConfigValueBuildTime(pageConfig, configName, 'boolean');
|
|
118
119
|
if (configValue?.value === false) {
|
|
119
120
|
const configValueFilePathToShowToUser = getConfigValueFilePathToShowToUser(configValue.definedAtData);
|
|
120
121
|
assert(configValueFilePathToShowToUser);
|
|
@@ -473,7 +474,7 @@ async function routeAndPrerender(prerenderContext, concurrencyLimit, onComplete)
|
|
|
473
474
|
if (pageContext._pageConfigs.length > 0) {
|
|
474
475
|
const pageConfig = pageContext._pageConfigs.find((p) => p.pageId === pageId);
|
|
475
476
|
assert(pageConfig);
|
|
476
|
-
usesClientRouter =
|
|
477
|
+
usesClientRouter = getConfigValueRuntime(pageConfig, 'clientRouting', 'boolean')?.value ?? false;
|
|
477
478
|
}
|
|
478
479
|
else {
|
|
479
480
|
usesClientRouter = globalContext.pluginManifest.usesClientRouter;
|
|
@@ -107,7 +107,7 @@ async function getHtmlTags(pageContext, injectToStream, injectFilter) {
|
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
// The JavaScript entry <script> tag
|
|
110
|
-
const scriptEntry = await mergeScriptEntries(pageAssets
|
|
110
|
+
const scriptEntry = await mergeScriptEntries(pageAssets);
|
|
111
111
|
if (scriptEntry) {
|
|
112
112
|
htmlTags.push({
|
|
113
113
|
htmlTag: scriptEntry,
|
|
@@ -128,11 +128,11 @@ async function getHtmlTags(pageContext, injectToStream, injectFilter) {
|
|
|
128
128
|
});
|
|
129
129
|
return htmlTags;
|
|
130
130
|
}
|
|
131
|
-
async function mergeScriptEntries(pageAssets
|
|
131
|
+
async function mergeScriptEntries(pageAssets) {
|
|
132
132
|
const scriptEntries = pageAssets.filter((pageAsset) => pageAsset.isEntry && pageAsset.assetType === 'script');
|
|
133
133
|
const viteScripts = await getViteDevScripts();
|
|
134
134
|
const scriptTagsHtml = `${viteScripts}${scriptEntries.map((asset) => inferAssetTag(asset)).join('')}`;
|
|
135
|
-
const scriptTag = mergeScriptTags(scriptTagsHtml
|
|
135
|
+
const scriptTag = mergeScriptTags(scriptTagsHtml);
|
|
136
136
|
return scriptTag;
|
|
137
137
|
}
|
|
138
138
|
function getPageContextJsonScriptTag(pageContext) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { getViteDevScripts };
|
|
2
2
|
import { getGlobalContext } from '../../globalContext.js';
|
|
3
|
-
import { assert, assertUsage } from '../../utils.js';
|
|
3
|
+
import { assert, assertUsage, assertWarning } from '../../utils.js';
|
|
4
4
|
import pc from '@brillout/picocolors';
|
|
5
5
|
async function getViteDevScripts() {
|
|
6
6
|
const globalContext = getGlobalContext();
|
|
@@ -16,7 +16,8 @@ async function getViteDevScripts() {
|
|
|
16
16
|
assertUsage(!fakeHtml.startsWith(fakeHtmlBegin.replace(' ', '')), 'Vite plugins that minify the HTML are not supported by vike, see https://github.com/vikejs/vike/issues/224');
|
|
17
17
|
assertUsage(fakeHtml.startsWith(fakeHtmlBegin) && fakeHtml.endsWith(fakeHtmlEnd), 'You are using a Vite Plugin that transforms the HTML in a way that conflicts with vike. Create a new GitHub ticket to discuss a solution.');
|
|
18
18
|
const viteInjection = fakeHtml.slice(fakeHtmlBegin.length, -1 * fakeHtmlEnd.length);
|
|
19
|
-
assert(viteInjection.includes('script')
|
|
19
|
+
assert(viteInjection.includes('script'));
|
|
20
|
+
assertWarning(!viteInjection.includes('import('), 'Unexpected Vite HMR code. Reach out to a Vike maintainer on GitHub.', { onlyOnce: true });
|
|
20
21
|
const scriptTags = viteInjection;
|
|
21
22
|
return scriptTags;
|
|
22
23
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { mergeScriptTags };
|
|
2
|
-
declare function mergeScriptTags(scriptTagsHtml: string
|
|
2
|
+
declare function mergeScriptTags(scriptTagsHtml: string): string;
|
|
@@ -4,7 +4,7 @@ import { scriptAttrs } from './inferHtmlTags.js';
|
|
|
4
4
|
const scriptRE = /(<script\b(?:\s[^>]*>|>))(.*?)<\/script>/gims;
|
|
5
5
|
const srcRE = /\bsrc\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/im;
|
|
6
6
|
const typeRE = /\btype\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/im;
|
|
7
|
-
function mergeScriptTags(scriptTagsHtml
|
|
7
|
+
function mergeScriptTags(scriptTagsHtml) {
|
|
8
8
|
let scriptTag = '';
|
|
9
9
|
const scripts = parseScripts(scriptTagsHtml);
|
|
10
10
|
// We need to merge module scripts to ensure execution order
|
|
@@ -19,13 +19,7 @@ function mergeScriptTags(scriptTagsHtml, isProduction) {
|
|
|
19
19
|
const hasInnerHtml = !!innerHtml.trim();
|
|
20
20
|
if (src) {
|
|
21
21
|
assert(!hasInnerHtml);
|
|
22
|
-
|
|
23
|
-
contents.push(`import ${JSON.stringify(src)};`);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
// Ensure HMR preamble code is executed before client entries
|
|
27
|
-
contents.push(`import(${JSON.stringify(src)});`);
|
|
28
|
-
}
|
|
22
|
+
contents.push(`import ${JSON.stringify(src)};`);
|
|
29
23
|
}
|
|
30
24
|
else if (hasInnerHtml) {
|
|
31
25
|
innerHtml = innerHtml.split('\n').filter(Boolean).join('\n');
|
|
@@ -4,12 +4,16 @@ import { analyzePageClientSide } from '../../../shared/getPageFiles/analyzePageC
|
|
|
4
4
|
import { getVirtualFileIdPageConfigValuesAll } from '../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
|
|
5
5
|
import { analyzeClientSide } from '../../../shared/getPageFiles/analyzeClientSide.js';
|
|
6
6
|
import { getGlobalContext } from '../globalContext.js';
|
|
7
|
-
import {
|
|
7
|
+
import { getConfigValueRuntime } from '../../../shared/page-configs/getConfigValue.js';
|
|
8
8
|
function analyzePage(pageFilesAll, pageConfig, pageId) {
|
|
9
9
|
if (pageConfig) {
|
|
10
10
|
const { isClientSideRenderable, isClientRouting } = analyzeClientSide(pageConfig, pageFilesAll, pageId);
|
|
11
|
-
const
|
|
12
|
-
const
|
|
11
|
+
const clientEntries = [];
|
|
12
|
+
const clientFilePath = getConfigValueRuntime(pageConfig, 'client', 'string')?.value ?? null;
|
|
13
|
+
if (clientFilePath)
|
|
14
|
+
clientEntries.push(clientFilePath);
|
|
15
|
+
if (isClientSideRenderable)
|
|
16
|
+
clientEntries.push(getVikeClientEntry(isClientRouting));
|
|
13
17
|
const clientDependencies = [];
|
|
14
18
|
clientDependencies.push({
|
|
15
19
|
id: getVirtualFileIdPageConfigValuesAll(pageConfig.pageId, true),
|
|
@@ -41,15 +45,13 @@ function analyzePage(pageFilesAll, pageConfig, pageId) {
|
|
|
41
45
|
}
|
|
42
46
|
})
|
|
43
47
|
*/
|
|
44
|
-
|
|
45
|
-
if (clientEntry) {
|
|
48
|
+
clientEntries.forEach((clientEntry) => {
|
|
46
49
|
clientDependencies.push({
|
|
47
50
|
id: clientEntry,
|
|
48
51
|
onlyAssets: false,
|
|
49
52
|
eagerlyImported: false
|
|
50
53
|
});
|
|
51
|
-
|
|
52
|
-
}
|
|
54
|
+
});
|
|
53
55
|
return {
|
|
54
56
|
isHtmlOnly: !isClientSideRenderable,
|
|
55
57
|
isClientRouting,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export { getCacheControl };
|
|
2
2
|
import { getPageConfig } from '../../../../shared/page-configs/helpers.js';
|
|
3
|
-
import {
|
|
3
|
+
import { getConfigValueRuntime } from '../../../../shared/page-configs/getConfigValue.js';
|
|
4
4
|
const defaultValue = 'no-store, max-age=0';
|
|
5
5
|
function getCacheControl(pageId, pageConfigs) {
|
|
6
6
|
// TODO/v1-release: remove
|
|
7
7
|
if (pageConfigs.length === 0)
|
|
8
8
|
return defaultValue;
|
|
9
9
|
const pageConfig = getPageConfig(pageId, pageConfigs);
|
|
10
|
-
const configValue =
|
|
10
|
+
const configValue = getConfigValueRuntime(pageConfig, 'cacheControl', 'string');
|
|
11
11
|
const value = configValue?.value;
|
|
12
12
|
if (value)
|
|
13
13
|
return value;
|
|
@@ -14,7 +14,7 @@ type PageContext_loadUserFilesServerSide = PageContextGetPageAssets & PageContex
|
|
|
14
14
|
type PageFiles = PromiseType<ReturnType<typeof loadUserFilesServerSide>>;
|
|
15
15
|
declare function loadUserFilesServerSide(pageContext: {
|
|
16
16
|
_pageId: string;
|
|
17
|
-
} & PageContext_loadUserFilesServerSide): Promise<import("../../../shared/getPageFiles
|
|
17
|
+
} & PageContext_loadUserFilesServerSide): Promise<import("../../../shared/getPageFiles.js").PageContextExports & {
|
|
18
18
|
Page: unknown;
|
|
19
19
|
_isHtmlOnly: boolean;
|
|
20
20
|
_passToClient: string[];
|
|
@@ -65,7 +65,7 @@ declare function prerenderPage(pageContext: PageContextInitEnhanced & PageFiles
|
|
|
65
65
|
url: string;
|
|
66
66
|
} & {
|
|
67
67
|
headers: Record<string, string> | null;
|
|
68
|
-
} & import("../../../shared/getPageFiles
|
|
68
|
+
} & import("../../../shared/getPageFiles.js").PageContextExports & {
|
|
69
69
|
Page: unknown;
|
|
70
70
|
_isHtmlOnly: boolean;
|
|
71
71
|
_passToClient: string[];
|
|
@@ -116,7 +116,7 @@ declare function prerenderPage(pageContext: PageContextInitEnhanced & PageFiles
|
|
|
116
116
|
url: string;
|
|
117
117
|
} & {
|
|
118
118
|
headers: Record<string, string> | null;
|
|
119
|
-
} & import("../../../shared/getPageFiles
|
|
119
|
+
} & import("../../../shared/getPageFiles.js").PageContextExports & {
|
|
120
120
|
Page: unknown;
|
|
121
121
|
_isHtmlOnly: boolean;
|
|
122
122
|
_passToClient: string[];
|
|
@@ -168,7 +168,7 @@ declare function prerender404Page(renderContext: RenderContext, pageContextInit_
|
|
|
168
168
|
url: string;
|
|
169
169
|
} & {
|
|
170
170
|
headers: Record<string, string> | null;
|
|
171
|
-
} & import("../../../shared/getPageFiles
|
|
171
|
+
} & import("../../../shared/getPageFiles.js").PageContextExports & {
|
|
172
172
|
Page: unknown;
|
|
173
173
|
_isHtmlOnly: boolean;
|
|
174
174
|
_passToClient: string[];
|
|
@@ -219,7 +219,7 @@ declare function prerender404Page(renderContext: RenderContext, pageContextInit_
|
|
|
219
219
|
url: string;
|
|
220
220
|
} & {
|
|
221
221
|
headers: Record<string, string> | null;
|
|
222
|
-
} & import("../../../shared/getPageFiles
|
|
222
|
+
} & import("../../../shared/getPageFiles.js").PageContextExports & {
|
|
223
223
|
Page: unknown;
|
|
224
224
|
_isHtmlOnly: boolean;
|
|
225
225
|
_passToClient: string[];
|
|
@@ -21,7 +21,6 @@ import { executeGuardHook } from '../../../shared/route/executeGuardHook.js';
|
|
|
21
21
|
import { loadPageRoutes } from '../../../shared/route/loadPageRoutes.js';
|
|
22
22
|
import pc from '@brillout/picocolors';
|
|
23
23
|
import { isServerSideError } from '../../../shared/misc/isServerSideError.js';
|
|
24
|
-
import { assertV1Design } from '../../shared/assertV1Design.js';
|
|
25
24
|
async function renderPageAlreadyRouted(pageContext) {
|
|
26
25
|
// pageContext._pageId can either be the:
|
|
27
26
|
// - ID of the page matching the routing, or the
|
|
@@ -171,7 +170,8 @@ async function getRenderContext() {
|
|
|
171
170
|
const globalContext = getGlobalContext();
|
|
172
171
|
const { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal } = await getPageFilesAll(false, globalContext.isProduction);
|
|
173
172
|
const { pageRoutes, onBeforeRouteHook } = await loadPageRoutes(pageFilesAll, pageConfigs, pageConfigGlobal, allPageIds);
|
|
174
|
-
assertV1Design(
|
|
173
|
+
// We assume assertV1Design() was already called at build-time
|
|
174
|
+
assert(pageFilesAll.length === 0 || pageConfigs.length === 0);
|
|
175
175
|
const renderContext = {
|
|
176
176
|
pageFilesAll: pageFilesAll,
|
|
177
177
|
pageConfigs,
|