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
@@ -4,8 +4,10 @@ export { reloadVikeConfig };
4
4
  export { vikeConfigDependencies };
5
5
  export { isVikeConfigFile };
6
6
  export { isV1Design };
7
- export { getConfigValueInterfaceFile };
8
- import { assertPosixPath, assert, isObject, assertUsage, assertWarning, objectEntries, hasProp, includes, assertIsNotProductionRuntime, getMostSimilar, joinEnglish, lowerFirst, assertKeys, objectKeys, objectFromEntries, makeFirst, isNpmPackageImport, reverse } from '../../../utils.js';
7
+ export { getConfVal };
8
+ export { getConfigDefinitionOptional };
9
+ export { shouldBeLoadableAtBuildTime };
10
+ import { assertPosixPath, assert, isObject, assertUsage, assertWarning, objectEntries, hasProp, includes, assertIsNotProductionRuntime, getMostSimilar, joinEnglish, lowerFirst, assertKeys, objectKeys, objectFromEntries, makeFirst, isNpmPackageImport, reverse, unique } from '../../../utils.js';
9
11
  import path from 'path';
10
12
  import { configDefinitionsBuiltInAll } from './getVikeConfig/configDefinitionsBuiltIn.js';
11
13
  import { getLocationId, getFilesystemRouteString, getFilesystemRouteDefinedBy, isInherited, sortAfterInheritanceOrder, isGlobalLocation, applyFilesystemRoutingRootEffect } from './getVikeConfig/filesystemRouting.js';
@@ -18,11 +20,11 @@ import pc from '@brillout/picocolors';
18
20
  import { getConfigDefinedAt } from '../../../../../shared/page-configs/getConfigDefinedAt.js';
19
21
  import { crawlPlusFiles } from './getVikeConfig/crawlPlusFiles.js';
20
22
  import { getConfigFileExport } from './getConfigFileExport.js';
21
- import { loadConfigFile, loadImportedFile, loadValueFile } from './getVikeConfig/loadFileAtConfigTime.js';
23
+ import { loadConfigFile, loadImportedFile, loadValueFile, loadValueFiles } from './getVikeConfig/loadFileAtConfigTime.js';
22
24
  import { clearFilesEnvMap, resolveConfigEnvWithFileName, resolvePointerImportOfConfig } from './getVikeConfig/resolvePointerImport.js';
23
25
  import { getFilePathResolved } from '../../../shared/getFilePath.js';
24
26
  import { getConfigValueBuildTime } from '../../../../../shared/page-configs/getConfigValueBuildTime.js';
25
- import { assertExtensionsPeerDependencies, assertExtensionsConventions } from './assertExtensions.js';
27
+ import { assertExtensionsRequire, assertExtensionsConventions } from './assertExtensions.js';
26
28
  import { getPageConfigUserFriendlyNew } from '../../../../../shared/page-configs/getPageConfigUserFriendly.js';
27
29
  import { getConfigValuesBase } from '../../../../../shared/page-configs/serialize/serializeConfigValues.js';
28
30
  const configDefinitionsBuiltIn = getConfigDefinitionsBuiltIn();
@@ -108,7 +110,7 @@ async function loadInterfaceFiles(userRootDir) {
108
110
  valueFiles.push(f);
109
111
  }
110
112
  });
111
- let interfaceFilesByLocationId = {};
113
+ let interfaceFilesAll = {};
112
114
  await Promise.all([
113
115
  // Config files
114
116
  ...configFiles.map(async (filePath) => {
@@ -118,8 +120,8 @@ async function loadInterfaceFiles(userRootDir) {
118
120
  assert(filePath.filePathAbsoluteUserRootDir);
119
121
  const locationId = getLocationId(filePathAbsoluteUserRootDir);
120
122
  const interfaceFile = getInterfaceFileFromConfigFile(configFile, false, locationId);
121
- interfaceFilesByLocationId[locationId] = interfaceFilesByLocationId[locationId] ?? [];
122
- interfaceFilesByLocationId[locationId].push(interfaceFile);
123
+ interfaceFilesAll[locationId] = interfaceFilesAll[locationId] ?? [];
124
+ interfaceFilesAll[locationId].push(interfaceFile);
123
125
  extendsConfigs.forEach((extendsConfig) => {
124
126
  /* We purposely use the same locationId because the Vike extension's config should only apply to where it's being extended from, for example:
125
127
  ```js
@@ -139,7 +141,7 @@ async function loadInterfaceFiles(userRootDir) {
139
141
  */
140
142
  const interfaceFile = getInterfaceFileFromConfigFile(extendsConfig, true, locationId);
141
143
  assertExtensionsConventions(interfaceFile);
142
- interfaceFilesByLocationId[locationId].push(interfaceFile);
144
+ interfaceFilesAll[locationId].push(interfaceFile);
143
145
  });
144
146
  }),
145
147
  // Value files
@@ -152,30 +154,21 @@ async function loadInterfaceFiles(userRootDir) {
152
154
  const interfaceFile = {
153
155
  locationId,
154
156
  filePath,
155
- fileExportsByConfigName: {
156
- [configName]: {}
157
- },
158
157
  isConfigFile: false,
159
158
  isValueFile: true,
159
+ isValueLoaded: false,
160
160
  configName
161
161
  };
162
- {
163
- // We don't have access to the custom config definitions defined by the user yet.
164
- // - If `configDef` is `undefined` => we load the file +{configName}.js later.
165
- // - We already need to load +meta.js here (to get the custom config definitions defined by the user)
166
- const configDef = getConfigDefinitionOptional(configDefinitionsBuiltIn, configName);
167
- if (configDef && isLoadableAtBuildTime(configDef)) {
168
- await loadValueFile(interfaceFile, configName, userRootDir);
169
- }
170
- }
171
- {
172
- interfaceFilesByLocationId[locationId] = interfaceFilesByLocationId[locationId] ?? [];
173
- interfaceFilesByLocationId[locationId].push(interfaceFile);
174
- }
162
+ interfaceFilesAll[locationId] = interfaceFilesAll[locationId] ?? [];
163
+ interfaceFilesAll[locationId].push(interfaceFile);
164
+ // We don't have access to the custom config definitions defined by the user yet.
165
+ // - If `configDef` is `undefined` => we load the file +{configName}.js later.
166
+ // - We already need to load +meta.js here (to get the custom config definitions defined by the user)
167
+ await loadValueFile(interfaceFile, configDefinitionsBuiltIn, userRootDir);
175
168
  })
176
169
  ]);
