vike 0.4.144-commit-756f5d7 → 0.4.144-commit-f7ab002

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 (82) hide show
  1. package/dist/cjs/node/plugin/plugins/buildConfig.js +2 -2
  2. package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +5 -5
  3. package/dist/cjs/node/plugin/plugins/importBuild/index.js +3 -3
  4. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +4 -3
  5. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +12 -12
  6. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +152 -152
  7. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +2 -2
  8. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +13 -5
  9. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/helpers.js +1 -14
  10. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.js +2 -4
  11. package/dist/cjs/node/plugin/plugins/previewConfig.js +6 -2
  12. package/dist/cjs/node/prerender/runPrerender.js +8 -8
  13. package/dist/cjs/node/runtime/html/serializePageContextClientSide.js +19 -6
  14. package/dist/cjs/node/runtime/renderPage/log404/index.js +27 -17
  15. package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +2 -2
  16. package/dist/cjs/node/shared/getClientEntryFilePath.js +2 -2
  17. package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +4 -6
  18. package/dist/cjs/shared/getPageFiles/getExports.js +3 -3
  19. package/dist/cjs/shared/hooks/getHook.js +1 -1
  20. package/dist/cjs/shared/page-configs/getExportPath.js +3 -3
  21. package/dist/cjs/shared/page-configs/helpers/getConfigDefinedAtString.js +43 -0
  22. package/dist/cjs/shared/page-configs/helpers/getConfigValue.js +44 -0
  23. package/dist/cjs/shared/page-configs/helpers.js +33 -0
  24. package/dist/cjs/shared/page-configs/loadConfigValues.js +2 -2
  25. package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +6 -8
  26. package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +2 -2
  27. package/dist/cjs/shared/page-configs/serialize/serializeConfigValue.js +9 -10
  28. package/dist/cjs/shared/route/abort.js +1 -1
  29. package/dist/cjs/shared/route/loadPageRoutes.js +11 -10
  30. package/dist/cjs/utils/projectInfo.js +1 -1
  31. package/dist/cjs/utils/truncateString.js +12 -7
  32. package/dist/esm/client/client-routing-runtime/getPageContext.js +1 -1
  33. package/dist/esm/node/plugin/plugins/buildConfig.js +1 -1
  34. package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +5 -5
  35. package/dist/esm/node/plugin/plugins/importBuild/index.js +3 -3
  36. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +2 -1
  37. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +4 -3
  38. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts +1 -1
  39. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +12 -12
  40. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +152 -152
  41. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +1 -1
  42. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +14 -6
  43. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/helpers.js +1 -14
  44. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.d.ts +2 -2
  45. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.js +2 -4
  46. package/dist/esm/node/plugin/plugins/previewConfig.js +6 -2
  47. package/dist/esm/node/prerender/runPrerender.js +2 -2
  48. package/dist/esm/node/runtime/html/serializePageContextClientSide.js +20 -7
  49. package/dist/esm/node/runtime/renderPage/log404/index.d.ts +2 -2
  50. package/dist/esm/node/runtime/renderPage/log404/index.js +27 -16
  51. package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +1 -1
  52. package/dist/esm/node/shared/getClientEntryFilePath.js +1 -1
  53. package/dist/esm/shared/getPageFiles/analyzeClientSide.js +2 -4
  54. package/dist/esm/shared/getPageFiles/getExports.js +2 -2
  55. package/dist/esm/shared/hooks/getHook.js +1 -1
  56. package/dist/esm/shared/page-configs/PageConfig.d.ts +53 -31
  57. package/dist/esm/shared/page-configs/getExportPath.d.ts +1 -1
  58. package/dist/esm/shared/page-configs/getExportPath.js +3 -3
  59. package/dist/esm/shared/page-configs/helpers/getConfigDefinedAtString.d.ts +7 -0
  60. package/dist/esm/shared/page-configs/helpers/getConfigDefinedAtString.js +37 -0
  61. package/dist/esm/shared/page-configs/helpers/getConfigValue.d.ts +14 -0
  62. package/dist/esm/shared/page-configs/helpers/getConfigValue.js +38 -0
  63. package/dist/esm/shared/page-configs/helpers.d.ts +13 -0
  64. package/dist/esm/shared/page-configs/helpers.js +27 -0
  65. package/dist/esm/shared/page-configs/loadConfigValues.js +2 -2
  66. package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.d.ts +4 -4
  67. package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +6 -8
  68. package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +2 -2
  69. package/dist/esm/shared/page-configs/serialize/serializeConfigValue.js +9 -10
  70. package/dist/esm/shared/route/abort.js +1 -1
  71. package/dist/esm/shared/route/loadPageRoutes.js +8 -7
  72. package/dist/esm/utils/projectInfo.d.ts +1 -1
  73. package/dist/esm/utils/projectInfo.js +1 -1
  74. package/dist/esm/utils/truncateString.d.ts +2 -1
  75. package/dist/esm/utils/truncateString.js +10 -7
  76. package/package.json +2 -2
  77. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.js +0 -16
  78. package/dist/cjs/shared/page-configs/utils.js +0 -103
  79. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.d.ts +0 -24
  80. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.js +0 -13
  81. package/dist/esm/shared/page-configs/utils.d.ts +0 -35
  82. package/dist/esm/shared/page-configs/utils.js +0 -97
