vike 0.4.220-commit-a9f46b8 → 0.4.220-commit-5c7810f

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.
Files changed (110) hide show
  1. package/dist/cjs/node/api/utils.js +1 -1
  2. package/dist/cjs/{utils → node/plugin}/getOutDirs.js +11 -11
  3. package/dist/cjs/node/plugin/index.js +1 -7
  4. package/dist/cjs/node/plugin/onLoad.js +6 -1
  5. package/dist/cjs/node/plugin/plugins/autoFullBuild.js +12 -13
  6. package/dist/cjs/node/plugin/plugins/baseUrls.js +2 -2
  7. package/dist/cjs/node/plugin/plugins/buildConfig.js +6 -3
  8. package/dist/cjs/node/plugin/plugins/buildEntry/index.js +24 -21
  9. package/dist/cjs/node/plugin/plugins/commonConfig.js +4 -3
  10. package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +4 -2
  11. package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +10 -7
  12. package/dist/cjs/node/plugin/plugins/importUserCode/index.js +3 -4
  13. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/assertExtensions.js +18 -13
  14. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +8 -3
  15. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +29 -3
  16. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +216 -233
  17. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +3 -1
  18. package/dist/cjs/node/plugin/plugins/previewConfig.js +3 -4
  19. package/dist/cjs/node/plugin/utils.js +1 -1
  20. package/dist/cjs/node/prerender/context.js +6 -4
  21. package/dist/cjs/node/prerender/resolvePrerenderConfig.js +25 -0
  22. package/dist/cjs/node/prerender/runPrerender.js +9 -4
  23. package/dist/cjs/node/prerender/utils.js +2 -2
  24. package/dist/cjs/node/runtime/globalContext.js +42 -36
  25. package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +6 -3
  26. package/dist/cjs/node/runtime/renderPage/resolveRedirects.js +6 -5
  27. package/dist/cjs/node/runtime/renderPage.js +10 -5
  28. package/dist/cjs/node/runtime/utils.js +2 -2
  29. package/dist/cjs/node/shared/resolveBase.js +9 -0
  30. package/dist/cjs/shared/getPageContextUrlComputed.js +6 -1
  31. package/dist/cjs/shared/page-configs/getPageConfigUserFriendly.js +2 -2
  32. package/dist/cjs/shared/utils.js +1 -1
  33. package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
  34. package/dist/cjs/utils/findFile.js +3 -3
  35. package/dist/cjs/utils/isDev.js +3 -2
  36. package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +2 -2
  37. package/dist/cjs/utils/requireResolve.js +3 -3
  38. package/dist/esm/node/api/utils.d.ts +1 -1
  39. package/dist/esm/node/api/utils.js +1 -1
  40. package/dist/esm/{utils → node/plugin}/getOutDirs.js +5 -5
  41. package/dist/esm/node/plugin/index.d.ts +29 -1
  42. package/dist/esm/node/plugin/index.js +2 -8
  43. package/dist/esm/node/plugin/onLoad.js +7 -2
  44. package/dist/esm/node/plugin/plugins/autoFullBuild.js +12 -13
  45. package/dist/esm/node/plugin/plugins/baseUrls.js +2 -2
  46. package/dist/esm/node/plugin/plugins/buildConfig.js +7 -4
  47. package/dist/esm/node/plugin/plugins/buildEntry/index.d.ts +3 -3
  48. package/dist/esm/node/plugin/plugins/buildEntry/index.js +25 -22
  49. package/dist/esm/node/plugin/plugins/commonConfig.d.ts +1 -1
  50. package/dist/esm/node/plugin/plugins/commonConfig.js +4 -3
  51. package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +4 -2
  52. package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.d.ts +2 -2
  53. package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +10 -7
  54. package/dist/esm/node/plugin/plugins/importUserCode/index.js +3 -4
  55. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/assertExtensions.d.ts +3 -2
  56. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/assertExtensions.js +19 -14
  57. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +8 -3
  58. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.d.ts +5 -2
  59. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +30 -4
  60. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +23 -101
  61. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +219 -236
  62. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +3 -1
  63. package/dist/esm/node/plugin/plugins/previewConfig.js +3 -4
  64. package/dist/esm/node/plugin/utils.js +1 -1
  65. package/dist/esm/node/prerender/context.d.ts +2 -2
  66. package/dist/esm/node/prerender/context.js +6 -4
  67. package/dist/esm/node/prerender/resolvePrerenderConfig.d.ts +5 -0
  68. package/dist/esm/node/prerender/resolvePrerenderConfig.js +23 -0
  69. package/dist/esm/node/prerender/runPrerender.js +9 -4
  70. package/dist/esm/node/prerender/utils.d.ts +2 -2
  71. package/dist/esm/node/prerender/utils.js +2 -2
  72. package/dist/esm/node/runtime/globalContext.d.ts +15 -9
  73. package/dist/esm/node/runtime/globalContext.js +43 -37
  74. package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +5 -5
  75. package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +6 -3
  76. package/dist/esm/node/runtime/renderPage/resolveRedirects.d.ts +2 -0
  77. package/dist/esm/node/runtime/renderPage/resolveRedirects.js +5 -5
  78. package/dist/esm/node/runtime/renderPage.js +10 -5
  79. package/dist/esm/node/runtime/utils.d.ts +2 -2
  80. package/dist/esm/node/runtime/utils.js +2 -2
  81. package/dist/esm/node/shared/resolveBase.d.ts +4 -1
  82. package/dist/esm/node/shared/resolveBase.js +9 -0
  83. package/dist/esm/shared/getPageContextUrlComputed.js +6 -1
  84. package/dist/esm/shared/page-configs/Config.d.ts +76 -3
  85. package/dist/esm/shared/page-configs/PageConfig.d.ts +25 -19
  86. package/dist/esm/shared/page-configs/getPageConfigUserFriendly.d.ts +1 -1
  87. package/dist/esm/shared/page-configs/getPageConfigUserFriendly.js +2 -2
  88. package/dist/esm/shared/utils.d.ts +1 -1
  89. package/dist/esm/shared/utils.js +1 -1
  90. package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
  91. package/dist/esm/utils/PROJECT_VERSION.js +1 -1
  92. package/dist/esm/utils/findFile.js +1 -1
  93. package/dist/esm/utils/isDev.js +3 -2
  94. package/dist/esm/utils/isFilePathAbsoluteFilesystem.js +1 -1
  95. package/dist/esm/utils/projectInfo.d.ts +1 -1
  96. package/dist/esm/utils/requireResolve.js +1 -1
  97. package/package.json +1 -1
  98. package/dist/cjs/node/plugin/plugins/buildEntry/getVikeManifest.js +0 -17
  99. package/dist/cjs/node/shared/assertPluginManifest.js +0 -20
  100. package/dist/cjs/node/shared/assertRuntimeManifest.js +0 -16
  101. package/dist/esm/node/plugin/plugins/buildEntry/getVikeManifest.d.ts +0 -5
  102. package/dist/esm/node/plugin/plugins/buildEntry/getVikeManifest.js +0 -15
  103. package/dist/esm/node/shared/assertPluginManifest.d.ts +0 -12
  104. package/dist/esm/node/shared/assertPluginManifest.js +0 -18
  105. package/dist/esm/node/shared/assertRuntimeManifest.d.ts +0 -10
  106. package/dist/esm/node/shared/assertRuntimeManifest.js +0 -14
  107. /package/dist/cjs/utils/{filesystemPathHandling.js → toPosixPath.js} +0 -0
  108. /package/dist/esm/{utils → node/plugin}/getOutDirs.d.ts +0 -0
  109. /package/dist/esm/utils/{filesystemPathHandling.d.ts → toPosixPath.d.ts} +0 -0
  110. /package/dist/esm/utils/{filesystemPathHandling.js → toPosixPath.js} +0 -0