177
- assertAllConfigsAreKnown(interfaceFilesByLocationId);
178
- return interfaceFilesByLocationId;
170
+ assertAllConfigsAreKnown(interfaceFilesAll);
171
+ return interfaceFilesAll;
179
172
  }
180
173
  function getInterfaceFileFromConfigFile(configFile, isConfigExtend, locationId) {
181
174
  const { fileExports, filePath, extendsFilePaths } = configFile;
@@ -185,23 +178,27 @@ function getInterfaceFileFromConfigFile(configFile, isConfigExtend, locationId)
185
178
  fileExportsByConfigName: {},
186
179
  isConfigFile: true,
187
180
  isValueFile: false,
181
+ isValueLoaded: true,
188
182
  isConfigExtend,
189
183
  extendsFilePaths
190
184
  };
191
185
  const fileExport = getConfigFileExport(fileExports, filePath.filePathToShowToUser);
192
186
  Object.entries(fileExport).forEach(([configName, configValue]) => {
193
- interfaceFile.fileExportsByConfigName[configName] = { configValue };
187
+ interfaceFile.fileExportsByConfigName[configName] = configValue;
194
188
  });
195
189
  return interfaceFile;
196
190
  }
197
191
  /** Show error message upon unknown config */
198
- function assertAllConfigsAreKnown(interfaceFilesByLocationId) {
199
- objectEntries(interfaceFilesByLocationId).forEach(([locationId, interfaceFiles]) => {
200
- const interfaceFilesRelevant = getInterfaceFilesRelevant(interfaceFilesByLocationId, locationId);
192
+ function assertAllConfigsAreKnown(interfaceFilesAll) {
193
+ objectEntries(interfaceFilesAll).forEach(([locationId, interfaceFiles]) => {
194
+ const interfaceFilesRelevant = getInterfaceFilesRelevant(interfaceFilesAll, locationId);
201
195
  const configDefinitions = getConfigDefinitions(interfaceFilesRelevant);
202
196
  interfaceFiles.forEach((interfaceFile) => {
203
- Object.keys(interfaceFile.fileExportsByConfigName).forEach((configName) => {
204
- assertConfigExists(configName, Object.keys(configDefinitions), interfaceFile.filePath.filePathToShowToUser);
197
+ const configNamesKnown = Object.keys(configDefinitions);
198
+ const { filePathToShowToUser } = interfaceFile.filePath;
199
+ const configNames = getDefiningConfigNames(interfaceFile);
200
+ configNames.forEach((configName) => {
201
+ assertConfigExists(configName, configNamesKnown, filePathToShowToUser);
205
202
  });
206
203
  });
207
204
  });
@@ -240,9 +237,9 @@ async function loadVikeConfig_withErrorHandling(userRootDir, isDev, vikeVitePlug
240
237
  pageConfigs: [],
241
238
  pageConfigGlobal: {
242
239
  configDefinitions: {},
240
+ interfaceFiles: {},
243
241
  configValueSources: {}
244
242
  },
245
- vikeConfigGlobal: resolveVikeConfigGlobal({}, {}),
246
243
  global: getPageConfigUserFriendlyNew({ configValues: {} })
247
244
  };
248
245
  return dummyData;
@@ -250,49 +247,86 @@ async function loadVikeConfig_withErrorHandling(userRootDir, isDev, vikeVitePlug
250
247
  }
251
248
  }
252
249
  async function loadVikeConfig(userRootDir, vikeVitePluginOptions) {
253
- const interfaceFilesByLocationId = await loadInterfaceFiles(userRootDir);
250
+ const interfaceFilesAll = await loadInterfaceFiles(userRootDir);
254
251
  const importedFilesLoaded = {};
255
- const [globalConfigs, pageConfigs] = await Promise.all([
256
- getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded, vikeVitePluginOptions),
257
- getPageConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded)
258
- ]);
259
- return { pageConfigs, ...globalConfigs };
252
+ const { pageConfigGlobal, pageConfigs } = await getPageConfigs(interfaceFilesAll, userRootDir, importedFilesLoaded);
253
+ // interop vike(options) in vite.config.js
254
+ temp_interopVikeVitePlugin(pageConfigGlobal, vikeVitePluginOptions, userRootDir);
255
+ // global
256
+ const configValues = getConfigValues(pageConfigGlobal);
257
+ const global = getPageConfigUserFriendlyNew({ configValues });
258
+ return { pageConfigs, pageConfigGlobal, global };
260
259
  }
261
- async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded, vikeVitePluginOptions) {
262
- const locationIds = objectKeys(interfaceFilesByLocationId);
263
- const interfaceFilesGlobal = objectFromEntries(objectEntries(interfaceFilesByLocationId).filter(([locationId]) => {
264
- return isGlobalLocation(locationId, locationIds);
265
- }));
260
+ async function getGlobalConfigs(interfaceFilesAll, userRootDir, importedFilesLoaded) {
261
+ /* TODO/now: dedupe
266
262
  // Validate that global configs live in global interface files
267
263
  {
268
- const interfaceFilesGlobalPaths = [];
269
- objectEntries(interfaceFilesGlobal).forEach(([locationId, interfaceFiles]) => {
270
- assert(isGlobalLocation(locationId, locationIds));
271
- interfaceFiles.forEach(({ filePath: { filePathAbsoluteUserRootDir } }) => {
272
- if (filePathAbsoluteUserRootDir) {
273
- interfaceFilesGlobalPaths.push(filePathAbsoluteUserRootDir);
274
- }
275
- });
276
- });
277
- const globalPaths = Array.from(new Set(interfaceFilesGlobalPaths.map((p) => path.posix.dirname(p))));
278
- objectEntries(interfaceFilesByLocationId).forEach(([locationId, interfaceFiles]) => {
279
- interfaceFiles.forEach((interfaceFile) => {
280
- Object.keys(interfaceFile.fileExportsByConfigName).forEach((configName) => {
281
- if (!isGlobalLocation(locationId, locationIds) && isGlobalConfig(configName)) {
282
- assertUsage(false, [
283
- `${interfaceFile.filePath.filePathToShowToUser} defines the config ${pc.cyan(configName)} which is global:`,
284
- globalPaths.length
285
- ? `define ${pc.cyan(configName)} in ${joinEnglish(globalPaths, 'or')} instead`
286
- : `create a global config (e.g. /pages/+config.js) and define ${pc.cyan(configName)} there instead`
287
- ].join(' '));
288
- }
289
- });
290
- });
291
- });
264
+ const interfaceFilesGlobalPaths: string[] = []
265
+ objectEntries(interfaceFilesGlobal).forEach(([locationId, interfaceFiles]) => {
266
+ assert(isGlobalLocation(locationId, locationIds))
267
+ interfaceFiles.forEach(({ filePath: { filePathAbsoluteUserRootDir } }) => {
268
+ if (filePathAbsoluteUserRootDir) {
269
+ interfaceFilesGlobalPaths.push(filePathAbsoluteUserRootDir)
270
+ }
271
+ })
272
+ })
273
+ const globalPaths = Array.from(new Set(interfaceFilesGlobalPaths.map((p) => path.posix.dirname(p))))
274
+ objectEntries(interfaceFilesAll).forEach(([locationId, interfaceFiles]) => {
275
+ interfaceFiles.forEach((interfaceFile) => {
276
+ Object.keys(interfaceFile.fileExportsByConfigName).forEach((configName) => {
277
+ if (!isGlobalLocation(locationId, locationIds) && isGlobalConfigOld(configName)) {
278
+ assertUsage(
279
+ false,
280
+ [
281
+ `${interfaceFile.filePath.filePathToShowToUser} defines the config ${pc.cyan(
282
+ configName
283
+ )} which is global:`,
284
+ globalPaths.length
285
+ ? `define ${pc.cyan(configName)} in ${joinEnglish(globalPaths, 'or')} instead`
286
+ : `create a global config (e.g. /pages/+config.js) and define ${pc.cyan(configName)} there instead`
287
+ ].join(' ')
288
+ )
289
+ }
290
+ })
291
+ })
292
+ })
292
293
  }
293
- const pageConfigGlobalValues = {};
294
+ //*/
295
+ }
296
+ function temp_interopVikeVitePlugin(pageConfigGlobal, vikeVitePluginOptions, userRootDir) {
297
+ assert(isObject(vikeVitePluginOptions));
298
+ assertWarning(Object.keys(vikeVitePluginOptions).length === 0, `Define Vike settings in +config.js instead of vite.config.js ${pc.underline('https://vike.dev/migration/settings')}`, { onlyOnce: true });
299
+ Object.entries(vikeVitePluginOptions).forEach(([configName, value]) => {
300
+ var _a;
301
+ assert(includes(objectKeys(configDefinitionsBuiltInGlobal), configName));
302
+ const configDef = configDefinitionsBuiltInGlobal[configName];
303
+ const sources = ((_a = pageConfigGlobal.configValueSources)[configName] ?? (_a[configName] = []));
304
+ sources.push({
305
+ value,
306
+ configEnv: configDef.env,
307
+ definedAtFilePath: {
308
+ ...getFilePathResolved({
309
+ userRootDir,
310
+ filePathAbsoluteUserRootDir: '/vite.config.js'
311
+ }),
312
+ fileExportPathToShowToUser: null
313
+ },
314
+ locationId: '/',
315
+ interfaceFile: null,
316
+ isOverriden: configDef.cumulative ? false : sources.length > 0,
317
+ valueIsImportedAtRuntime: false,
318
+ valueIsDefinedByPlusFile: false
319
+ });
320
+ });
321
+ }
322
+ async function getPageConfigs(interfaceFilesAll, userRootDir, importedFilesLoaded) {
323
+ const locationIds = objectKeys(interfaceFilesAll);
324
+ const interfaceFilesGlobal = objectFromEntries(objectEntries(interfaceFilesAll).filter(([locationId]) => {
325
+ return isGlobalLocation(locationId, locationIds);
326
+ }));
294
327
  const pageConfigGlobal = {
295
328
  configDefinitions: configDefinitionsBuiltInGlobal,
329
+ interfaceFiles: interfaceFilesGlobal,
296
330
  configValueSources: {}
297
331
  };
298
332
  await Promise.all(objectEntries(configDefinitionsBuiltInGlobal).map(async ([configName, configDef]) => {
@@ -301,75 +335,17 @@ async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importe
301
335
  if (!configValueSource)
302
336
  return;
303
337
  pageConfigGlobal.configValueSources[configName] = sources;
304
- // TODO/now
305
- if (configName === 'onBeforeRoute' || configName === 'onPrerenderStart') {
306
- assert(!('value' in configValueSource));
307
- }
308
- else {
309
- assert('value' in configValueSource);
310
- // TODO/now
311
- if (configName === 'prerender' && typeof configValueSource.value === 'boolean')
312
- return;
313
- pageConfigGlobalValues[configName] = configValueSource.value;
314
- }
315
338
  }));
316
- const vikeConfigGlobal = resolveVikeConfigGlobal(vikeVitePluginOptions, pageConfigGlobalValues);
317
- {
318
- assert(isObject(vikeVitePluginOptions));
319
- Object.entries(vikeVitePluginOptions).forEach(([configName, value]) => {
320
- var _a;
321
- assert(includes(objectKeys(configDefinitionsBuiltInGlobal), configName));
322
- const configDef = configDefinitionsBuiltInGlobal[configName];
323
- const sources = ((_a = pageConfigGlobal.configValueSources)[configName] ?? (_a[configName] = []));
324
- sources.push({
325
- value,
326
- configEnv: configDef.env,
327
- definedAtFilePath: {
328
- ...getFilePathResolved({
329
- userRootDir,
330
- filePathAbsoluteUserRootDir: '/vite.config.js'
331
- }),
332
- fileExportPathToShowToUser: null
333
- },
334
- locationId: '/',
335
- isOverriden: configDef.cumulative ? false : sources.length > 0,
336
- valueIsImportedAtRuntime: false,
337
- valueIsDefinedByPlusFile: false
338
- });
339
- });
340
- }
341
- const configValues = getConfigValues(pageConfigGlobal);
342
- const global = getPageConfigUserFriendlyNew({ configValues });
343
- return { pageConfigGlobal, vikeConfigGlobal, global };
344
- }
345
- async function getPageConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded) {
346
- const pageConfigs = await Promise.all(objectEntries(interfaceFilesByLocationId)
347
- .filter(([_pageId, interfaceFiles]) => isDefiningPage(interfaceFiles))
348
- .map(async ([locationId]) => {
349
- const interfaceFilesRelevant = getInterfaceFilesRelevant(interfaceFilesByLocationId, locationId);
350
- const interfaceFilesRelevantList = Object.values(interfaceFilesRelevant).flat(1);
351
- assertExtensionsPeerDependencies(interfaceFilesRelevantList);
339
+ const pageConfigs = [];
340
+ await Promise.all(getPageLocationIds(interfaceFilesAll).map(async (locationId) => {
341
+ const interfaceFilesRelevant = getInterfaceFilesRelevant(interfaceFilesAll, locationId);
352
342
  const configDefinitions = getConfigDefinitions(interfaceFilesRelevant);
353
- // Load value files of custom config-only configs
354
- await Promise.all(interfaceFilesRelevantList.map(async (interfaceFile) => {
355
- if (!interfaceFile.isValueFile)
356
- return;
357
- const { configName } = interfaceFile;
358
- if (isGlobalConfig(configName))
359
- return;
360
- const configDef = getConfigDefinition(configDefinitions, configName, interfaceFile.filePath.filePathToShowToUser);
361
- if (!isLoadableAtBuildTime(configDef))
362
- return;
363
- const isAlreadyLoaded = interfacefileIsAlreaydLoaded(interfaceFile);
364
- if (isAlreadyLoaded)
365
- return;
366
- // Value files of built-in configs should have already been loaded at loadInterfaceFiles()
367
- assert(!(configName in configDefinitionsBuiltIn));
368
- await loadValueFile(interfaceFile, configName, userRootDir);
369
- }));
343
+ // Load value files (with `env.config===true`) of *custom* configs.
344
+ // - The value files of *built-in* configs are already loaded at `loadInterfaceFiles()`.
345
+ await loadValueFiles(interfaceFilesRelevant, configDefinitions, userRootDir);
370
346
  let configValueSources = {};
371
347
  await Promise.all(objectEntries(configDefinitions)
372
- .filter(([configName]) => !isGlobalConfig(configName))
348
+ .filter(([configName]) => !isGlobalConfigOld(configName))
373
349
  .map(async ([configName, configDef]) => {
374
350
  const sources = await resolveConfigValueSources(configName, configDef, interfaceFilesRelevant, userRootDir, importedFilesLoaded);
375
351
  if (sources.length === 0)
@@ -380,53 +356,43 @@ async function getPageConfigs(interfaceFilesByLocationId, userRootDir, importedF
380
356
  const { routeFilesystem, isErrorPage } = determineRouteFilesystem(locationId, configValueSources);
381
357
  applyEffectsAll(configValueSources, configDefinitions);
382
358
  const configValuesComputed = getComputed(configValueSources, configDefinitions);
383
- assertUsageGlobalConfigs(interfaceFilesRelevantList, configDefinitions, interfaceFilesByLocationId);
384
359
  const pageConfig = {
385
360
  pageId: locationId,
386
361
  isErrorPage,
387
362
  routeFilesystem,
388
363
  configDefinitions,
364
+ interfaceFiles: interfaceFilesRelevant,
389
365
  configValueSources,
390
366
  configValuesComputed
391
367
  };
392
- return pageConfig;
368
+ pageConfigs.push(pageConfig);
393
369
  }));
394
- assertPageConfigs(pageConfigs);
395
- return pageConfigs;
370
+ assertPageConfigs(pageConfigs, interfaceFilesAll);
371
+ return { pageConfigs, pageConfigGlobal };
396
372
  }
397
- function getConfigValues(pageConfig) {
398
- const configValues = {};
399
- getConfigValuesBase(pageConfig, (configEnv) => !!configEnv.config, null).forEach((entry) => {
400
- if (entry.configValueBase.type === 'computed') {
401
- assert('value' in entry); // Help TS
402
- const { configValueBase, value, configName } = entry;
403
- configValues[configName] = { ...configValueBase, value };
404
- }
405
- if (entry.configValueBase.type === 'standard') {
406
- assert('sourceRelevant' in entry); // Help TS
407
- const { configValueBase, sourceRelevant, configName } = entry;
408
- assert('value' in sourceRelevant);
409
- const { value } = sourceRelevant;
410
- configValues[configName] = { ...configValueBase, value };
411
- }
412
- if (entry.configValueBase.type === 'cumulative') {
413
- assert('sourcesRelevant' in entry); // Help TS
414
- const { configValueBase, sourcesRelevant, configName } = entry;
415
- const values = [];
416
- sourcesRelevant.forEach((source) => {
417
- assert('value' in source);
418
- values.push(source.value);
419
- });
420
- configValues[configName] = { ...configValueBase, value: values };
373
+ function getPageLocationIds(interfaceFilesAll) {
374
+ const locationIds = new Set();
375
+ objectEntries(interfaceFilesAll).forEach(([locationId, interfaceFiles]) => {
376
+ if (isDefiningPage(interfaceFiles)) {
377
+ locationIds.add(locationId);
421
378
  }
422
379
  });
423
- return configValues;
380
+ return Array.from(locationIds);
381
+ }
382
+ function assertPageConfigs(pageConfigs, interfaceFilesAll) {
383
+ pageConfigs.forEach((pageConfig) => {
384
+ assertGlobalConfigs(pageConfig, interfaceFilesAll);
385
+ assertExtensionsRequire(pageConfig);
386
+ assertOnBeforeRenderEnv(pageConfig);
387
+ });
424
388
  }
425
389
  // TODO/now: refactor
426
- // - Dedupe: most of the assertUsageGlobalConfigs() code below is a copy-paste of the assertUsage() logic inside getGlobalConfigs()
390
+ // - Dedupe: most of the assertGlobalConfigs() code below is a copy-paste of the assertUsage() logic inside getGlobalConfigs()
427
391
  // - This assertUsage() message is slightly better: use this one for getGlobalConfigs()
428
392
  // Global configs should be defined at global locations
429
- function assertUsageGlobalConfigs(interfaceFilesRelevantList, configDefinitions, interfaceFilesByLocationId) {
393
+ function assertGlobalConfigs(pageConfig, interfaceFilesAll) {
394
+ const interfaceFilesRelevantList = Object.values(pageConfig.interfaceFiles).flat(1);
395
+ const { configDefinitions } = pageConfig;
430
396
  interfaceFilesRelevantList.forEach((interfaceFile) => {
431
397
  const configNames = [];
432
398
  if (interfaceFile.isValueFile) {
@@ -436,13 +402,13 @@ function assertUsageGlobalConfigs(interfaceFilesRelevantList, configDefinitions,
436
402
  configNames.push(...Object.keys(interfaceFile.fileExportsByConfigName));
437
403
  }
438
404
  configNames.forEach((configName) => {
439
- if (isGlobalConfig(configName))
405
+ if (isGlobalConfigOld(configName))
440
406
  return;
441
407
  const configDef = getConfigDefinition(configDefinitions, configName, interfaceFile.filePath.filePathToShowToUser);
442
408
  if (configDef.global === true) {
443
- const locationIds = objectKeys(interfaceFilesByLocationId);
409
+ const locationIds = objectKeys(interfaceFilesAll);
444
410
  if (!isGlobalLocation(interfaceFile.locationId, locationIds)) {
445
- const interfaceFilesGlobal = objectFromEntries(objectEntries(interfaceFilesByLocationId).filter(([locationId]) => {
411
+ const interfaceFilesGlobal = objectFromEntries(objectEntries(interfaceFilesAll).filter(([locationId]) => {
446
412
  return isGlobalLocation(locationId, locationIds);
447
413
  }));
448
414
  const configFilesGlobal = [];
@@ -468,11 +434,6 @@ function assertUsageGlobalConfigs(interfaceFilesRelevantList, configDefinitions,
468
434
  });
469
435
  });
470
436
  }
471
- function assertPageConfigs(pageConfigs) {
472
- pageConfigs.forEach((pageConfig) => {
473
- assertOnBeforeRenderEnv(pageConfig);
474
- });
475
- }
476
437
  function assertOnBeforeRenderEnv(pageConfig) {
477
438
  const onBeforeRenderConfig = pageConfig.configValueSources.onBeforeRender?.[0];
478
439
  if (!onBeforeRenderConfig)
@@ -482,16 +443,36 @@ function assertOnBeforeRenderEnv(pageConfig) {
482
443
  // 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
483
444
  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.`);
484
445
  }
485
- function interfacefileIsAlreaydLoaded(interfaceFile) {
486
- const configMapValues = Object.values(interfaceFile.fileExportsByConfigName);
487
- const isAlreadyLoaded = configMapValues.some((conf) => 'configValue' in conf);
488
- if (isAlreadyLoaded) {
489
- assert(configMapValues.every((conf) => 'configValue' in conf));
490
- }
491
- return isAlreadyLoaded;
446
+ function getConfigValues(pageConfig) {
447
+ const configValues = {};
448
+ getConfigValuesBase(pageConfig, (configEnv) => !!configEnv.config, null).forEach((entry) => {
449
+ if (entry.configValueBase.type === 'computed') {
450
+ assert('value' in entry); // Help TS
451
+ const { configValueBase, value, configName } = entry;
452
+ configValues[configName] = { ...configValueBase, value };
453
+ }
454
+ if (entry.configValueBase.type === 'standard') {
455
+ assert('sourceRelevant' in entry); // Help TS
456
+ const { configValueBase, sourceRelevant, configName } = entry;
457
+ assert('value' in sourceRelevant);
458
+ const { value } = sourceRelevant;
459
+ configValues[configName] = { ...configValueBase, value };
460
+ }
461
+ if (entry.configValueBase.type === 'cumulative') {
462
+ assert('sourcesRelevant' in entry); // Help TS
463
+ const { configValueBase, sourcesRelevant, configName } = entry;
464
+ const values = [];
465
+ sourcesRelevant.forEach((source) => {
466
+ assert('value' in source);
467
+ values.push(source.value);
468
+ });
469
+ configValues[configName] = { ...configValueBase, value: values };
470
+ }
471
+ });
472
+ return configValues;
492
473
  }
493
- function getInterfaceFilesRelevant(interfaceFilesByLocationId, locationIdPage) {
494
- const interfaceFilesRelevant = Object.fromEntries(objectEntries(interfaceFilesByLocationId)
474
+ function getInterfaceFilesRelevant(interfaceFilesAll, locationIdPage) {
475
+ const interfaceFilesRelevant = Object.fromEntries(objectEntries(interfaceFilesAll)
495
476
  .filter(([locationId]) => {
496
477
  return isInherited(locationId, locationIdPage);
497
478
  })
@@ -502,7 +483,7 @@ async function resolveConfigValueSources(configName, configDef, interfaceFilesRe
502
483
  const sourcesInfo = [];
503
484
  // interfaceFilesRelevant is sorted by sortAfterInheritanceOrder()
504
485
  for (const interfaceFiles of Object.values(interfaceFilesRelevant)) {
505
- const interfaceFilesDefiningConfig = interfaceFiles.filter((interfaceFile) => interfaceFile.fileExportsByConfigName[configName]);
486
+ const interfaceFilesDefiningConfig = interfaceFiles.filter((interfaceFile) => getDefiningConfigNames(interfaceFile).includes(configName));
506
487
  if (interfaceFilesDefiningConfig.length === 0)
507
488
  continue;
508
489
  const visited = new WeakSet();
@@ -589,9 +570,12 @@ function isInterfaceFileUserLand(interfaceFile) {
589
570
  return (interfaceFile.isConfigFile && !interfaceFile.isConfigExtend) || interfaceFile.isValueFile;
590
571
  }
591
572
  async function getConfigValueSource(configName, interfaceFile, configDef, userRootDir, importedFilesLoaded, isHighestInheritancePrecedence) {
592
- const conf = interfaceFile.fileExportsByConfigName[configName];
593
- assert(conf);
594
- const { locationId } = interfaceFile;
573
+ const confVal = getConfVal(interfaceFile, configName);
574
+ assert(confVal);
575
+ const configValueSourceCommon = {
576
+ locationId: interfaceFile.locationId,
577
+ interfaceFile
578
+ };
595
579
  const definedAtFilePath_ = {
596
580
  ...interfaceFile.filePath,
597
581
  fileExportPathToShowToUser: ['default', configName]
@@ -603,7 +587,8 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
603
587
  let valueFilePath;
604
588
  if (interfaceFile.isConfigFile) {
605
589
  // Defined over pointer import
606
- const resolved = resolvePointerImportOfConfig(conf.configValue, interfaceFile.filePath, userRootDir, configDef.env, configName);
590
+ assert(confVal.configValueLoaded);
591
+ const resolved = resolvePointerImportOfConfig(confVal.configValue, interfaceFile.filePath, userRootDir, configDef.env, configName);
607
592
  const configDefinedAt = getConfigDefinedAt('Config', configName, definedAtFilePath_);
608
593
  assertUsage(resolved, `${configDefinedAt} should be an import`);
609
594
  valueFilePath = resolved.pointerImport.filePathAbsoluteVite;
@@ -619,7 +604,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
619
604
  };
620
605
  }
621
606
  const configValueSource = {
622
- locationId,
607
+ ...configValueSourceCommon,
623
608
  value: valueFilePath,
624
609
  valueIsFilePath: true,
625
610
  configEnv: configDef.env,
@@ -632,13 +617,13 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
632
617
  }
633
618
  // +config.js
634
619
  if (interfaceFile.isConfigFile) {
635
- assert('configValue' in conf);
636
- const { configValue } = conf;
620
+ assert(confVal.configValueLoaded);
621
+ const { configValue } = confVal;
637
622
  // Defined over pointer import
638
623
  const resolved = resolvePointerImportOfConfig(configValue, interfaceFile.filePath, userRootDir, configDef.env, configName);
639
624
  if (resolved) {
640
625
  const configValueSource = {
641
- locationId,
626
+ ...configValueSourceCommon,
642
627
  configEnv: resolved.configEnvResolved,
643
628
  valueIsImportedAtRuntime: true,
644
629
  valueIsDefinedByPlusFile: false,
@@ -646,7 +631,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
646
631
  definedAtFilePath: resolved.pointerImport
647
632
  };
648
633
  // Load pointer import
649
- if (isLoadableAtBuildTime(configDef) &&
634
+ if (shouldBeLoadableAtBuildTime(configDef) &&
650
635
  // The value of `extends` was already loaded and already used: we don't need the value of `extends` anymore
651
636
  configName !== 'extends') {
652
637
  if (resolved.pointerImport.filePathAbsoluteFilesystem) {
@@ -662,7 +647,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
662
647
  }
663
648
  // Defined inside +config.js
664
649
  const configValueSource = {
665
- locationId,
650
+ ...configValueSourceCommon,
666
651
  value: configValue,
667
652
  configEnv: configDef.env,
668
653
  valueIsImportedAtRuntime: false,
@@ -675,10 +660,10 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
675
660
  // Defined by value file, i.e. +{configName}.js
676
661
  if (interfaceFile.isValueFile) {
677
662
  const configEnvResolved = resolveConfigEnvWithFileName(configDef.env, interfaceFile.filePath);
678
- const valueAlreadyLoaded = 'configValue' in conf;
663
+ const valueAlreadyLoaded = confVal.configValueLoaded;
679
664
  assert(valueAlreadyLoaded === !!configEnvResolved.config);
680
665
  const configValueSource = {
681
- locationId,
666
+ ...configValueSourceCommon,
682
667
  configEnv: configEnvResolved,
683
668
  valueIsImportedAtRuntime: !valueAlreadyLoaded,
684
669
  valueIsDefinedByPlusFile: true,
@@ -692,7 +677,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
692
677
  }
693
678
  };
694
679
  if (valueAlreadyLoaded) {
695
- configValueSource.value = conf.configValue;
680
+ configValueSource.value = confVal.configValue;
696
681
  }
697
682
  return configValueSource;
698
683
  }
@@ -700,7 +685,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
700
685
  }
701
686
  function isDefiningPage(interfaceFiles) {
702
687
  for (const interfaceFile of interfaceFiles) {
703
- const configNames = Object.keys(interfaceFile.fileExportsByConfigName);
688
+ const configNames = getDefiningConfigNames(interfaceFile);
704
689
  if (configNames.some((configName) => isDefiningPageConfig(configName))) {
705
690
  return true;
706
691
  }
@@ -710,16 +695,28 @@ function isDefiningPage(interfaceFiles) {
710
695
  function isDefiningPageConfig(configName) {
711
696
  return ['Page', 'route'].includes(configName);
712
697
  }
698
+ function getDefiningConfigNames(interfaceFile) {
699
+ let configNames = [];
700
+ if (interfaceFile.isValueFile) {
701
+ configNames.push(interfaceFile.configName);
702
+ }
703
+ if (interfaceFile.isValueLoaded) {
704
+ configNames.push(...Object.keys(interfaceFile.fileExportsByConfigName));
705
+ }
706
+ configNames = unique(configNames);
707
+ return configNames;
708
+ }
713
709
  function getConfigDefinitions(interfaceFilesRelevant) {
714
710
  const configDefinitionsMerged = { ...configDefinitionsBuiltIn };
715
711
  Object.entries(interfaceFilesRelevant)
716
712
  .reverse()
717
713
  .forEach(([_locationId, interfaceFiles]) => {
718
714
  interfaceFiles.forEach((interfaceFile) => {
719
- const configMeta = interfaceFile.fileExportsByConfigName['meta'];
720
- if (!configMeta)
715
+ const confVal = getConfVal(interfaceFile, 'meta');
716
+ if (!confVal)
721
717
  return;
722
- const meta = configMeta.configValue;
718
+ assert(confVal.configValueLoaded);
719
+ const meta = confVal.configValue;
723
720
  assertMetaUsage(meta, `Config ${pc.cyan('meta')} defined at ${interfaceFile.filePath.filePathToShowToUser}`);
724
721
  // Set configDef._userEffectDefinedAtFilePath
725
722
  Object.entries(meta).forEach(([configName, configDef]) => {
@@ -1036,16 +1033,28 @@ function getConfigDefinition(configDefinitions, configName, filePathToShowToUser
1036
1033
  function getConfigDefinitionOptional(configDefinitions, configName) {
1037
1034
  return configDefinitions[configName] ?? null;
1038
1035
  }
1039
- function isLoadableAtBuildTime(configDef) {
1036
+ function shouldBeLoadableAtBuildTime(configDef) {
1040
1037
  return !!configDef.env.config && !configDef._valueIsFilePath;
1041
1038
  }
1042
- function isGlobalConfig(configName) {
1039
+ // TODO/now: remove
1040
+ function isGlobalConfigOld(configName) {
1043
1041
  // TODO/now
1044
1042
  if (configName === 'prerender')
1045
1043
  return false;
1046
1044
  const configNamesGlobal = getConfigNamesGlobal();
1047
1045
  return includes(configNamesGlobal, configName);
1048
1046
  }
1047
+ // TODO/now
1048
+ function isGlobalConfig(configName, configDefinitions, value) {
1049
+ const configSpec = configDefinitions[configName];
1050
+ assert(configSpec);
1051
+ const globalValue = configSpec.global;
1052
+ if (!globalValue)
1053
+ return false;
1054
+ if (globalValue === true)
1055
+ return true;
1056
+ return globalValue(value);
1057
+ }
1049
1058
  function getConfigNamesGlobal() {
1050
1059
  return Object.keys(configDefinitionsBuiltInGlobal);
1051
1060
  }
@@ -1078,38 +1087,12 @@ function sortConfigValueSources(configValueSources, locationIdPage) {
1078
1087
  // Sort after the filesystem inheritance of the config value
1079
1088
  .sort(([, [source1]], [, [source2]]) => reverse(sortAfterInheritanceOrder(source1.locationId, source2.locationId, locationIdPage))));
1080
1089
  }
1081
- function getConfigValueInterfaceFile(interfaceFile, configName) {
1082
- return interfaceFile.fileExportsByConfigName[configName]?.configValue;
1083
- }
1084
- // TODO/now: refactor code below
1085
- function resolveVikeConfigGlobal(vikeVitePluginOptions, pageConfigGlobalValues) {
1086
- const configs = [vikeVitePluginOptions, pageConfigGlobalValues];
1087
- const vikeConfigGlobal = {
1088
- disableAutoFullBuild: pickFirst(configs.map((c) => c.disableAutoFullBuild)) ?? null,
1089
- prerender: resolvePrerenderOptions(configs),
1090
- includeAssetsImportedByServer: pickFirst(configs.map((c) => c.includeAssetsImportedByServer)) ?? true,
1091
- baseServer: pickFirst(configs.map((c) => c.baseServer)) ?? null,
1092
- baseAssets: pickFirst(configs.map((c) => c.baseAssets)) ?? null,
1093
- disableUrlNormalization: pickFirst(configs.map((c) => c.disableUrlNormalization)) ?? false,
1094
- trailingSlash: pickFirst(configs.map((c) => c.trailingSlash)) ?? false
1095
- };
1096
- return vikeConfigGlobal;
1097
- }
1098
- function resolvePrerenderOptions(configs) {
1099
- if (!configs.some((c) => c.prerender)) {
1100
- return false;
1101
- }
1102
- const configsPrerender = configs.map((c) => c.prerender).filter(isObject2);
1103
- return {
1104
- partial: pickFirst(configsPrerender.map((c) => c.partial)) ?? false,
1105
- noExtraDir: pickFirst(configsPrerender.map((c) => c.noExtraDir)) ?? false,
1106
- parallel: pickFirst(configsPrerender.map((c) => c.parallel)) ?? true,
1107
- disableAutoRun: pickFirst(configsPrerender.map((c) => c.disableAutoRun)) ?? false
1108
- };
1109
- }
1110
- function isObject2(p) {
1111
- return typeof p === 'object';
1112
- }
1113
- function pickFirst(arr) {
1114
- return arr.filter((v) => v !== undefined)[0];
1090
+ function getConfVal(interfaceFile, configName) {
1091
+ const configNames = getDefiningConfigNames(interfaceFile);
1092
+ if (!configNames.includes(configName))
1093
+ return null;
1094
+ if (!interfaceFile.isValueLoaded)
1095
+ return { configValueLoaded: false };
1096
+ const confVal = { configValue: interfaceFile.fileExportsByConfigName[configName], configValueLoaded: true };
1097
+ return confVal;
1115
1098
  }