@@ -15,9 +15,8 @@ const isConfigInvalid_js_1 = require("../../../../runtime/renderPage/isConfigInv
15
15
  const globalContext_js_1 = require("../../../../runtime/globalContext.js");
16
16
  const loggerNotProd_js_1 = require("../../../shared/loggerNotProd.js");
17
17
  const removeSuperfluousViteLog_js_1 = require("../../../shared/loggerVite/removeSuperfluousViteLog.js");
18
- const getFilePathToShowToUser_js_1 = require("./getFilePathToShowToUser.js");
19
18
  const picocolors_1 = __importDefault(require("@brillout/picocolors"));
20
- const utils_js_2 = require("../../../../../shared/page-configs/utils.js");
19
+ const helpers_js_1 = require("../../../../../shared/page-configs/helpers.js");
21
20
  const assertExports_js_1 = require("../../../../../shared/page-configs/assertExports.js");
22
21
  const getVirtualFilePageConfigs_js_1 = require("./getVirtualFilePageConfigs.js");
23
22
  (0, utils_js_1.assertIsNotProductionRuntime)();
@@ -77,7 +76,7 @@ async function loadInterfaceFiles(userRootDir, outDirRoot, isDev, extensions) {
77
76
  const configFiles = [];
78
77
  const valueFiles = [];
79
78
  plusFiles.forEach((f) => {
80
- if (getConfigName(f.filePathRelativeToUserRootDir) === 'config') {
79
+ if (getConfigName(f.filePathAbsoluteFilesystem) === 'config') {
81
80
  configFiles.push(f);
82
81
  }
83
82
  else {
@@ -86,15 +85,10 @@ async function loadInterfaceFiles(userRootDir, outDirRoot, isDev, extensions) {
86
85
  });
87
86
  let interfaceFilesByLocationId = {};
88
87
  // Config files
89
- await Promise.all(configFiles.map(async ({ filePathAbsoluteFilesystem, filePathRelativeToUserRootDir }) => {
90
- const configFilePath = {
91
- filePathAbsoluteFilesystem: filePathAbsoluteFilesystem,
92
- filePathRelativeToUserRootDir: filePathRelativeToUserRootDir,
93
- importPathAbsolute: null
94
- };
95
- const { configFile, extendsConfigs } = await loadConfigFile(configFilePath, userRootDir, []);
88
+ await Promise.all(configFiles.map(async (filePath) => {
89
+ const { configFile, extendsConfigs } = await loadConfigFile(filePath, userRootDir, []);
96
90
  const interfaceFile = getInterfaceFileFromConfigFile(configFile, false);
97
- const locationId = (0, filesystemRouting_js_1.getLocationId)(filePathRelativeToUserRootDir);
91
+ const locationId = (0, filesystemRouting_js_1.getLocationId)(filePath.filePathAbsoluteVite);
98
92
  interfaceFilesByLocationId[locationId] = interfaceFilesByLocationId[locationId] ?? [];
99
93
  interfaceFilesByLocationId[locationId].push(interfaceFile);
100
94
  extendsConfigs.forEach((extendsConfig) => {
@@ -103,15 +97,11 @@ async function loadInterfaceFiles(userRootDir, outDirRoot, isDev, extensions) {
103
97
  });
104
98
  }));
105
99
  // Value files
106
- await Promise.all(valueFiles.map(async ({ filePathAbsoluteFilesystem, filePathRelativeToUserRootDir }) => {
107
- const configName = getConfigName(filePathRelativeToUserRootDir);
100
+ await Promise.all(valueFiles.map(async (filePath) => {
101
+ const configName = getConfigName(filePath.filePathAbsoluteVite);
108
102
  (0, utils_js_1.assert)(configName);
109
103
  const interfaceFile = {
110
- filePath: {
111
- filePathRelativeToUserRootDir,
112
- filePathAbsoluteFilesystem,
113
- importPathAbsolute: null
114
- },
104
+ filePath,
115
105
  configMap: {
116
106
  [configName]: {}
117
107
  },
@@ -129,16 +119,16 @@ async function loadInterfaceFiles(userRootDir, outDirRoot, isDev, extensions) {
129
119
  }
130
120
  }
131
121
  {
132
- const locationId = (0, filesystemRouting_js_1.getLocationId)(filePathRelativeToUserRootDir);
122
+ const locationId = (0, filesystemRouting_js_1.getLocationId)(filePath.filePathAbsoluteVite);
133
123
  interfaceFilesByLocationId[locationId] = interfaceFilesByLocationId[locationId] ?? [];
134
124
  interfaceFilesByLocationId[locationId].push(interfaceFile);
135
125
  }
136
126
  }));
137
127
  return interfaceFilesByLocationId;
138
128
  }
139
- function getConfigDefinition(configDefinitionsRelevant, configName, definedByFile) {
129
+ function getConfigDefinition(configDefinitionsRelevant, configName, filePathToShowToUser) {
140
130
  const configDef = configDefinitionsRelevant[configName];
141
- assertConfigExists(configName, Object.keys(configDefinitionsRelevant), definedByFile);
131
+ assertConfigExists(configName, Object.keys(configDefinitionsRelevant), filePathToShowToUser);
142
132
  (0, utils_js_1.assert)(configDef);
143
133
  return configDef;
144
134
  }
@@ -147,7 +137,7 @@ function getConfigDefinitionOptional(configDefinitions, configName) {
147
137
  }
148
138
  async function loadValueFile(interfaceValueFile, configName, userRootDir) {
149
139
  const { fileExports } = await (0, transpileAndExecuteFile_js_1.transpileAndExecuteFile)(interfaceValueFile.filePath, true, userRootDir);
150
- const filePathToShowToUser = (0, getFilePathToShowToUser_js_1.getFilePathToShowToUser)(interfaceValueFile.filePath);
140
+ const { filePathToShowToUser } = interfaceValueFile.filePath;
151
141
  (0, assertExports_js_1.assertExportsOfValueFile)(fileExports, filePathToShowToUser, configName);
152
142
  Object.entries(fileExports).forEach(([exportName, configValue]) => {
153
143
  const configName_ = exportName === 'default' ? configName : exportName;
@@ -164,7 +154,7 @@ function getInterfaceFileFromConfigFile(configFile, isConfigExtend) {
164
154
  isConfigExtend,
165
155
  extendsFilePaths
166
156
  };
167
- const filePathToShowToUser = (0, getFilePathToShowToUser_js_1.getFilePathToShowToUser)(filePath);
157
+ const { filePathToShowToUser } = filePath;
168
158
  (0, assertExports_js_1.assertExportsOfConfigFile)(fileExports, filePathToShowToUser);
169
159
  Object.entries(fileExports.default).forEach(([configName, configValue]) => {
170
160
  interfaceFile.configMap[configName] = { configValue };
@@ -227,7 +217,7 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev, extensions) {
227
217
  const { configName } = interfaceFile;
228
218
  if (isGlobalConfig(configName))
229
219
  return;
230
- const configDef = getConfigDefinition(configDefinitionsRelevant, configName, (0, getFilePathToShowToUser_js_1.getFilePathToShowToUser)(interfaceFile.filePath));
220
+ const configDef = getConfigDefinition(configDefinitionsRelevant, configName, interfaceFile.filePath.filePathToShowToUser);
231
221
  if (configDef.env !== 'config-only')
232
222
  return;
233
223
  const isAlreadyLoaded = interfacefileIsAlreaydLoaded(interfaceFile);
@@ -266,7 +256,7 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev, extensions) {
266
256
  const configDefinitionsRelevant = getConfigDefinitions(interfaceFilesRelevant);
267
257
  interfaceFiles.forEach((interfaceFile) => {
268
258
  Object.keys(interfaceFile.configMap).forEach((configName) => {
269
- assertConfigExists(configName, Object.keys(configDefinitionsRelevant), (0, getFilePathToShowToUser_js_1.getFilePathToShowToUser)(interfaceFile.filePath));
259
+ assertConfigExists(configName, Object.keys(configDefinitionsRelevant), interfaceFile.filePath.filePathToShowToUser);
270
260
  });
271
261
  });
272
262
  });
@@ -317,7 +307,7 @@ function getGlobalConfigs(interfaceFilesByLocationId, userRootDir) {
317
307
  Object.keys(interfaceFile.configMap).forEach((configName) => {
318
308
  if (!(0, filesystemRouting_js_1.isGlobalLocation)(locationId, locationIds) && isGlobalConfig(configName)) {
319
309
  (0, utils_js_1.assertUsage)(false, [
320
- `${(0, getFilePathToShowToUser_js_1.getFilePathToShowToUser)(interfaceFile.filePath)} defines the config ${picocolors_1.default.cyan(configName)} which is global:`,
310
+ `${interfaceFile.filePath.filePathToShowToUser} defines the config ${picocolors_1.default.cyan(configName)} which is global:`,
321
311
  globalPaths.length
322
312
  ? `define ${picocolors_1.default.cyan(configName)} in ${(0, utils_js_1.joinEnglish)(globalPaths, 'or')} instead`
323
313
  : `create a global config (e.g. /pages/+config.js) and define ${picocolors_1.default.cyan(configName)} there instead`
@@ -344,9 +334,8 @@ function getGlobalConfigs(interfaceFilesByLocationId, userRootDir) {
344
334
  (0, utils_js_1.assert)('value' in configValueSource);
345
335
  if (configName === 'prerender' && typeof configValueSource.value === 'boolean')
346
336
  return;
347
- const sourceFilePath = getDefinedAtFilePathToShowToUser(configValueSource.definedAtInfo);
348
- (0, utils_js_1.assert)(sourceFilePath);
349
- (0, utils_js_1.assertWarning)(false, `Being able to define config ${picocolors_1.default.cyan(configName)} in ${sourceFilePath} is experimental and will likely be removed. Define the config ${picocolors_1.default.cyan(configName)} in Vike's Vite plugin options instead.`, { onlyOnce: true });
337
+ const { filePathToShowToUser } = configValueSource.definedAt;
338
+ (0, utils_js_1.assertWarning)(false, `Being able to define config ${picocolors_1.default.cyan(configName)} in ${filePathToShowToUser} is experimental and will likely be removed. Define the config ${picocolors_1.default.cyan(configName)} in Vike's Vite plugin options instead.`, { onlyOnce: true });
350
339
  globalVikeConfig[configName] = configValueSource.value;
351
340
  }
352
341
  });
@@ -427,9 +416,14 @@ function makeOrderDeterministic(interfaceFile1, interfaceFile2) {
427
416
  }
428
417
  function warnOverridenConfigValues(interfaceFileWinner, interfaceFilesOverriden, configName, configDef, userRootDir) {
429
418
  interfaceFilesOverriden.forEach((interfaceFileLoser) => {
419
+ const configValueSourceLoser_ = getConfigValueSource(configName, interfaceFileLoser, configDef, userRootDir);
430
420
  const configValueSourceWinner = getConfigValueSource(configName, interfaceFileWinner, configDef, userRootDir);
431
- const configValueSourceLoser = getConfigValueSource(configName, interfaceFileLoser, configDef, userRootDir);
432
- (0, utils_js_1.assertWarning)(false, `${getConfigSourceDefinedAtString(configName, configValueSourceLoser, undefined, true)} overriden by another ${getConfigSourceDefinedAtString(configName, configValueSourceWinner, undefined, false)}, remove one of the two`, { onlyOnce: false });
421
+ // prettier-ignore
422
+ const configLoser_DefinedAt = (0, helpers_js_1.getConfigDefinedAtString)('Config', configName, configValueSourceLoser_);
423
+ // prettier-ignore
424
+ const configWinnerDefinedAt = (0, helpers_js_1.getConfigDefinedAtString)('config', configName, configValueSourceWinner);
425
+ const errMsg = `${configLoser_DefinedAt} is overriden by another ${configWinnerDefinedAt}, remove one of the two`;
426
+ (0, utils_js_1.assertWarning)(false, errMsg, { onlyOnce: false });
433
427
  });
434
428
  }
435
429
  function isInterfaceFileUserLand(interfaceFile) {
@@ -441,25 +435,25 @@ function getConfigValueSource(configName, interfaceFile, configDef, userRootDir)
441
435
  const configEnv = configDef.env;
442
436
  const definedAtConfigFile = {
443
437
  ...interfaceFile.filePath,
444
- fileExportPath: ['default', configName]
438
+ fileExportPathToShowToUser: ['default', configName]
445
439
  };
446
440
  if (configDef._valueIsFilePath) {
447
- let definedAtInfo;
441
+ let definedAt;
448
442
  let valueFilePath;
449
443
  if (interfaceFile.isConfigFile) {
450
444
  const { configValue } = conf;
451
445
  const import_ = resolveImport(configValue, interfaceFile.filePath, userRootDir, configEnv, configName);
452
- const configDefinedAt = getConfigSourceDefinedAtString(configName, { definedAtInfo: definedAtConfigFile });
446
+ const configDefinedAt = (0, helpers_js_1.getConfigDefinedAtString)('Config', configName, { definedAt: definedAtConfigFile });
453
447
  (0, utils_js_1.assertUsage)(import_, `${configDefinedAt} should be an import`);
454
- valueFilePath = import_.filePathRelativeToUserRootDir ?? import_.importPathAbsolute;
455
- definedAtInfo = import_;
448
+ valueFilePath = import_.filePathAbsoluteVite;
449
+ definedAt = import_;
456
450
  }
457
451
  else {
458
452
  (0, utils_js_1.assert)(interfaceFile.isValueFile);
459
- valueFilePath = interfaceFile.filePath.filePathRelativeToUserRootDir;
460
- definedAtInfo = {
453
+ valueFilePath = interfaceFile.filePath.filePathAbsoluteVite;
454
+ definedAt = {
461
455
  ...interfaceFile.filePath,
462
- fileExportPath: []
456
+ fileExportPathToShowToUser: []
463
457
  };
464
458
  }
465
459
  const configValueSource = {
@@ -467,7 +461,7 @@ function getConfigValueSource(configName, interfaceFile, configDef, userRootDir)
467
461
  valueIsFilePath: true,
468
462
  configEnv,
469
463
  valueIsImportedAtRuntime: true,
470
- definedAtInfo
464
+ definedAt
471
465
  };
472
466
  return configValueSource;
473
467
  }
@@ -479,7 +473,7 @@ function getConfigValueSource(configName, interfaceFile, configDef, userRootDir)
479
473
  const configValueSource = {
480
474
  configEnv,
481
475
  valueIsImportedAtRuntime: true,
482
- definedAtInfo: import_
476
+ definedAt: import_
483
477
  };
484
478
  return configValueSource;
485
479
  }
@@ -488,7 +482,7 @@ function getConfigValueSource(configName, interfaceFile, configDef, userRootDir)
488
482
  value: configValue,
489
483
  configEnv,
490
484
  valueIsImportedAtRuntime: false,
491
- definedAtInfo: definedAtConfigFile
485
+ definedAt: definedAtConfigFile
492
486
  };
493
487
  return configValueSource;
494
488
  }
@@ -498,9 +492,9 @@ function getConfigValueSource(configName, interfaceFile, configDef, userRootDir)
498
492
  const configValueSource = {
499
493
  configEnv,
500
494
  valueIsImportedAtRuntime: !valueAlreadyLoaded,
501
- definedAtInfo: {
495
+ definedAt: {
502
496
  ...interfaceFile.filePath,
503
- fileExportPath: configName === interfaceFile.configName
497
+ fileExportPathToShowToUser: configName === interfaceFile.configName
504
498
  ? []
505
499
  : // Side-effect config (e.g. `export { frontmatter }` of .md files)
506
500
  [configName]
@@ -553,7 +547,7 @@ function resolveImport(configValue, importerFilePath, userRootDir, configEnv, co
553
547
  const { importPath, exportName } = importData;
554
548
  const filePathAbsoluteFilesystem = resolveImportPath(importData, importerFilePath);
555
549
  assertFileEnv(filePathAbsoluteFilesystem ?? importPath, configEnv, configName);
556
- const fileExportPath = exportName === 'default' || exportName === configName ? [] : [exportName];
550
+ const fileExportPathToShowToUser = exportName === 'default' || exportName === configName ? [] : [exportName];
557
551
  if (importPath.startsWith('.')) {
558
552
  // We need to resolve relative paths into absolute paths. Because the import paths are included in virtual files:
559
553
  // ```
@@ -561,25 +555,35 @@ function resolveImport(configValue, importerFilePath, userRootDir, configEnv, co
561
555
  // ```
562
556
  assertImportPath(filePathAbsoluteFilesystem, importData, importerFilePath);
563
557
  const filePathRelativeToUserRootDir = resolveImportPath_relativeToUserRootDir(filePathAbsoluteFilesystem, importData, importerFilePath, userRootDir);
564
- return {
565
- exportName,
566
- fileExportPath,
558
+ const filePath = {
567
559
  filePathAbsoluteFilesystem,
568
560
  filePathRelativeToUserRootDir,
561
+ filePathAbsoluteVite: filePathRelativeToUserRootDir,
562
+ filePathToShowToUser: filePathRelativeToUserRootDir,
569
563
  importPathAbsolute: null
570
564
  };
565
+ return {
566
+ ...filePath,
567
+ fileExportName: exportName,
568
+ fileExportPathToShowToUser
569
+ };
571
570
  }
572
571
  else {
573
572
  // importPath can be:
574
573
  // - an npm package import
575
574
  // - a path alias
576
- return {
577
- exportName,
578
- fileExportPath,
575
+ const filePath = {
579
576
  filePathAbsoluteFilesystem,
580
577
  filePathRelativeToUserRootDir: null,
578
+ filePathAbsoluteVite: importPath,
579
+ filePathToShowToUser: importPath,
581
580
  importPathAbsolute: importPath
582
581
  };
582
+ return {
583
+ ...filePath,
584
+ fileExportName: exportName,
585
+ fileExportPathToShowToUser
586
+ };
583
587
  }
584
588
  }
585
589
  function resolveImportPath_relativeToUserRootDir(filePathAbsoluteFilesystem, importData, configFilePath, userRootDir) {
@@ -589,7 +593,7 @@ function resolveImportPath_relativeToUserRootDir(filePathAbsoluteFilesystem, imp
589
593
  filePathRelativeToUserRootDir = getVitePathFromAbsolutePath(filePathAbsoluteFilesystem, userRootDir);
590
594
  }
591
595
  else {
592
- (0, utils_js_1.assertUsage)(false, `${(0, getFilePathToShowToUser_js_1.getFilePathToShowToUser)(configFilePath)} imports from a relative path ${picocolors_1.default.cyan(importData.importPath)} outside of ${userRootDir} which is forbidden: import from a relative path inside ${userRootDir}, or import from a dependency's package.json#exports entry instead`);
596
+ (0, utils_js_1.assertUsage)(false, `${configFilePath.filePathToShowToUser} imports from a relative path ${picocolors_1.default.cyan(importData.importPath)} outside of ${userRootDir} which is forbidden: import from a relative path inside ${userRootDir}, or import from a dependency's package.json#exports entry instead`);
593
597
  // None of the following works. Seems to be a Vite bug?
594
598
  // /*
595
599
  // assert(filePathAbsoluteFilesystem.startsWith('/'))
@@ -621,9 +625,17 @@ function getConfigDefinitions(interfaceFilesRelevant) {
621
625
  if (!configMeta)
622
626
  return;
623
627
  const meta = configMeta.configValue;
624
- assertMetaValue(meta,
625
- // Maybe we should use the getConfigDefinedAtString() helper?
626
- `Config ${picocolors_1.default.cyan('meta')} defined at ${(0, getFilePathToShowToUser_js_1.getFilePathToShowToUser)(interfaceFile.filePath)}`);
628
+ assertMetaValue(meta, `Config ${picocolors_1.default.cyan('meta')} defined at ${interfaceFile.filePath.filePathToShowToUser}`);
629
+ // Set configDef._userEffectDefinedAt
630
+ Object.entries(meta).forEach(([configName, configDef]) => {
631
+ if (!configDef.effect)
632
+ return;
633
+ (0, utils_js_1.assert)(interfaceFile.isConfigFile);
634
+ configDef._userEffectDefinedAt = {
635
+ ...interfaceFile.filePath,
636
+ fileExportPathToShowToUser: ['default', 'meta', configName, 'effect']
637
+ };
638
+ });
627
639
  (0, utils_js_1.objectEntries)(meta).forEach(([configName, configDefinition]) => {
628
640
  // User can override an existing config definition
629
641
  configDefinitions[configName] = {
@@ -636,9 +648,15 @@ function getConfigDefinitions(interfaceFilesRelevant) {
636
648
  return configDefinitions;
637
649
  }
638
650
  function assertMetaValue(metaVal, configMetaDefinedAt) {
639
- (0, utils_js_1.assertUsage)((0, utils_js_1.isObject)(metaVal), `${configMetaDefinedAt} has an invalid type ${picocolors_1.default.cyan(typeof metaVal)}: it should be an object instead.`);
651
+ if (!(0, utils_js_1.isObject)(metaVal)) {
652
+ (0, utils_js_1.assert)(configMetaDefinedAt); // We expect internal effects to return a valid meta value
653
+ (0, utils_js_1.assertUsage)(false, `${configMetaDefinedAt} has an invalid type ${picocolors_1.default.cyan(typeof metaVal)}: it should be an object instead.`);
654
+ }
640
655
  (0, utils_js_1.objectEntries)(metaVal).forEach(([configName, def]) => {
641
- (0, utils_js_1.assertUsage)((0, utils_js_1.isObject)(def), `${configMetaDefinedAt} sets meta.${configName} to a value with an invalid type ${picocolors_1.default.cyan(typeof def)}: it should be an object instead.`);
656
+ if (!(0, utils_js_1.isObject)(def)) {
657
+ (0, utils_js_1.assert)(configMetaDefinedAt); // We expect internal effects to return a valid meta value
658
+ (0, utils_js_1.assertUsage)(false, `${configMetaDefinedAt} sets ${picocolors_1.default.cyan(`meta.${configName}`)} to a value with an invalid type ${picocolors_1.default.cyan(typeof def)}: it should be an object instead.`);
659
+ }
642
660
  // env
643
661
  {
644
662
  const envValues = [
@@ -647,19 +665,34 @@ function assertMetaValue(metaVal, configMetaDefinedAt) {
647
665
  'server-and-client',
648
666
  'config-only'
649
667
  ];
650
- const hint = [
651
- `Set the value of ${picocolors_1.default.cyan('env')} to `,
668
+ const fix = [
669
+ `Set the value of ${picocolors_1.default.cyan(`meta.${configName}.env`)} to `,
652
670
  (0, utils_js_1.joinEnglish)(envValues.map((s) => picocolors_1.default.cyan(`'${s}'`)), 'or'),
653
671
  '.'
654
672
  ].join('');
655
- (0, utils_js_1.assertUsage)('env' in def, `${configMetaDefinedAt} doesn't set meta.${configName}.env but it's required. ${hint}`);
656
- (0, utils_js_1.assertUsage)((0, utils_js_1.hasProp)(def, 'env', 'string'), `${configMetaDefinedAt} sets meta.${configName}.env to an invalid type ${picocolors_1.default.cyan(typeof def.env)}. ${hint}`);
657
- (0, utils_js_1.assertUsage)(envValues.includes(def.env), `${configMetaDefinedAt} sets meta.${configName}.env to an invalid value ${picocolors_1.default.cyan(`'${def.env}'`)}. ${hint}`);
673
+ if (!('env' in def)) {
674
+ (0, utils_js_1.assert)(configMetaDefinedAt); // We expect internal effects to return a valid meta value
675
+ (0, utils_js_1.assertUsage)(false, `${configMetaDefinedAt} doesn't set ${picocolors_1.default.cyan(`meta.${configName}.env`)} but it's required. ${fix}`);
676
+ }
677
+ if (!(0, utils_js_1.hasProp)(def, 'env', 'string')) {
678
+ (0, utils_js_1.assert)(configMetaDefinedAt); // We expect internal effects to return a valid meta value
679
+ (0, utils_js_1.assertUsage)(false, `${configMetaDefinedAt} sets ${picocolors_1.default.cyan(`meta.${configName}.env`)} to an invalid type ${picocolors_1.default.cyan(typeof def.env)}. ${fix}`);
680
+ }
681
+ if (!envValues.includes(def.env)) {
682
+ (0, utils_js_1.assert)(configMetaDefinedAt); // We expect internal effects to return a valid meta value
683
+ (0, utils_js_1.assertUsage)(false, `${configMetaDefinedAt} sets ${picocolors_1.default.cyan(`meta.${configName}.env`)} to an unknown value ${picocolors_1.default.cyan(`'${def.env}'`)}. ${fix}`);
684
+ }
658
685
  }
659
686
  // effect
660
687
  if ('effect' in def) {
661
- (0, utils_js_1.assertUsage)((0, utils_js_1.hasProp)(def, 'effect', 'function'), `${configMetaDefinedAt} sets meta.${configName}.effect to an invalid type ${picocolors_1.default.cyan(typeof def.effect)}: it should be a function instead`);
662
- (0, utils_js_1.assertUsage)(def.env === 'config-only', `${configMetaDefinedAt} sets meta.${configName}.effect but it's only supported if meta.${configName}.env is ${picocolors_1.default.cyan('config-only')} (but it's ${picocolors_1.default.cyan(def.env)} instead)`);
688
+ if (!(0, utils_js_1.hasProp)(def, 'effect', 'function')) {
689
+ (0, utils_js_1.assert)(configMetaDefinedAt); // We expect internal effects to return a valid meta value
690
+ (0, utils_js_1.assertUsage)(false, `${configMetaDefinedAt} sets ${picocolors_1.default.cyan(`meta.${configName}.effect`)} to an invalid type ${picocolors_1.default.cyan(typeof def.effect)}: it should be a function instead`);
691
+ }
692
+ if (def.env !== 'config-only') {
693
+ (0, utils_js_1.assert)(configMetaDefinedAt); // We expect internal effects to return a valid meta value
694
+ (0, utils_js_1.assertUsage)(false, `${configMetaDefinedAt} sets ${picocolors_1.default.cyan(`meta.${configName}.effect`)} but it's only supported if meta.${configName}.env is ${picocolors_1.default.cyan('config-only')} (but it's ${picocolors_1.default.cyan(def.env)} instead)`);
695
+ }
663
696
  }
664
697
  });
665
698
  }
@@ -670,7 +703,7 @@ function applyEffectsAll(configValueSources, configDefinitionsRelevant) {
670
703
  // The value needs to be loaded at config time, that's why we only support effect for configs that are config-only for now.
671
704
  // (We could support effect for non config-only by always loading its value at config time, regardless of the config's `env` value.)
672
705
  (0, utils_js_1.assertUsage)(configDef.env === 'config-only', [
673
- `Cannot add effect to ${picocolors_1.default.cyan(configName)} because its ${picocolors_1.default.cyan('env')} is ${picocolors_1.default.cyan(configDef.env)}: effects can only be added to configs with an env that is ${picocolors_1.default.cyan('config-only')}.`
706
+ `Cannot add effect to ${picocolors_1.default.cyan(configName)} because its ${picocolors_1.default.cyan('env')} is ${picocolors_1.default.cyan(configDef.env)}: effects can only be added to configs with an ${picocolors_1.default.cyan('env')} value of ${picocolors_1.default.cyan('config-only')}.`
674
707
  ].join(' '));
675
708
  const source = configValueSources[configName]?.[0];
676
709
  if (!source)
@@ -680,19 +713,28 @@ function applyEffectsAll(configValueSources, configDefinitionsRelevant) {
680
713
  // Call effect
681
714
  const configModFromEffect = configDef.effect({
682
715
  configValue: source.value,
683
- configDefinedAt: getConfigSourceDefinedAtString(configName, source)
716
+ configDefinedAt: (0, helpers_js_1.getConfigDefinedAtString)('Config', configName, source)
684
717
  });
685
718
  if (!configModFromEffect)
686
719
  return;
687
720
  (0, utils_js_1.assert)((0, utils_js_1.hasProp)(source, 'value')); // We need to assume that the config value is loaded at build-time
688
- applyEffect(configModFromEffect, source, configValueSources);
721
+ applyEffect(configModFromEffect, configValueSources, configDef);
689
722
  });
690
723
  }
691
- function applyEffect(configModFromEffect, configValueEffectSource, configValueSources) {
724
+ function applyEffect(configModFromEffect, configValueSources, configDefEffect) {
692
725
  const notSupported = `Effects currently only supports modifying the the ${picocolors_1.default.cyan('env')} of a config.`;
693
726
  (0, utils_js_1.objectEntries)(configModFromEffect).forEach(([configName, configValue]) => {
694
727
  if (configName === 'meta') {
695
- assertMetaValue(configValue, getConfigSourceDefinedAtString(configName, configValueEffectSource, true));
728
+ let configDefinedAtString;
729
+ if (configDefEffect._userEffectDefinedAt) {
730
+ configDefinedAtString = (0, helpers_js_1.getConfigDefinedAtString)('Config', configName, {
731
+ definedAt: configDefEffect._userEffectDefinedAt
732
+ });
733
+ }
734
+ else {
735
+ configDefinedAtString = null;
736
+ }
737
+ assertMetaValue(configValue, configDefinedAtString);
696
738
  (0, utils_js_1.objectEntries)(configValue).forEach(([configTargetName, configTargetDef]) => {
697
739
  {
698
740
  const keys = Object.keys(configTargetDef);
@@ -710,7 +752,7 @@ function applyEffect(configModFromEffect, configValueEffectSource, configValueSo
710
752
  else {
711
753
  (0, utils_js_1.assertUsage)(false, notSupported);
712
754
  // If we do end implementing being able to set the value of a config:
713
- // - For setting definedAtInfo: we could take the definedAtInfo of the effect config while appending '(effect)' to definedAtInfo.fileExportPath
755
+ // - For setting definedAt: we could take the definedAt of the effect config while appending '(effect)' to definedAt.fileExportPathToShowToUser
714
756
  }
715
757
  });
716
758
  }
@@ -762,19 +804,28 @@ async function findPlusFiles(userRootDir, ignoreDirs, isDev, extensions) {
762
804
  p = (0, utils_js_1.toPosixPath)(p);
763
805
  const filePathRelativeToUserRootDir = path_1.default.posix.join('/', p);
764
806
  const filePathAbsoluteFilesystem = path_1.default.posix.join(userRootDir, p);
765
- return { filePathRelativeToUserRootDir, filePathAbsoluteFilesystem };
807
+ return {
808
+ filePathRelativeToUserRootDir,
809
+ filePathAbsoluteVite: filePathRelativeToUserRootDir,
810
+ filePathAbsoluteFilesystem,
811
+ filePathToShowToUser: filePathRelativeToUserRootDir,
812
+ importPathAbsolute: null
813
+ };
766
814
  });
815
+ // TODO/v1-release: remove
767
816
  extensions.forEach((extension) => {
768
817
  extension.pageConfigsDistFiles?.forEach((pageConfigDistFile) => {
769
- // TODO/v1-release: remove
770
818
  if (!pageConfigDistFile.importPath.includes('+'))
771
819
  return;
772
820
  (0, utils_js_1.assert)(pageConfigDistFile.importPath.includes('+'));
773
821
  (0, utils_js_1.assert)(path_1.default.posix.basename(pageConfigDistFile.importPath).startsWith('+'));
774
822
  const { importPath, filePath } = pageConfigDistFile;
775
823
  plusFiles.push({
776
- filePathRelativeToUserRootDir: importPath,
777
- filePathAbsoluteFilesystem: filePath
824
+ filePathRelativeToUserRootDir: null,
825
+ filePathAbsoluteVite: importPath,
826
+ filePathAbsoluteFilesystem: filePath,
827
+ filePathToShowToUser: importPath,
828
+ importPathAbsolute: importPath
778
829
  });
779
830
  });
780
831
  });
@@ -831,18 +882,18 @@ async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir
831
882
  const extendsConfigFiles = [];
832
883
  extendsImportData.map((importData) => {
833
884
  const { importPath: importPath } = importData;
834
- // TODO
835
- // - validate extends configs
836
885
  const filePathAbsoluteFilesystem = resolveImportPath(importData, configFilePath);
837
886
  assertImportPath(filePathAbsoluteFilesystem, importData, configFilePath);
838
887
  assertExtendsImportPath(importPath, filePathAbsoluteFilesystem, configFilePath);
839
888
  // - filePathRelativeToUserRootDir has no functionality beyond nicer error messages for user
840
889
  // - Using importPath would be visually nicer but it's ambigous => we rather pick filePathAbsoluteFilesystem for added clarity
841
890
  const filePathRelativeToUserRootDir = determineFilePathRelativeToUserDir(filePathAbsoluteFilesystem, userRootDir);
891
+ const filePathAbsoluteVite = filePathRelativeToUserRootDir ?? importPath;
842
892
  extendsConfigFiles.push({
843
893
  filePathAbsoluteFilesystem,
844
- // TODO: fix type cast
845
- filePathRelativeToUserRootDir: filePathRelativeToUserRootDir,
894
+ filePathAbsoluteVite,
895
+ filePathRelativeToUserRootDir,
896
+ filePathToShowToUser: filePathAbsoluteVite,
846
897
  importPathAbsolute: importPath
847
898
  });
848
899
  });
@@ -878,14 +929,14 @@ function assertExtendsImportPath(importPath, filePath, configFilePath) {
878
929
  });
879
930
  }
880
931
  else {
881
- (0, utils_js_1.assertWarning)(false, `${(0, getFilePathToShowToUser_js_1.getFilePathToShowToUser)(configFilePath)} uses ${picocolors_1.default.cyan('extends')} to inherit from ${picocolors_1.default.cyan(importPath)} which is a user-land file: this is experimental and may be remove at any time. Reach out to a maintainer if you need this feature.`, { onlyOnce: true });
932
+ (0, utils_js_1.assertWarning)(false, `${configFilePath.filePathToShowToUser} uses ${picocolors_1.default.cyan('extends')} to inherit from ${picocolors_1.default.cyan(importPath)} which is a user-land file: this is experimental and may be remove at any time. Reach out to a maintainer if you need this feature.`, { onlyOnce: true });
882
933
  }
883
934
  }
884
935
  function getExtendsImportData(configFileExports, configFilePath) {
885
- const filePathToShowToUser = (0, getFilePathToShowToUser_js_1.getFilePathToShowToUser)(configFilePath);
936
+ const { filePathToShowToUser } = configFilePath;
886
937
  (0, assertExports_js_1.assertExportsOfConfigFile)(configFileExports, filePathToShowToUser);
887
938
  const defaultExports = configFileExports.default;
888
- const wrongUsage = `${filePathToShowToUser} sets the config 'extends' to an invalid value, see https://vike.dev/extends`;
939
+ const wrongUsage = `${filePathToShowToUser} sets the config ${picocolors_1.default.cyan('extends')} to an invalid value, see https://vike.dev/extends`;
889
940
  let extendList;
890
941
  if (!('extends' in defaultExports)) {
891
942
  return [];
@@ -906,38 +957,6 @@ function getExtendsImportData(configFileExports, configFilePath) {
906
957
  });
907
958
  return extendsImportData;
908
959
  }
909
- // TODO: re-use this
910
- function handleUserFileError(err, isDev) {
911
- // Properly handle error during transpilation so that we can use assertUsage() during transpilation
912
- if (isDev) {
913
- throw err;
914
- }
915
- else {
916
- // Avoid ugly error format:
917
- // ```
918
- // [vike:importUserCode] Could not load virtual:vike:importUserCode:server: [vike@0.4.70][Wrong Usage] /pages/+config.ts sets the config 'onRenderHtml' to the value './+config/onRenderHtml-i-dont-exist.js' but no file was found at /home/rom/code/vike/examples/v1/pages/+config/onRenderHtml-i-dont-exist.js
919
- // Error: [vike@0.4.70][Wrong Usage] /pages/+config.ts sets the config 'onRenderHtml' to the value './+config/onRenderHtml-i-dont-exist.js' but no file was found at /home/rom/code/vike/examples/v1/pages/+config/onRenderHtml-i-dont-exist.js
920
- // at ...
921
- // at ...
922
- // at ...
923
- // at ...
924
- // at ...
925
- // at ...
926
- // code: 'PLUGIN_ERROR',
927
- // plugin: 'vike:importUserCode',
928
- // hook: 'load',
929
- // watchFiles: [
930
- // '/home/rom/code/vike/vike/dist/esm/node/importBuild.js',
931
- // '\x00virtual:vike:importUserCode:server'
932
- // ]
933
- // }
934
- //  ELIFECYCLE  Command failed with exit code 1.
935
- // ```
936
- console.log('');
937
- console.error(err);
938
- process.exit(1);
939
- }
940
- }
941
960
  function isGlobalConfig(configName) {
942
961
  if (configName === 'prerender')
943
962
  return false;
@@ -947,15 +966,15 @@ function isGlobalConfig(configName) {
947
966
  function getConfigNamesGlobal() {
948
967
  return Object.keys(configDefinitionsBuiltIn_js_1.configDefinitionsBuiltInGlobal);
949
968
  }
950
- function assertConfigExists(configName, configNamesRelevant, definedByFile) {
969
+ function assertConfigExists(configName, configNamesRelevant, filePathToShowToUser) {
951
970
  const configNames = [...configNamesRelevant, ...getConfigNamesGlobal()];
952
971
  if (configNames.includes(configName))
953
972
  return;
954
- handleUnknownConfig(configName, configNames, definedByFile);
973
+ handleUnknownConfig(configName, configNames, filePathToShowToUser);
955
974
  (0, utils_js_1.assert)(false);
956
975
  }
957
- function handleUnknownConfig(configName, configNames, definedByFile) {
958
- let errMsg = `${definedByFile} defines an unknown config ${picocolors_1.default.cyan(configName)}`;
976
+ function handleUnknownConfig(configName, configNames, filePathToShowToUser) {
977
+ let errMsg = `${filePathToShowToUser} defines an unknown config ${picocolors_1.default.cyan(configName)}`;
959
978
  let configNameSimilar = null;
960
979
  if (configName === 'page') {
961
980
  configNameSimilar = 'Page';
@@ -987,11 +1006,11 @@ function determineRouteFilesystem(locationId, configValueSources) {
987
1006
  if (configFilesystemRoutingRoot) {
988
1007
  const routingRoot = getFilesystemRoutingRootEffect(configFilesystemRoutingRoot, configName);
989
1008
  if (routingRoot) {
990
- const { filesystemRoutingRootEffect, filesystemRoutingRootDefinedAt } = routingRoot;
1009
+ const { filesystemRoutingRootEffect /*, filesystemRoutingRootDefinedAt*/ } = routingRoot;
991
1010
  const debugInfo = { locationId, routeFilesystem: filesystemRouteString, configFilesystemRoutingRoot };
992
1011
  (0, utils_js_1.assert)(filesystemRouteString.startsWith(filesystemRoutingRootEffect.before), debugInfo);
993
1012
  filesystemRouteString = (0, filesystemRouting_js_1.applyFilesystemRoutingRootEffect)(filesystemRouteString, filesystemRoutingRootEffect);
994
- filesystemRouteDefinedBy = `${filesystemRouteDefinedBy} (with ${filesystemRoutingRootDefinedAt})`;
1013
+ // filesystemRouteDefinedBy = `${filesystemRouteDefinedBy} (with ${filesystemRoutingRootDefinedAt})`
995
1014
  }
996
1015
  }
997
1016
  (0, utils_js_1.assert)(filesystemRouteString.startsWith('/'));
@@ -1006,10 +1025,10 @@ function getFilesystemRoutingRootEffect(configFilesystemRoutingRoot, configName)
1006
1025
  // Eagerly loaded since it's config-only
1007
1026
  (0, utils_js_1.assert)('value' in configFilesystemRoutingRoot);
1008
1027
  const { value } = configFilesystemRoutingRoot;
1009
- const configDefinedAt = getConfigSourceDefinedAtString(configName, configFilesystemRoutingRoot);
1028
+ const configDefinedAt = (0, helpers_js_1.getConfigDefinedAtString)('Config', configName, configFilesystemRoutingRoot);
1010
1029
  (0, utils_js_1.assertUsage)(typeof value === 'string', `${configDefinedAt} should be a string`);
1011
1030
  (0, utils_js_1.assertUsage)(value.startsWith('/'), `${configDefinedAt} is ${picocolors_1.default.cyan(value)} but it should start with a leading slash ${picocolors_1.default.cyan('/')}`);
1012
- const { filePathRelativeToUserRootDir } = configFilesystemRoutingRoot.definedAtInfo;
1031
+ const { filePathRelativeToUserRootDir } = configFilesystemRoutingRoot.definedAt;
1013
1032
  (0, utils_js_1.assert)(filePathRelativeToUserRootDir);
1014
1033
  const before = (0, filesystemRouting_js_1.getFilesystemRouteString)((0, filesystemRouting_js_1.getLocationId)(filePathRelativeToUserRootDir));
1015
1034
  const after = value;
@@ -1030,7 +1049,7 @@ function resolveImportPath(importData, importerFilePath) {
1030
1049
  }
1031
1050
  function assertImportPath(filePathAbsoluteFilesystem, importData, importerFilePath) {
1032
1051
  const { importPath: importPath, importStringWasGenerated, importString } = importData;
1033
- const filePathToShowToUser = (0, getFilePathToShowToUser_js_1.getFilePathToShowToUser)(importerFilePath);
1052
+ const { filePathToShowToUser } = importerFilePath;
1034
1053
  if (!filePathAbsoluteFilesystem) {
1035
1054
  const importPathString = picocolors_1.default.cyan(`'${importPath}'`);
1036
1055
  const errIntro = importStringWasGenerated
@@ -1074,7 +1093,6 @@ function getConfigValues(configValueSources, configValuesComputed, configDefinit
1074
1093
  configValues[configName] = {
1075
1094
  value,
1076
1095
  definedAt: {
1077
- isCumulative: true,
1078
1096
  files: sources.map((source) => getDefinedAtFile(source))
1079
1097
  }
1080
1098
  };
@@ -1082,12 +1100,21 @@ function getConfigValues(configValueSources, configValuesComputed, configDefinit
1082
1100
  });
1083
1101
  return configValues;
1084
1102
  }
1103
+ function getDefinedAtFile(configValueSource) {
1104
+ return {
1105
+ filePathToShowToUser: configValueSource.definedAt.filePathToShowToUser,
1106
+ fileExportPathToShowToUser: configValueSource.definedAt.fileExportPathToShowToUser
1107
+ };
1108
+ }
1109
+ function getDefinedAt(configValueSource) {
1110
+ return getDefinedAtFile(configValueSource);
1111
+ }
1085
1112
  function mergeCumulative(configName, configValueSources) {
1086
1113
  const valuesArr = [];
1087
1114
  const valuesSet = [];
1088
1115
  let configValueSourcePrevious = null;
1089
1116
  configValueSources.forEach((configValueSource) => {
1090
- const configDefinedAt = getConfigSourceDefinedAtString(configName, configValueSource);
1117
+ const configDefinedAt = (0, helpers_js_1.getConfigDefinedAtString)('Config', configName, configValueSource);
1091
1118
  const configNameColored = picocolors_1.default.cyan(configName);
1092
1119
  // We could, in principle, also support cumulative values to be defined in +${configName}.js but it ins't completely trivial to implement
1093
1120
  (0, utils_js_1.assertUsage)('value' in configValueSource, `${configDefinedAt} is only allowed to be defined in a +config.h.js file. (Because the values of ${configNameColored} are cumulative.)`);
@@ -1105,7 +1132,7 @@ function mergeCumulative(configName, configValueSources) {
1105
1132
  if (vals2.length === 0)
1106
1133
  return;
1107
1134
  (0, utils_js_1.assert)(configValueSourcePrevious);
1108
- const configPreviousDefinedAt = getConfigSourceDefinedAtString(configName, configValueSourcePrevious, undefined, false);
1135
+ const configPreviousDefinedAt = (0, helpers_js_1.getConfigDefinedAtString)('Config', configName, configValueSourcePrevious);
1109
1136
  (0, utils_js_1.assertUsage)(false, `${configDefinedAt} sets ${t1} but another ${configPreviousDefinedAt} sets ${t2} which is forbidden: the values must be all arrays or all sets (you cannot mix).`);
1110
1137
  };
1111
1138
  const { value } = configValueSource;
@@ -1136,30 +1163,3 @@ function mergeCumulative(configName, configValueSources) {
1136
1163
  }
1137
1164
  (0, utils_js_1.assert)(false);
1138
1165
  }
1139
- // TODO: rename
1140
- // TODO: refactor
1141
- function getConfigSourceDefinedAtString(configName, { definedAtInfo }, isEffect = undefined, sentenceBegin = true) {
1142
- return (0, utils_js_2.getConfigDefinedAtString)(configName, {
1143
- definedAt: {
1144
- isEffect,
1145
- file: {
1146
- filePathToShowToUser: getDefinedAtFilePathToShowToUser(definedAtInfo),
1147
- fileExportPath: definedAtInfo.fileExportPath
1148
- }
1149
- }
1150
- }, sentenceBegin);
1151
- }
1152
- function getDefinedAtFilePathToShowToUser(definedAtInfo) {
1153
- return definedAtInfo.filePathRelativeToUserRootDir ?? definedAtInfo.importPathAbsolute;
1154
- }
1155
- function getDefinedAtFile(source) {
1156
- return {
1157
- filePathToShowToUser: getDefinedAtFilePathToShowToUser(source.definedAtInfo),
1158
- fileExportPath: source.definedAtInfo.fileExportPath
1159
- };
1160
- }
1161
- function getDefinedAt(configValueSource) {
1162
- return {
1163
- file: getDefinedAtFile(configValueSource)
1164
- };
1165
- }