@@ -9,7 +9,9 @@ exports.getVikeConfig2 = getVikeConfig2;
9
9
  exports.reloadVikeConfig = reloadVikeConfig;
10
10
  exports.isVikeConfigFile = isVikeConfigFile;
11
11
  exports.isV1Design = isV1Design;
12
- exports.getConfigValueInterfaceFile = getConfigValueInterfaceFile;
12
+ exports.getConfVal = getConfVal;
13
+ exports.getConfigDefinitionOptional = getConfigDefinitionOptional;
14
+ exports.shouldBeLoadableAtBuildTime = shouldBeLoadableAtBuildTime;
13
15
  const utils_js_1 = require("../../../utils.js");
14
16
  const path_1 = __importDefault(require("path"));
15
17
  const configDefinitionsBuiltIn_js_1 = require("./getVikeConfig/configDefinitionsBuiltIn.js");
@@ -114,7 +116,7 @@ async function loadInterfaceFiles(userRootDir) {
114
116
  valueFiles.push(f);
115
117
  }
116
118
  });
117
- let interfaceFilesByLocationId = {};
119
+ let interfaceFilesAll = {};
118
120
  await Promise.all([
119
121
  // Config files
120
122
  ...configFiles.map(async (filePath) => {
@@ -124,8 +126,8 @@ async function loadInterfaceFiles(userRootDir) {
124
126
  (0, utils_js_1.assert)(filePath.filePathAbsoluteUserRootDir);
125
127
  const locationId = (0, filesystemRouting_js_1.getLocationId)(filePathAbsoluteUserRootDir);
126
128
  const interfaceFile = getInterfaceFileFromConfigFile(configFile, false, locationId);
127
- interfaceFilesByLocationId[locationId] = interfaceFilesByLocationId[locationId] ?? [];
128
- interfaceFilesByLocationId[locationId].push(interfaceFile);
129
+ interfaceFilesAll[locationId] = interfaceFilesAll[locationId] ?? [];
130
+ interfaceFilesAll[locationId].push(interfaceFile);
129
131
  extendsConfigs.forEach((extendsConfig) => {
130
132
  /* We purposely use the same locationId because the Vike extension's config should only apply to where it's being extended from, for example:
131
133
  ```js
@@ -145,7 +147,7 @@ async function loadInterfaceFiles(userRootDir) {
145
147
  */
146
148
  const interfaceFile = getInterfaceFileFromConfigFile(extendsConfig, true, locationId);
147
149
  (0, assertExtensions_js_1.assertExtensionsConventions)(interfaceFile);
148
- interfaceFilesByLocationId[locationId].push(interfaceFile);
150
+ interfaceFilesAll[locationId].push(interfaceFile);
149
151
  });
150
152
  }),
151
153
  // Value files
@@ -158,30 +160,21 @@ async function loadInterfaceFiles(userRootDir) {
158
160
  const interfaceFile = {
159
161
  locationId,
160
162
  filePath,
161
- fileExportsByConfigName: {
162
- [configName]: {}
163
- },
164
163
  isConfigFile: false,
165
164
  isValueFile: true,
165
+ isValueLoaded: false,
166
166
  configName
167
167
  };
168
- {
169
- // We don't have access to the custom config definitions defined by the user yet.
170
- // - If `configDef` is `undefined` => we load the file +{configName}.js later.
171
- // - We already need to load +meta.js here (to get the custom config definitions defined by the user)
172
- const configDef = getConfigDefinitionOptional(configDefinitionsBuiltIn, configName);
173
- if (configDef && isLoadableAtBuildTime(configDef)) {
174
- await (0, loadFileAtConfigTime_js_1.loadValueFile)(interfaceFile, configName, userRootDir);
175
- }
176
- }
177
- {
178
- interfaceFilesByLocationId[locationId] = interfaceFilesByLocationId[locationId] ?? [];
179
- interfaceFilesByLocationId[locationId].push(interfaceFile);
180
- }
168
+ interfaceFilesAll[locationId] = interfaceFilesAll[locationId] ?? [];
169
+ interfaceFilesAll[locationId].push(interfaceFile);
170
+ // We don't have access to the custom config definitions defined by the user yet.
171
+ // - If `configDef` is `undefined` => we load the file +{configName}.js later.
172
+ // - We already need to load +meta.js here (to get the custom config definitions defined by the user)
173
+ await (0, loadFileAtConfigTime_js_1.loadValueFile)(interfaceFile, configDefinitionsBuiltIn, userRootDir);
181
174
  })
182
175
  ]);
183
- assertAllConfigsAreKnown(interfaceFilesByLocationId);
184
- return interfaceFilesByLocationId;
176
+ assertAllConfigsAreKnown(interfaceFilesAll);
177
+ return interfaceFilesAll;
185
178
  }
186
179
  function getInterfaceFileFromConfigFile(configFile, isConfigExtend, locationId) {
187
180
  const { fileExports, filePath, extendsFilePaths } = configFile;
@@ -191,23 +184,27 @@ function getInterfaceFileFromConfigFile(configFile, isConfigExtend, locationId)
191
184
  fileExportsByConfigName: {},
192
185
  isConfigFile: true,
193
186
  isValueFile: false,
187
+ isValueLoaded: true,
194
188
  isConfigExtend,
195
189
  extendsFilePaths
196
190
  };
197
191
  const fileExport = (0, getConfigFileExport_js_1.getConfigFileExport)(fileExports, filePath.filePathToShowToUser);
198
192
  Object.entries(fileExport).forEach(([configName, configValue]) => {
199
- interfaceFile.fileExportsByConfigName[configName] = { configValue };
193
+ interfaceFile.fileExportsByConfigName[configName] = configValue;
200
194
  });
201
195
  return interfaceFile;
202
196
  }
203
197
  /** Show error message upon unknown config */
204
- function assertAllConfigsAreKnown(interfaceFilesByLocationId) {
205
- (0, utils_js_1.objectEntries)(interfaceFilesByLocationId).forEach(([locationId, interfaceFiles]) => {
206
- const interfaceFilesRelevant = getInterfaceFilesRelevant(interfaceFilesByLocationId, locationId);
198
+ function assertAllConfigsAreKnown(interfaceFilesAll) {
199
+ (0, utils_js_1.objectEntries)(interfaceFilesAll).forEach(([locationId, interfaceFiles]) => {
200
+ const interfaceFilesRelevant = getInterfaceFilesRelevant(interfaceFilesAll, locationId);
207
201
  const configDefinitions = getConfigDefinitions(interfaceFilesRelevant);
208
202
  interfaceFiles.forEach((interfaceFile) => {
209
- Object.keys(interfaceFile.fileExportsByConfigName).forEach((configName) => {
210
- assertConfigExists(configName, Object.keys(configDefinitions), interfaceFile.filePath.filePathToShowToUser);
203
+ const configNamesKnown = Object.keys(configDefinitions);
204
+ const { filePathToShowToUser } = interfaceFile.filePath;
205
+ const configNames = getDefiningConfigNames(interfaceFile);
206
+ configNames.forEach((configName) => {
207
+ assertConfigExists(configName, configNamesKnown, filePathToShowToUser);
211
208
  });
212
209
  });
213
210
  });
@@ -246,9 +243,9 @@ async function loadVikeConfig_withErrorHandling(userRootDir, isDev, vikeVitePlug
246
243
  pageConfigs: [],
247
244
  pageConfigGlobal: {
248
245
  configDefinitions: {},
246
+ interfaceFiles: {},
249
247
  configValueSources: {}
250
248
  },
251
- vikeConfigGlobal: resolveVikeConfigGlobal({}, {}),
252
249
  global: (0, getPageConfigUserFriendly_js_1.getPageConfigUserFriendlyNew)({ configValues: {} })
253
250
  };
254
251
  return dummyData;
@@ -256,49 +253,86 @@ async function loadVikeConfig_withErrorHandling(userRootDir, isDev, vikeVitePlug
256
253
  }
257
254
  }
258
255
  async function loadVikeConfig(userRootDir, vikeVitePluginOptions) {
259
- const interfaceFilesByLocationId = await loadInterfaceFiles(userRootDir);
256
+ const interfaceFilesAll = await loadInterfaceFiles(userRootDir);
260
257
  const importedFilesLoaded = {};
261
- const [globalConfigs, pageConfigs] = await Promise.all([
262
- getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded, vikeVitePluginOptions),
263
- getPageConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded)
264
- ]);
265
- return { pageConfigs, ...globalConfigs };
258
+ const { pageConfigGlobal, pageConfigs } = await getPageConfigs(interfaceFilesAll, userRootDir, importedFilesLoaded);
259
+ // interop vike(options) in vite.config.js
260
+ temp_interopVikeVitePlugin(pageConfigGlobal, vikeVitePluginOptions, userRootDir);
261
+ // global
262
+ const configValues = getConfigValues(pageConfigGlobal);
263
+ const global = (0, getPageConfigUserFriendly_js_1.getPageConfigUserFriendlyNew)({ configValues });
264
+ return { pageConfigs, pageConfigGlobal, global };
266
265
  }
267
- async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded, vikeVitePluginOptions) {
268
- const locationIds = (0, utils_js_1.objectKeys)(interfaceFilesByLocationId);
269
- const interfaceFilesGlobal = (0, utils_js_1.objectFromEntries)((0, utils_js_1.objectEntries)(interfaceFilesByLocationId).filter(([locationId]) => {
270
- return (0, filesystemRouting_js_1.isGlobalLocation)(locationId, locationIds);
271
- }));
266
+ async function getGlobalConfigs(interfaceFilesAll, userRootDir, importedFilesLoaded) {
267
+ /* TODO/now: dedupe
272
268
  // Validate that global configs live in global interface files
273
269
  {
274
- const interfaceFilesGlobalPaths = [];
275
- (0, utils_js_1.objectEntries)(interfaceFilesGlobal).forEach(([locationId, interfaceFiles]) => {
276
- (0, utils_js_1.assert)((0, filesystemRouting_js_1.isGlobalLocation)(locationId, locationIds));
277
- interfaceFiles.forEach(({ filePath: { filePathAbsoluteUserRootDir } }) => {
278
- if (filePathAbsoluteUserRootDir) {
279
- interfaceFilesGlobalPaths.push(filePathAbsoluteUserRootDir);
280
- }
281
- });
282
- });
283
- const globalPaths = Array.from(new Set(interfaceFilesGlobalPaths.map((p) => path_1.default.posix.dirname(p))));
284
- (0, utils_js_1.objectEntries)(interfaceFilesByLocationId).forEach(([locationId, interfaceFiles]) => {
285
- interfaceFiles.forEach((interfaceFile) => {
286
- Object.keys(interfaceFile.fileExportsByConfigName).forEach((configName) => {
287
- if (!(0, filesystemRouting_js_1.isGlobalLocation)(locationId, locationIds) && isGlobalConfig(configName)) {
288
- (0, utils_js_1.assertUsage)(false, [
289
- `${interfaceFile.filePath.filePathToShowToUser} defines the config ${picocolors_1.default.cyan(configName)} which is global:`,
290
- globalPaths.length
291
- ? `define ${picocolors_1.default.cyan(configName)} in ${(0, utils_js_1.joinEnglish)(globalPaths, 'or')} instead`
292
- : `create a global config (e.g. /pages/+config.js) and define ${picocolors_1.default.cyan(configName)} there instead`
293
- ].join(' '));
294
- }
295
- });
296
- });
297
- });
270
+ const interfaceFilesGlobalPaths: string[] = []
271
+ objectEntries(interfaceFilesGlobal).forEach(([locationId, interfaceFiles]) => {
272
+ assert(isGlobalLocation(locationId, locationIds))
273
+ interfaceFiles.forEach(({ filePath: { filePathAbsoluteUserRootDir } }) => {
274
+ if (filePathAbsoluteUserRootDir) {
275
+ interfaceFilesGlobalPaths.push(filePathAbsoluteUserRootDir)
276
+ }
277
+ })
278
+ })
279
+ const globalPaths = Array.from(new Set(interfaceFilesGlobalPaths.map((p) => path.posix.dirname(p))))
280
+ objectEntries(interfaceFilesAll).forEach(([locationId, interfaceFiles]) => {
281
+ interfaceFiles.forEach((interfaceFile) => {
282
+ Object.keys(interfaceFile.fileExportsByConfigName).forEach((configName) => {
283
+ if (!isGlobalLocation(locationId, locationIds) && isGlobalConfigOld(configName)) {
284
+ assertUsage(
285
+ false,
286
+ [
287
+ `${interfaceFile.filePath.filePathToShowToUser} defines the config ${pc.cyan(
288
+ configName
289
+ )} which is global:`,
290
+ globalPaths.length
291
+ ? `define ${pc.cyan(configName)} in ${joinEnglish(globalPaths, 'or')} instead`
292
+ : `create a global config (e.g. /pages/+config.js) and define ${pc.cyan(configName)} there instead`
293
+ ].join(' ')
294
+ )
295
+ }
296
+ })
297
+ })
298
+ })
298
299
  }
299
- const pageConfigGlobalValues = {};
300
+ //*/
301
+ }
302
+ function temp_interopVikeVitePlugin(pageConfigGlobal, vikeVitePluginOptions, userRootDir) {
303
+ (0, utils_js_1.assert)((0, utils_js_1.isObject)(vikeVitePluginOptions));
304
+ (0, utils_js_1.assertWarning)(Object.keys(vikeVitePluginOptions).length === 0, `Define Vike settings in +config.js instead of vite.config.js ${picocolors_1.default.underline('https://vike.dev/migration/settings')}`, { onlyOnce: true });
305
+ Object.entries(vikeVitePluginOptions).forEach(([configName, value]) => {
306
+ var _a;
307
+ (0, utils_js_1.assert)((0, utils_js_1.includes)((0, utils_js_1.objectKeys)(configDefinitionsBuiltInGlobal), configName));
308
+ const configDef = configDefinitionsBuiltInGlobal[configName];
309
+ const sources = ((_a = pageConfigGlobal.configValueSources)[configName] ?? (_a[configName] = []));
310
+ sources.push({
311
+ value,
312
+ configEnv: configDef.env,
313
+ definedAtFilePath: {
314
+ ...(0, getFilePath_js_1.getFilePathResolved)({
315
+ userRootDir,
316
+ filePathAbsoluteUserRootDir: '/vite.config.js'
317
+ }),
318
+ fileExportPathToShowToUser: null
319
+ },
320
+ locationId: '/',
321
+ interfaceFile: null,
322
+ isOverriden: configDef.cumulative ? false : sources.length > 0,
323
+ valueIsImportedAtRuntime: false,
324
+ valueIsDefinedByPlusFile: false
325
+ });
326
+ });
327
+ }
328
+ async function getPageConfigs(interfaceFilesAll, userRootDir, importedFilesLoaded) {
329
+ const locationIds = (0, utils_js_1.objectKeys)(interfaceFilesAll);
330
+ const interfaceFilesGlobal = (0, utils_js_1.objectFromEntries)((0, utils_js_1.objectEntries)(interfaceFilesAll).filter(([locationId]) => {
331
+ return (0, filesystemRouting_js_1.isGlobalLocation)(locationId, locationIds);
332
+ }));
300
333
  const pageConfigGlobal = {
301
334
  configDefinitions: configDefinitionsBuiltInGlobal,
335
+ interfaceFiles: interfaceFilesGlobal,
302
336
  configValueSources: {}
303
337
  };
304
338
  await Promise.all((0, utils_js_1.objectEntries)(configDefinitionsBuiltInGlobal).map(async ([configName, configDef]) => {
@@ -307,75 +341,17 @@ async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importe
307
341
  if (!configValueSource)
308
342
  return;
309
343
  pageConfigGlobal.configValueSources[configName] = sources;
310
- // TODO/now
311
- if (configName === 'onBeforeRoute' || configName === 'onPrerenderStart') {
312
- (0, utils_js_1.assert)(!('value' in configValueSource));
313
- }
314
- else {
315
- (0, utils_js_1.assert)('value' in configValueSource);
316
- // TODO/now
317
- if (configName === 'prerender' && typeof configValueSource.value === 'boolean')
318
- return;
319
- pageConfigGlobalValues[configName] = configValueSource.value;
320
- }
321
344
  }));
322
- const vikeConfigGlobal = resolveVikeConfigGlobal(vikeVitePluginOptions, pageConfigGlobalValues);
323
- {
324
- (0, utils_js_1.assert)((0, utils_js_1.isObject)(vikeVitePluginOptions));
325
- Object.entries(vikeVitePluginOptions).forEach(([configName, value]) => {
326
- var _a;
327
- (0, utils_js_1.assert)((0, utils_js_1.includes)((0, utils_js_1.objectKeys)(configDefinitionsBuiltInGlobal), configName));
328
- const configDef = configDefinitionsBuiltInGlobal[configName];
329
- const sources = ((_a = pageConfigGlobal.configValueSources)[configName] ?? (_a[configName] = []));
330
- sources.push({
331
- value,
332
- configEnv: configDef.env,
333
- definedAtFilePath: {
334
- ...(0, getFilePath_js_1.getFilePathResolved)({
335
- userRootDir,
336
- filePathAbsoluteUserRootDir: '/vite.config.js'
337
- }),
338
- fileExportPathToShowToUser: null
339
- },
340
- locationId: '/',
341
- isOverriden: configDef.cumulative ? false : sources.length > 0,
342
- valueIsImportedAtRuntime: false,
343
- valueIsDefinedByPlusFile: false
344
- });
345
- });
346
- }
347
- const configValues = getConfigValues(pageConfigGlobal);
348
- const global = (0, getPageConfigUserFriendly_js_1.getPageConfigUserFriendlyNew)({ configValues });
349
- return { pageConfigGlobal, vikeConfigGlobal, global };
350
- }
351
- async function getPageConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded) {
352
- const pageConfigs = await Promise.all((0, utils_js_1.objectEntries)(interfaceFilesByLocationId)
353
- .filter(([_pageId, interfaceFiles]) => isDefiningPage(interfaceFiles))
354
- .map(async ([locationId]) => {
355
- const interfaceFilesRelevant = getInterfaceFilesRelevant(interfaceFilesByLocationId, locationId);
356
- const interfaceFilesRelevantList = Object.values(interfaceFilesRelevant).flat(1);
357
- (0, assertExtensions_js_1.assertExtensionsPeerDependencies)(interfaceFilesRelevantList);
345
+ const pageConfigs = [];
346
+ await Promise.all(getPageLocationIds(interfaceFilesAll).map(async (locationId) => {
347
+ const interfaceFilesRelevant = getInterfaceFilesRelevant(interfaceFilesAll, locationId);
358
348
  const configDefinitions = getConfigDefinitions(interfaceFilesRelevant);
359
- // Load value files of custom config-only configs
360
- await Promise.all(interfaceFilesRelevantList.map(async (interfaceFile) => {
361
- if (!interfaceFile.isValueFile)
362
- return;
363
- const { configName } = interfaceFile;
364
- if (isGlobalConfig(configName))
365
- return;
366
- const configDef = getConfigDefinition(configDefinitions, configName, interfaceFile.filePath.filePathToShowToUser);
367
- if (!isLoadableAtBuildTime(configDef))
368
- return;
369
- const isAlreadyLoaded = interfacefileIsAlreaydLoaded(interfaceFile);
370
- if (isAlreadyLoaded)
371
- return;
372
- // Value files of built-in configs should have already been loaded at loadInterfaceFiles()
373
- (0, utils_js_1.assert)(!(configName in configDefinitionsBuiltIn));
374
- await (0, loadFileAtConfigTime_js_1.loadValueFile)(interfaceFile, configName, userRootDir);
375
- }));
349
+ // Load value files (with `env.config===true`) of *custom* configs.
350
+ // - The value files of *built-in* configs are already loaded at `loadInterfaceFiles()`.
351
+ await (0, loadFileAtConfigTime_js_1.loadValueFiles)(interfaceFilesRelevant, configDefinitions, userRootDir);
376
352
  let configValueSources = {};
377
353
  await Promise.all((0, utils_js_1.objectEntries)(configDefinitions)
378
- .filter(([configName]) => !isGlobalConfig(configName))
354
+ .filter(([configName]) => !isGlobalConfigOld(configName))
379
355
  .map(async ([configName, configDef]) => {
380
356
  const sources = await resolveConfigValueSources(configName, configDef, interfaceFilesRelevant, userRootDir, importedFilesLoaded);
381
357
  if (sources.length === 0)
@@ -386,53 +362,43 @@ async function getPageConfigs(interfaceFilesByLocationId, userRootDir, importedF
386
362
  const { routeFilesystem, isErrorPage } = determineRouteFilesystem(locationId, configValueSources);
387
363
  applyEffectsAll(configValueSources, configDefinitions);
388
364
  const configValuesComputed = getComputed(configValueSources, configDefinitions);
389
- assertUsageGlobalConfigs(interfaceFilesRelevantList, configDefinitions, interfaceFilesByLocationId);
390
365
  const pageConfig = {
391
366
  pageId: locationId,
392
367
  isErrorPage,
393
368
  routeFilesystem,
394
369
  configDefinitions,
370
+ interfaceFiles: interfaceFilesRelevant,
395
371
  configValueSources,
396
372
  configValuesComputed
397
373
  };
398
- return pageConfig;
374
+ pageConfigs.push(pageConfig);
399
375
  }));
400
- assertPageConfigs(pageConfigs);
401
- return pageConfigs;
376
+ assertPageConfigs(pageConfigs, interfaceFilesAll);
377
+ return { pageConfigs, pageConfigGlobal };
402
378
  }
403
- function getConfigValues(pageConfig) {
404
- const configValues = {};
405
- (0, serializeConfigValues_js_1.getConfigValuesBase)(pageConfig, (configEnv) => !!configEnv.config, null).forEach((entry) => {
406
- if (entry.configValueBase.type === 'computed') {
407
- (0, utils_js_1.assert)('value' in entry); // Help TS
408
- const { configValueBase, value, configName } = entry;
409
- configValues[configName] = { ...configValueBase, value };
410
- }
411
- if (entry.configValueBase.type === 'standard') {
412
- (0, utils_js_1.assert)('sourceRelevant' in entry); // Help TS
413
- const { configValueBase, sourceRelevant, configName } = entry;
414
- (0, utils_js_1.assert)('value' in sourceRelevant);
415
- const { value } = sourceRelevant;
416
- configValues[configName] = { ...configValueBase, value };
417
- }
418
- if (entry.configValueBase.type === 'cumulative') {
419
- (0, utils_js_1.assert)('sourcesRelevant' in entry); // Help TS
420
- const { configValueBase, sourcesRelevant, configName } = entry;
421
- const values = [];
422
- sourcesRelevant.forEach((source) => {
423
- (0, utils_js_1.assert)('value' in source);
424
- values.push(source.value);
425
- });
426
- configValues[configName] = { ...configValueBase, value: values };
379
+ function getPageLocationIds(interfaceFilesAll) {
380
+ const locationIds = new Set();
381
+ (0, utils_js_1.objectEntries)(interfaceFilesAll).forEach(([locationId, interfaceFiles]) => {
382
+ if (isDefiningPage(interfaceFiles)) {
383
+ locationIds.add(locationId);
427
384
  }
428
385
  });
429
- return configValues;
386
+ return Array.from(locationIds);
387
+ }
388
+ function assertPageConfigs(pageConfigs, interfaceFilesAll) {
389
+ pageConfigs.forEach((pageConfig) => {
390
+ assertGlobalConfigs(pageConfig, interfaceFilesAll);
391
+ (0, assertExtensions_js_1.assertExtensionsRequire)(pageConfig);
392
+ assertOnBeforeRenderEnv(pageConfig);
393
+ });
430
394
  }
431
395
  // TODO/now: refactor
432
- // - Dedupe: most of the assertUsageGlobalConfigs() code below is a copy-paste of the assertUsage() logic inside getGlobalConfigs()
396
+ // - Dedupe: most of the assertGlobalConfigs() code below is a copy-paste of the assertUsage() logic inside getGlobalConfigs()
433
397
  // - This assertUsage() message is slightly better: use this one for getGlobalConfigs()
434
398
  // Global configs should be defined at global locations
435
- function assertUsageGlobalConfigs(interfaceFilesRelevantList, configDefinitions, interfaceFilesByLocationId) {
399
+ function assertGlobalConfigs(pageConfig, interfaceFilesAll) {
400
+ const interfaceFilesRelevantList = Object.values(pageConfig.interfaceFiles).flat(1);
401
+ const { configDefinitions } = pageConfig;
436
402
  interfaceFilesRelevantList.forEach((interfaceFile) => {
437
403
  const configNames = [];
438
404
  if (interfaceFile.isValueFile) {
@@ -442,13 +408,13 @@ function assertUsageGlobalConfigs(interfaceFilesRelevantList, configDefinitions,
442
408
  configNames.push(...Object.keys(interfaceFile.fileExportsByConfigName));
443
409
  }
444
410
  configNames.forEach((configName) => {
445
- if (isGlobalConfig(configName))
411
+ if (isGlobalConfigOld(configName))
446
412
  return;
447
413
  const configDef = getConfigDefinition(configDefinitions, configName, interfaceFile.filePath.filePathToShowToUser);
448
414
  if (configDef.global === true) {
449
- const locationIds = (0, utils_js_1.objectKeys)(interfaceFilesByLocationId);
415
+ const locationIds = (0, utils_js_1.objectKeys)(interfaceFilesAll);
450
416
  if (!(0, filesystemRouting_js_1.isGlobalLocation)(interfaceFile.locationId, locationIds)) {
451
- const interfaceFilesGlobal = (0, utils_js_1.objectFromEntries)((0, utils_js_1.objectEntries)(interfaceFilesByLocationId).filter(([locationId]) => {
417
+ const interfaceFilesGlobal = (0, utils_js_1.objectFromEntries)((0, utils_js_1.objectEntries)(interfaceFilesAll).filter(([locationId]) => {
452
418
  return (0, filesystemRouting_js_1.isGlobalLocation)(locationId, locationIds);
453
419
  }));
454
420
  const configFilesGlobal = [];
@@ -474,11 +440,6 @@ function assertUsageGlobalConfigs(interfaceFilesRelevantList, configDefinitions,
474
440
  });
475
441
  });
476
442
  }
477
- function assertPageConfigs(pageConfigs) {
478
- pageConfigs.forEach((pageConfig) => {
479
- assertOnBeforeRenderEnv(pageConfig);
480
- });
481
- }
482
443
  function assertOnBeforeRenderEnv(pageConfig) {
483
444
  const onBeforeRenderConfig = pageConfig.configValueSources.onBeforeRender?.[0];
484
445
  if (!onBeforeRenderConfig)
@@ -488,16 +449,36 @@ function assertOnBeforeRenderEnv(pageConfig) {
488
449
  // 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
489
450
  (0, utils_js_1.assertUsage)(!(onBeforeRenderEnv.client && !isClientRouting), `Page ${pageConfig.pageId} has an onBeforeRender() hook with env ${picocolors_1.default.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.`);
490
451
  }
491
- function interfacefileIsAlreaydLoaded(interfaceFile) {
492
- const configMapValues = Object.values(interfaceFile.fileExportsByConfigName);
493
- const isAlreadyLoaded = configMapValues.some((conf) => 'configValue' in conf);
494
- if (isAlreadyLoaded) {
495
- (0, utils_js_1.assert)(configMapValues.every((conf) => 'configValue' in conf));
496
- }
497
- return isAlreadyLoaded;
452
+ function getConfigValues(pageConfig) {
453
+ const configValues = {};
454
+ (0, serializeConfigValues_js_1.getConfigValuesBase)(pageConfig, (configEnv) => !!configEnv.config, null).forEach((entry) => {
455
+ if (entry.configValueBase.type === 'computed') {
456
+ (0, utils_js_1.assert)('value' in entry); // Help TS
457
+ const { configValueBase, value, configName } = entry;
458
+ configValues[configName] = { ...configValueBase, value };
459
+ }
460
+ if (entry.configValueBase.type === 'standard') {
461
+ (0, utils_js_1.assert)('sourceRelevant' in entry); // Help TS
462
+ const { configValueBase, sourceRelevant, configName } = entry;
463
+ (0, utils_js_1.assert)('value' in sourceRelevant);
464
+ const { value } = sourceRelevant;
465
+ configValues[configName] = { ...configValueBase, value };
466
+ }
467
+ if (entry.configValueBase.type === 'cumulative') {
468
+ (0, utils_js_1.assert)('sourcesRelevant' in entry); // Help TS
469
+ const { configValueBase, sourcesRelevant, configName } = entry;
470
+ const values = [];
471
+ sourcesRelevant.forEach((source) => {
472
+ (0, utils_js_1.assert)('value' in source);
473
+ values.push(source.value);
474
+ });
475
+ configValues[configName] = { ...configValueBase, value: values };
476
+ }
477
+ });
478
+ return configValues;
498
479
  }
499
- function getInterfaceFilesRelevant(interfaceFilesByLocationId, locationIdPage) {
500
- const interfaceFilesRelevant = Object.fromEntries((0, utils_js_1.objectEntries)(interfaceFilesByLocationId)
480
+ function getInterfaceFilesRelevant(interfaceFilesAll, locationIdPage) {
481
+ const interfaceFilesRelevant = Object.fromEntries((0, utils_js_1.objectEntries)(interfaceFilesAll)
501
482
  .filter(([locationId]) => {
502
483
  return (0, filesystemRouting_js_1.isInherited)(locationId, locationIdPage);
503
484
  })
@@ -508,7 +489,7 @@ async function resolveConfigValueSources(configName, configDef, interfaceFilesRe
508
489
  const sourcesInfo = [];
509
490
  // interfaceFilesRelevant is sorted by sortAfterInheritanceOrder()
510
491
  for (const interfaceFiles of Object.values(interfaceFilesRelevant)) {
511
- const interfaceFilesDefiningConfig = interfaceFiles.filter((interfaceFile) => interfaceFile.fileExportsByConfigName[configName]);
492
+ const interfaceFilesDefiningConfig = interfaceFiles.filter((interfaceFile) => getDefiningConfigNames(interfaceFile).includes(configName));
512
493
  if (interfaceFilesDefiningConfig.length === 0)
513
494
  continue;
514
495
  const visited = new WeakSet();
@@ -595,9 +576,12 @@ function isInterfaceFileUserLand(interfaceFile) {
595
576
  return (interfaceFile.isConfigFile && !interfaceFile.isConfigExtend) || interfaceFile.isValueFile;
596
577
  }
597
578
  async function getConfigValueSource(configName, interfaceFile, configDef, userRootDir, importedFilesLoaded, isHighestInheritancePrecedence) {
598
- const conf = interfaceFile.fileExportsByConfigName[configName];
599
- (0, utils_js_1.assert)(conf);
600
- const { locationId } = interfaceFile;
579
+ const confVal = getConfVal(interfaceFile, configName);
580
+ (0, utils_js_1.assert)(confVal);
581
+ const configValueSourceCommon = {
582
+ locationId: interfaceFile.locationId,
583
+ interfaceFile
584
+ };
601
585
  const definedAtFilePath_ = {
602
586
  ...interfaceFile.filePath,
603
587
  fileExportPathToShowToUser: ['default', configName]
@@ -609,7 +593,8 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
609
593
  let valueFilePath;
610
594
  if (interfaceFile.isConfigFile) {
611
595
  // Defined over pointer import
612
- const resolved = (0, resolvePointerImport_js_1.resolvePointerImportOfConfig)(conf.configValue, interfaceFile.filePath, userRootDir, configDef.env, configName);
596
+ (0, utils_js_1.assert)(confVal.configValueLoaded);
597
+ const resolved = (0, resolvePointerImport_js_1.resolvePointerImportOfConfig)(confVal.configValue, interfaceFile.filePath, userRootDir, configDef.env, configName);
613
598
  const configDefinedAt = (0, getConfigDefinedAt_js_1.getConfigDefinedAt)('Config', configName, definedAtFilePath_);
614
599
  (0, utils_js_1.assertUsage)(resolved, `${configDefinedAt} should be an import`);
615
600
  valueFilePath = resolved.pointerImport.filePathAbsoluteVite;
@@ -625,7 +610,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
625
610
  };
626
611
  }
627
612
  const configValueSource = {
628
- locationId,
613
+ ...configValueSourceCommon,
629
614
  value: valueFilePath,
630
615
  valueIsFilePath: true,
631
616
  configEnv: configDef.env,
@@ -638,13 +623,13 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
638
623
  }
639
624
  // +config.js
640
625
  if (interfaceFile.isConfigFile) {
641
- (0, utils_js_1.assert)('configValue' in conf);
642
- const { configValue } = conf;
626
+ (0, utils_js_1.assert)(confVal.configValueLoaded);
627
+ const { configValue } = confVal;
643
628
  // Defined over pointer import
644
629
  const resolved = (0, resolvePointerImport_js_1.resolvePointerImportOfConfig)(configValue, interfaceFile.filePath, userRootDir, configDef.env, configName);
645
630
  if (resolved) {
646
631
  const configValueSource = {
647
- locationId,
632
+ ...configValueSourceCommon,
648
633
  configEnv: resolved.configEnvResolved,
649
634
  valueIsImportedAtRuntime: true,
650
635
  valueIsDefinedByPlusFile: false,
@@ -652,7 +637,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
652
637
  definedAtFilePath: resolved.pointerImport
653
638
  };
654
639
  // Load pointer import
655
- if (isLoadableAtBuildTime(configDef) &&
640
+ if (shouldBeLoadableAtBuildTime(configDef) &&
656
641
  // The value of `extends` was already loaded and already used: we don't need the value of `extends` anymore
657
642
  configName !== 'extends') {
658
643
  if (resolved.pointerImport.filePathAbsoluteFilesystem) {
@@ -668,7 +653,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
668
653
  }
669
654
  // Defined inside +config.js
670
655
  const configValueSource = {
671
- locationId,
656
+ ...configValueSourceCommon,
672
657
  value: configValue,
673
658
  configEnv: configDef.env,
674
659
  valueIsImportedAtRuntime: false,
@@ -681,10 +666,10 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
681
666
  // Defined by value file, i.e. +{configName}.js
682
667
  if (interfaceFile.isValueFile) {
683
668
  const configEnvResolved = (0, resolvePointerImport_js_1.resolveConfigEnvWithFileName)(configDef.env, interfaceFile.filePath);
684
- const valueAlreadyLoaded = 'configValue' in conf;
669
+ const valueAlreadyLoaded = confVal.configValueLoaded;
685
670
  (0, utils_js_1.assert)(valueAlreadyLoaded === !!configEnvResolved.config);
686
671
  const configValueSource = {
687
- locationId,
672
+ ...configValueSourceCommon,
688
673
  configEnv: configEnvResolved,
689
674
  valueIsImportedAtRuntime: !valueAlreadyLoaded,
690
675
  valueIsDefinedByPlusFile: true,
@@ -698,7 +683,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
698
683
  }
699
684
  };
700
685
  if (valueAlreadyLoaded) {
701
- configValueSource.value = conf.configValue;
686
+ configValueSource.value = confVal.configValue;
702
687
  }
703
688
  return configValueSource;
704
689
  }
@@ -706,7 +691,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
706
691
  }
707
692
  function isDefiningPage(interfaceFiles) {
708
693
  for (const interfaceFile of interfaceFiles) {
709
- const configNames = Object.keys(interfaceFile.fileExportsByConfigName);
694
+ const configNames = getDefiningConfigNames(interfaceFile);
710
695
  if (configNames.some((configName) => isDefiningPageConfig(configName))) {
711
696
  return true;
712
697
  }
@@ -716,16 +701,28 @@ function isDefiningPage(interfaceFiles) {
716
701
  function isDefiningPageConfig(configName) {
717
702
  return ['Page', 'route'].includes(configName);
718
703
  }
704
+ function getDefiningConfigNames(interfaceFile) {
705
+ let configNames = [];
706
+ if (interfaceFile.isValueFile) {
707
+ configNames.push(interfaceFile.configName);
708
+ }
709
+ if (interfaceFile.isValueLoaded) {
710
+ configNames.push(...Object.keys(interfaceFile.fileExportsByConfigName));
711
+ }
712
+ configNames = (0, utils_js_1.unique)(configNames);
713
+ return configNames;
714
+ }
719
715
  function getConfigDefinitions(interfaceFilesRelevant) {
720
716
  const configDefinitionsMerged = { ...configDefinitionsBuiltIn };
721
717
  Object.entries(interfaceFilesRelevant)
722
718
  .reverse()
723
719
  .forEach(([_locationId, interfaceFiles]) => {
724
720
  interfaceFiles.forEach((interfaceFile) => {
725
- const configMeta = interfaceFile.fileExportsByConfigName['meta'];
726
- if (!configMeta)
721
+ const confVal = getConfVal(interfaceFile, 'meta');
722
+ if (!confVal)
727
723
  return;
728
- const meta = configMeta.configValue;
724
+ (0, utils_js_1.assert)(confVal.configValueLoaded);
725
+ const meta = confVal.configValue;
729
726
  assertMetaUsage(meta, `Config ${picocolors_1.default.cyan('meta')} defined at ${interfaceFile.filePath.filePathToShowToUser}`);
730
727
  // Set configDef._userEffectDefinedAtFilePath
731
728
  Object.entries(meta).forEach(([configName, configDef]) => {
@@ -1042,16 +1039,28 @@ function getConfigDefinition(configDefinitions, configName, filePathToShowToUser
1042
1039
  function getConfigDefinitionOptional(configDefinitions, configName) {
1043
1040
  return configDefinitions[configName] ?? null;
1044
1041
  }
1045
- function isLoadableAtBuildTime(configDef) {
1042
+ function shouldBeLoadableAtBuildTime(configDef) {
1046
1043
  return !!configDef.env.config && !configDef._valueIsFilePath;
1047
1044
  }
1048
- function isGlobalConfig(configName) {
1045
+ // TODO/now: remove
1046
+ function isGlobalConfigOld(configName) {
1049
1047
  // TODO/now
1050
1048
  if (configName === 'prerender')
1051
1049
  return false;
1052
1050
  const configNamesGlobal = getConfigNamesGlobal();
1053
1051
  return (0, utils_js_1.includes)(configNamesGlobal, configName);
1054
1052
  }
1053
+ // TODO/now
1054
+ function isGlobalConfig(configName, configDefinitions, value) {
1055
+ const configSpec = configDefinitions[configName];
1056
+ (0, utils_js_1.assert)(configSpec);
1057
+ const globalValue = configSpec.global;
1058
+ if (!globalValue)
1059
+ return false;
1060
+ if (globalValue === true)
1061
+ return true;
1062
+ return globalValue(value);
1063
+ }
1055
1064
  function getConfigNamesGlobal() {
1056
1065
  return Object.keys(configDefinitionsBuiltInGlobal);
1057
1066
  }
@@ -1084,38 +1093,12 @@ function sortConfigValueSources(configValueSources, locationIdPage) {
1084
1093
  // Sort after the filesystem inheritance of the config value
1085
1094
  .sort(([, [source1]], [, [source2]]) => (0, utils_js_1.reverse)((0, filesystemRouting_js_1.sortAfterInheritanceOrder)(source1.locationId, source2.locationId, locationIdPage))));
1086
1095
  }
1087
- function getConfigValueInterfaceFile(interfaceFile, configName) {
1088
- return interfaceFile.fileExportsByConfigName[configName]?.configValue;
1089
- }
1090
- // TODO/now: refactor code below
1091
- function resolveVikeConfigGlobal(vikeVitePluginOptions, pageConfigGlobalValues) {
1092
- const configs = [vikeVitePluginOptions, pageConfigGlobalValues];
1093
- const vikeConfigGlobal = {
1094
- disableAutoFullBuild: pickFirst(configs.map((c) => c.disableAutoFullBuild)) ?? null,
1095
- prerender: resolvePrerenderOptions(configs),
1096
- includeAssetsImportedByServer: pickFirst(configs.map((c) => c.includeAssetsImportedByServer)) ?? true,
1097
- baseServer: pickFirst(configs.map((c) => c.baseServer)) ?? null,
1098
- baseAssets: pickFirst(configs.map((c) => c.baseAssets)) ?? null,
1099
- disableUrlNormalization: pickFirst(configs.map((c) => c.disableUrlNormalization)) ?? false,
1100
- trailingSlash: pickFirst(configs.map((c) => c.trailingSlash)) ?? false
1101
- };
1102
- return vikeConfigGlobal;
1103
- }
1104
- function resolvePrerenderOptions(configs) {
1105
- if (!configs.some((c) => c.prerender)) {
1106
- return false;
1107
- }
1108
- const configsPrerender = configs.map((c) => c.prerender).filter(isObject2);
1109
- return {
1110
- partial: pickFirst(configsPrerender.map((c) => c.partial)) ?? false,
1111
- noExtraDir: pickFirst(configsPrerender.map((c) => c.noExtraDir)) ?? false,
1112
- parallel: pickFirst(configsPrerender.map((c) => c.parallel)) ?? true,
1113
- disableAutoRun: pickFirst(configsPrerender.map((c) => c.disableAutoRun)) ?? false
1114
- };
1115
- }
1116
- function isObject2(p) {
1117
- return typeof p === 'object';
1118
- }
1119
- function pickFirst(arr) {
1120
- return arr.filter((v) => v !== undefined)[0];
1096
+ function getConfVal(interfaceFile, configName) {
1097
+ const configNames = getDefiningConfigNames(interfaceFile);
1098
+ if (!configNames.includes(configName))
1099
+ return null;
1100
+ if (!interfaceFile.isValueLoaded)
1101
+ return { configValueLoaded: false };
1102
+ const confVal = { configValue: interfaceFile.fileExportsByConfigName[configName], configValueLoaded: true };
1103
+ return confVal;
1121
1104
  }