vike 0.4.160 → 0.4.161

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 (121) hide show
  1. package/dist/cjs/node/cli/bin.js +5 -0
  2. package/dist/cjs/node/client/router.js +4 -2
  3. package/dist/cjs/node/plugin/plugins/autoFullBuild.js +2 -2
  4. package/dist/cjs/node/plugin/plugins/buildConfig/fixServerAssets.js +148 -0
  5. package/dist/cjs/node/plugin/plugins/buildConfig.js +42 -15
  6. package/dist/cjs/node/plugin/plugins/commonConfig.js +5 -13
  7. package/dist/cjs/node/plugin/plugins/config/stemUtils.js +1 -1
  8. package/dist/cjs/node/plugin/plugins/distFileNames.js +9 -1
  9. package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +7 -2
  10. package/dist/cjs/node/plugin/plugins/importBuild/index.js +4 -7
  11. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +1 -5
  12. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +28 -46
  13. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{loadFileConfigEnv.js → loadFileAtConfigTime.js} +5 -5
  14. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveFilePath.js +33 -0
  15. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +2 -2
  16. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{transformImports.js → transformFileImports.js} +7 -7
  17. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +21 -27
  18. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +155 -111
  19. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +2 -1
  20. package/dist/cjs/node/plugin/utils.js +3 -2
  21. package/dist/cjs/node/prerender/runPrerender.js +12 -5
  22. package/dist/cjs/node/runtime/globalContext.js +7 -4
  23. package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +2 -2
  24. package/dist/cjs/node/runtime/html/renderHtml.js +1 -1
  25. package/dist/cjs/node/runtime/html/stream.js +2 -2
  26. package/dist/cjs/node/runtime/renderPage/executeOnRenderHtmlHook.js +2 -2
  27. package/dist/cjs/node/runtime/renderPage/getHttpResponseBody.js +39 -39
  28. package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +1 -1
  29. package/dist/cjs/node/runtime/renderPage/{logHintForCjsEsmError.js → logErrorHint.js} +81 -43
  30. package/dist/cjs/node/runtime/renderPage/loggerProd.js +3 -3
  31. package/dist/cjs/node/runtime/utils.js +1 -1
  32. package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +53 -26
  33. package/dist/cjs/shared/route/executeGuardHook.js +3 -2
  34. package/dist/cjs/shared/utils.js +0 -1
  35. package/dist/cjs/utils/assertNodeVersion.js +2 -2
  36. package/dist/cjs/utils/{findUserPackageJsonPath.js → findFile.js} +11 -8
  37. package/dist/cjs/utils/isVersionOrAbove.js +29 -0
  38. package/dist/cjs/utils/nodeEnv.js +23 -1
  39. package/dist/cjs/utils/objectKeys.js +19 -3
  40. package/dist/cjs/utils/projectInfo.js +1 -1
  41. package/dist/cjs/utils/sorter.js +62 -1
  42. package/dist/esm/client/client-routing-runtime/index.d.ts +1 -1
  43. package/dist/esm/client/client-routing-runtime/index.js +1 -1
  44. package/dist/esm/node/cli/bin.js +3 -1
  45. package/dist/esm/node/client/router.d.ts +2 -0
  46. package/dist/esm/node/client/router.js +3 -1
  47. package/dist/esm/node/plugin/plugins/autoFullBuild.js +2 -2
  48. package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.d.ts +13 -0
  49. package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.js +142 -0
  50. package/dist/esm/node/plugin/plugins/buildConfig.d.ts +2 -0
  51. package/dist/esm/node/plugin/plugins/buildConfig.js +43 -16
  52. package/dist/esm/node/plugin/plugins/commonConfig.js +6 -14
  53. package/dist/esm/node/plugin/plugins/config/stemUtils.js +2 -2
  54. package/dist/esm/node/plugin/plugins/distFileNames.js +9 -1
  55. package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +8 -3
  56. package/dist/esm/node/plugin/plugins/importBuild/index.d.ts +6 -1
  57. package/dist/esm/node/plugin/plugins/importBuild/index.js +4 -7
  58. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +2 -0
  59. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.d.ts +0 -1
  60. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +1 -5
  61. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts +39 -12
  62. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +29 -47
  63. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{loadFileConfigEnv.js → loadFileAtConfigTime.js} +4 -4
  64. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveFilePath.d.ts +5 -0
  65. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveFilePath.js +27 -0
  66. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.d.ts +1 -1
  67. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +1 -1
  68. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{transformImports.d.ts → transformFileImports.d.ts} +2 -2
  69. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{transformImports.js → transformFileImports.js} +6 -6
  70. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.d.ts +1 -1
  71. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +20 -26
  72. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +4 -0
  73. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +153 -109
  74. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +2 -1
  75. package/dist/esm/node/plugin/utils.d.ts +3 -2
  76. package/dist/esm/node/plugin/utils.js +3 -2
  77. package/dist/esm/node/prerender/runPrerender.js +13 -6
  78. package/dist/esm/node/runtime/globalContext.js +8 -5
  79. package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +2 -2
  80. package/dist/esm/node/runtime/html/renderHtml.js +1 -1
  81. package/dist/esm/node/runtime/html/stream.js +2 -2
  82. package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.js +2 -2
  83. package/dist/esm/node/runtime/renderPage/getHttpResponseBody.d.ts +6 -5
  84. package/dist/esm/node/runtime/renderPage/getHttpResponseBody.js +39 -39
  85. package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +1 -1
  86. package/dist/esm/node/runtime/renderPage/logErrorHint.d.ts +8 -0
  87. package/dist/esm/node/runtime/renderPage/{logHintForCjsEsmError.js → logErrorHint.js} +80 -42
  88. package/dist/esm/node/runtime/renderPage/loggerProd.js +3 -3
  89. package/dist/esm/node/runtime/utils.d.ts +1 -1
  90. package/dist/esm/node/runtime/utils.js +1 -1
  91. package/dist/esm/shared/page-configs/Config.d.ts +1 -1
  92. package/dist/esm/shared/page-configs/PageConfig.d.ts +2 -0
  93. package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +53 -26
  94. package/dist/esm/shared/route/executeGuardHook.js +3 -2
  95. package/dist/esm/shared/utils.d.ts +0 -1
  96. package/dist/esm/shared/utils.js +0 -1
  97. package/dist/esm/utils/assertNodeVersion.js +2 -2
  98. package/dist/esm/utils/findFile.d.ts +3 -0
  99. package/dist/esm/utils/findFile.js +21 -0
  100. package/dist/esm/utils/getOutDirs.d.ts +1 -0
  101. package/dist/esm/utils/isVersionOrAbove.d.ts +2 -0
  102. package/dist/esm/utils/isVersionOrAbove.js +26 -0
  103. package/dist/esm/utils/nodeEnv.d.ts +4 -0
  104. package/dist/esm/utils/nodeEnv.js +19 -0
  105. package/dist/esm/utils/objectKeys.d.ts +10 -1
  106. package/dist/esm/utils/objectKeys.js +20 -3
  107. package/dist/esm/utils/projectInfo.d.ts +2 -2
  108. package/dist/esm/utils/projectInfo.js +1 -1
  109. package/dist/esm/utils/sorter.d.ts +59 -0
  110. package/dist/esm/utils/sorter.js +61 -0
  111. package/package.json +1 -1
  112. package/dist/cjs/utils/objectEntries.js +0 -8
  113. package/dist/esm/node/runtime/renderPage/logHintForCjsEsmError.d.ts +0 -13
  114. package/dist/esm/utils/findUserPackageJsonPath.d.ts +0 -2
  115. package/dist/esm/utils/findUserPackageJsonPath.js +0 -18
  116. package/dist/esm/utils/objectEntries.d.ts +0 -4
  117. package/dist/esm/utils/objectEntries.js +0 -5
  118. /package/dist/cjs/node/runtime/renderPage/{logHintForCjsEsmError → logErrorHint}/errors.js +0 -0
  119. /package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{loadFileConfigEnv.d.ts → loadFileAtConfigTime.d.ts} +0 -0
  120. /package/dist/esm/node/runtime/renderPage/{logHintForCjsEsmError → logErrorHint}/errors.d.ts +0 -0
  121. /package/dist/esm/node/runtime/renderPage/{logHintForCjsEsmError → logErrorHint}/errors.js +0 -0
@@ -2,7 +2,8 @@ export { getVikeConfig };
2
2
  export { reloadVikeConfig };
3
3
  export { vikeConfigDependencies };
4
4
  export { isVikeConfigFile };
5
- import { assertPosixPath, assert, isObject, assertUsage, assertWarning, objectEntries, hasProp, arrayIncludes, assertIsNotProductionRuntime, getMostSimilar, joinEnglish, lowerFirst, mergeCumulativeValues, getOutDirs, assertKeys } from '../../../utils.js';
5
+ export { isV1Design };
6
+ import { assertPosixPath, assert, isObject, assertUsage, assertWarning, objectEntries, hasProp, arrayIncludes, assertIsNotProductionRuntime, getMostSimilar, joinEnglish, lowerFirst, mergeCumulativeValues, getOutDirs, assertKeys, objectKeys, objectFromEntries, makeFirst, isNpmPackageImport, reverse } from '../../../utils.js';
6
7
  import path from 'path';
7
8
  import { configDefinitionsBuiltIn, configDefinitionsBuiltInGlobal } from './getVikeConfig/configDefinitionsBuiltIn.js';
8
9
  import { getLocationId, getFilesystemRouteString, getFilesystemRouteDefinedBy, isInherited, sortAfterInheritanceOrder, isGlobalLocation, applyFilesystemRoutingRootEffect } from './getVikeConfig/filesystemRouting.js';
@@ -17,8 +18,9 @@ import { getConfigVike } from '../../../../shared/getConfigVike.js';
17
18
  import { assertConfigValueIsSerializable } from './getConfigValuesSerialized.js';
18
19
  import { crawlPlusFiles } from './getVikeConfig/crawlPlusFiles.js';
19
20
  import { getConfigFileExport } from './getConfigFileExport.js';
20
- import { loadConfigFile, loadImportedFile, loadValueFile } from './getVikeConfig/loadFileConfigEnv.js';
21
+ import { loadConfigFile, loadImportedFile, loadValueFile } from './getVikeConfig/loadFileAtConfigTime.js';
21
22
  import { clearFilesEnvMap, resolveImport } from './getVikeConfig/resolveImportPath.js';
23
+ import { resolveFilePathRelativeToUserRootDir } from './getVikeConfig/resolveFilePath.js';
22
24
  assertIsNotProductionRuntime();
23
25
  let devServerIsCorrupt = false;
24
26
  let wasConfigInvalid = null;
@@ -69,6 +71,10 @@ async function getVikeConfig(config, isDev, tolerateInvalidConfig = false, exten
69
71
  }
70
72
  return await vikeConfigPromise;
71
73
  }
74
+ async function isV1Design(config, isDev) {
75
+ const isV1Design = (await getVikeConfig(config, isDev)).pageConfigs.length > 0;
76
+ return isV1Design;
77
+ }
72
78
  async function loadInterfaceFiles(userRootDir, outDirRoot, isDev, extensions) {
73
79
  const plusFiles = await findPlusFiles(userRootDir, outDirRoot, isDev, extensions);
74
80
  const configFiles = [];
@@ -82,69 +88,77 @@ async function loadInterfaceFiles(userRootDir, outDirRoot, isDev, extensions) {
82
88
  }
83
89
  });
84
90
  let interfaceFilesByLocationId = {};
85
- // Config files
86
- await Promise.all(configFiles.map(async (filePath) => {
87
- const { configFile, extendsConfigs } = await loadConfigFile(filePath, userRootDir, [], false);
88
- const interfaceFile = getInterfaceFileFromConfigFile(configFile, false);
89
- const locationId = getLocationId(filePath.filePathAbsoluteVite);
90
- interfaceFilesByLocationId[locationId] = interfaceFilesByLocationId[locationId] ?? [];
91
- interfaceFilesByLocationId[locationId].push(interfaceFile);
92
- extendsConfigs.forEach((extendsConfig) => {
93
- const interfaceFile = getInterfaceFileFromConfigFile(extendsConfig, true);
94
- interfaceFilesByLocationId[locationId].push(interfaceFile);
95
- });
96
- }));
97
- // Value files
98
- await Promise.all(valueFiles.map(async (filePath) => {
99
- const configName = getConfigName(filePath.filePathAbsoluteVite);
100
- assert(configName);
101
- const interfaceFile = {
102
- filePath,
103
- fileExportsByConfigName: {
104
- [configName]: {}
105
- },
106
- isConfigFile: false,
107
- isValueFile: true,
108
- configName
109
- };
110
- {
111
- // We don't have access to the custom config definitions defined by the user yet.
112
- // - If `configDef` is `undefined` => we load the file +{configName}.js later.
113
- // - We already need to load +meta.js here (to get the custom config definitions defined by the user)
114
- const configDef = getConfigDefinitionOptional(configDefinitionsBuiltIn, configName);
115
- if (configDef && isConfigEnv(configDef, configName)) {
116
- await loadValueFile(interfaceFile, configName, userRootDir);
117
- }
118
- }
119
- {
120
- const locationId = getLocationId(filePath.filePathAbsoluteVite);
91
+ await Promise.all([
92
+ // Config files
93
+ ...configFiles.map(async (filePath) => {
94
+ const { filePathRelativeToUserRootDir } = filePath;
95
+ assert(filePathRelativeToUserRootDir);
96
+ const { configFile, extendsConfigs } = await loadConfigFile(filePath, userRootDir, [], false);
97
+ assert(filePath.filePathRelativeToUserRootDir);
98
+ const locationId = getLocationId(filePathRelativeToUserRootDir);
99
+ const interfaceFile = getInterfaceFileFromConfigFile(configFile, false, locationId);
121
100
  interfaceFilesByLocationId[locationId] = interfaceFilesByLocationId[locationId] ?? [];
122
101
  interfaceFilesByLocationId[locationId].push(interfaceFile);
123
- }
124
- }));
102
+ extendsConfigs.forEach((extendsConfig) => {
103
+ /* We purposely use the same locationId because the Vike extension's config should only apply to where it's being extended from, for example:
104
+ ```js
105
+ // /pages/admin/+config.h.js
106
+
107
+ import vikeVue from 'vike-vue/config'
108
+ // Should only apply to /pages/admin/**
109
+ export default { extends: [vikeVue] }
110
+ ```
111
+ ```js
112
+ // /pages/marketing/+config.h.js
113
+
114
+ import vikeReact from 'vike-react/config'
115
+ // Should only apply to /pages/marketing/**
116
+ export default { extends: [vikeReact] }
117
+ ```
118
+ */
119
+ const interfaceFile = getInterfaceFileFromConfigFile(extendsConfig, true, locationId);
120
+ interfaceFilesByLocationId[locationId].push(interfaceFile);
121
+ });
122
+ }),
123
+ // Value files
124
+ ...valueFiles.map(async (filePath) => {
125
+ const { filePathRelativeToUserRootDir } = filePath;
126
+ assert(filePathRelativeToUserRootDir);
127
+ const configName = getConfigName(filePathRelativeToUserRootDir);
128
+ assert(configName);
129
+ const locationId = getLocationId(filePathRelativeToUserRootDir);
130
+ const interfaceFile = {
131
+ locationId,
132
+ filePath,
133
+ fileExportsByConfigName: {
134
+ [configName]: {}
135
+ },
136
+ isConfigFile: false,
137
+ isValueFile: true,
138
+ configName
139
+ };
140
+ {
141
+ // We don't have access to the custom config definitions defined by the user yet.
142
+ // - If `configDef` is `undefined` => we load the file +{configName}.js later.
143
+ // - We already need to load +meta.js here (to get the custom config definitions defined by the user)
144
+ const configDef = getConfigDefinitionOptional(configDefinitionsBuiltIn, configName);
145
+ if (configDef && isConfigEnv(configDef, configName)) {
146
+ await loadValueFile(interfaceFile, configName, userRootDir);
147
+ }
148
+ }
149
+ {
150
+ interfaceFilesByLocationId[locationId] = interfaceFilesByLocationId[locationId] ?? [];
151
+ interfaceFilesByLocationId[locationId].push(interfaceFile);
152
+ }
153
+ })
154
+ ]);
125
155
  assertAllConfigsAreKnown(interfaceFilesByLocationId);
126
156
  return interfaceFilesByLocationId;
127
157
  }
128
- function getConfigDefinition(configDefinitionsRelevant, configName, filePathToShowToUser) {
129
- const configDef = configDefinitionsRelevant[configName];
130
- assertConfigExists(configName, Object.keys(configDefinitionsRelevant), filePathToShowToUser);
131
- assert(configDef);
132
- return configDef;
133
- }
134
- function getConfigDefinitionOptional(configDefinitions, configName) {
135
- return configDefinitions[configName] ?? null;
136
- }
137
- function isConfigEnv(configDef, configName) {
138
- const configEnv = configDef.env;
139
- if (configDef.cumulative) {
140
- // In principle we could lift that requirement (but it requires non-trivial modifications)
141
- assertUsage(configEnv.config, `Config ${pc.cyan(configName)} needs its ${pc.cyan('env')} to have ${pc.cyan('{ config: true }')} (because ${pc.cyan(configName)} is a ${pc.cyan('cumulative')} config)`);
142
- }
143
- return !!configEnv.config;
144
- }
145
- function getInterfaceFileFromConfigFile(configFile, isConfigExtend) {
158
+ function getInterfaceFileFromConfigFile(configFile, isConfigExtend, locationId) {
146
159
  const { fileExports, filePath, extendsFilePaths } = configFile;
147
160
  const interfaceFile = {
161
+ locationId,
148
162
  filePath,
149
163
  fileExportsByConfigName: {},
150
164
  isConfigFile: true,
@@ -160,12 +174,12 @@ function getInterfaceFileFromConfigFile(configFile, isConfigExtend) {
160
174
  }
161
175
  /** Show error message upon unknown config */
162
176
  function assertAllConfigsAreKnown(interfaceFilesByLocationId) {
163
- Object.entries(interfaceFilesByLocationId).forEach(([locationId, interfaceFiles]) => {
177
+ objectEntries(interfaceFilesByLocationId).forEach(([locationId, interfaceFiles]) => {
164
178
  const interfaceFilesRelevant = getInterfaceFilesRelevant(interfaceFilesByLocationId, locationId);
165
- const configDefinitionsRelevant = getConfigDefinitions(interfaceFilesRelevant);
179
+ const configDefinitions = getConfigDefinitions(interfaceFilesRelevant);
166
180
  interfaceFiles.forEach((interfaceFile) => {
167
181
  Object.keys(interfaceFile.fileExportsByConfigName).forEach((configName) => {
168
- assertConfigExists(configName, Object.keys(configDefinitionsRelevant), interfaceFile.filePath.filePathToShowToUser);
182
+ assertConfigExists(configName, Object.keys(configDefinitions), interfaceFile.filePath.filePathToShowToUser);
169
183
  });
170
184
  });
171
185
  });
@@ -215,11 +229,11 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev, extensions) {
215
229
  const interfaceFilesByLocationId = await loadInterfaceFiles(userRootDir, outDirRoot, isDev, extensions);
216
230
  const importedFilesLoaded = {};
217
231
  const { globalVikeConfig, pageConfigGlobal } = await getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded);
218
- const pageConfigs = await Promise.all(Object.entries(interfaceFilesByLocationId)
232
+ const pageConfigs = await Promise.all(objectEntries(interfaceFilesByLocationId)
219
233
  .filter(([_pageId, interfaceFiles]) => isDefiningPage(interfaceFiles))
220
234
  .map(async ([locationId]) => {
221
235
  const interfaceFilesRelevant = getInterfaceFilesRelevant(interfaceFilesByLocationId, locationId);
222
- const configDefinitionsRelevant = getConfigDefinitions(interfaceFilesRelevant);
236
+ const configDefinitions = getConfigDefinitions(interfaceFilesRelevant);
223
237
  // Load value files of custom config-only configs
224
238
  await Promise.all(getInterfaceFileList(interfaceFilesRelevant).map(async (interfaceFile) => {
225
239
  if (!interfaceFile.isValueFile)
@@ -227,7 +241,7 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev, extensions) {
227
241
  const { configName } = interfaceFile;
228
242
  if (isGlobalConfig(configName))
229
243
  return;
230
- const configDef = getConfigDefinition(configDefinitionsRelevant, configName, interfaceFile.filePath.filePathToShowToUser);
244
+ const configDef = getConfigDefinition(configDefinitions, configName, interfaceFile.filePath.filePathToShowToUser);
231
245
  if (!isConfigEnv(configDef, configName))
232
246
  return;
233
247
  const isAlreadyLoaded = interfacefileIsAlreaydLoaded(interfaceFile);
@@ -237,8 +251,8 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev, extensions) {
237
251
  assert(!(configName in configDefinitionsBuiltIn));
238
252
  await loadValueFile(interfaceFile, configName, userRootDir);
239
253
  }));
240
- const configValueSources = {};
241
- await Promise.all(objectEntries(configDefinitionsRelevant)
254
+ let configValueSources = {};
255
+ await Promise.all(objectEntries(configDefinitions)
242
256
  .filter(([configName]) => !isGlobalConfig(configName))
243
257
  .map(async ([configName, configDef]) => {
244
258
  const sources = await resolveConfigValueSources(configName, configDef, interfaceFilesRelevant, userRootDir, importedFilesLoaded);
@@ -246,10 +260,11 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev, extensions) {
246
260
  return;
247
261
  configValueSources[configName] = sources;
248
262
  }));
263
+ configValueSources = sortConfigValueSources(configValueSources, locationId);
249
264
  const { routeFilesystem, isErrorPage } = determineRouteFilesystem(locationId, configValueSources);
250
- applyEffectsAll(configValueSources, configDefinitionsRelevant);
251
- const configValuesComputed = getComputed(configValueSources, configDefinitionsRelevant);
252
- const configValues = getConfigValues(configValueSources, configValuesComputed, configDefinitionsRelevant);
265
+ applyEffectsAll(configValueSources, configDefinitions);
266
+ const configValuesComputed = getComputed(configValueSources, configDefinitions);
267
+ const configValues = getConfigValues(configValueSources, configValuesComputed, configDefinitions);
253
268
  const pageConfig = {
254
269
  pageId: locationId,
255
270
  isErrorPage,
@@ -286,7 +301,7 @@ function interfacefileIsAlreaydLoaded(interfaceFile) {
286
301
  return isAlreadyLoaded;
287
302
  }
288
303
  function getInterfaceFilesRelevant(interfaceFilesByLocationId, locationIdPage) {
289
- const interfaceFilesRelevant = Object.fromEntries(Object.entries(interfaceFilesByLocationId)
304
+ const interfaceFilesRelevant = Object.fromEntries(objectEntries(interfaceFilesByLocationId)
290
305
  .filter(([locationId]) => {
291
306
  return isInherited(locationId, locationIdPage);
292
307
  })
@@ -301,14 +316,14 @@ function getInterfaceFileList(interfaceFilesByLocationId) {
301
316
  return interfaceFiles;
302
317
  }
303
318
  async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded) {
304
- const locationIds = Object.keys(interfaceFilesByLocationId);
305
- const interfaceFilesGlobal = Object.fromEntries(Object.entries(interfaceFilesByLocationId).filter(([locationId]) => {
319
+ const locationIds = objectKeys(interfaceFilesByLocationId);
320
+ const interfaceFilesGlobal = objectFromEntries(objectEntries(interfaceFilesByLocationId).filter(([locationId]) => {
306
321
  return isGlobalLocation(locationId, locationIds);
307
322
  }));
308
323
  // Validate that global configs live in global interface files
309
324
  {
310
325
  const interfaceFilesGlobalPaths = [];
311
- Object.entries(interfaceFilesGlobal).forEach(([locationId, interfaceFiles]) => {
326
+ objectEntries(interfaceFilesGlobal).forEach(([locationId, interfaceFiles]) => {
312
327
  assert(isGlobalLocation(locationId, locationIds));
313
328
  interfaceFiles.forEach(({ filePath: { filePathRelativeToUserRootDir } }) => {
314
329
  if (filePathRelativeToUserRootDir) {
@@ -317,7 +332,7 @@ async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importe
317
332
  });
318
333
  });
319
334
  const globalPaths = Array.from(new Set(interfaceFilesGlobalPaths.map((p) => path.posix.dirname(p))));
320
- Object.entries(interfaceFilesByLocationId).forEach(([locationId, interfaceFiles]) => {
335
+ objectEntries(interfaceFilesByLocationId).forEach(([locationId, interfaceFiles]) => {
321
336
  interfaceFiles.forEach((interfaceFile) => {
322
337
  Object.keys(interfaceFile.fileExportsByConfigName).forEach((configName) => {
323
338
  if (!isGlobalLocation(locationId, locationIds) && isGlobalConfig(configName)) {
@@ -441,6 +456,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
441
456
  const conf = interfaceFile.fileExportsByConfigName[configName];
442
457
  assert(conf);
443
458
  const configEnv = configDef.env;
459
+ const { locationId } = interfaceFile;
444
460
  const definedAtConfigFile = {
445
461
  ...interfaceFile.filePath,
446
462
  fileExportPathToShowToUser: ['default', configName]
@@ -466,6 +482,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
466
482
  };
467
483
  }
468
484
  const configValueSource = {
485
+ locationId,
469
486
  value: valueFilePath,
470
487
  valueIsFilePath: true,
471
488
  configEnv,
@@ -482,6 +499,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
482
499
  const import_ = resolveImport(configValue, interfaceFile.filePath, userRootDir, configEnv, configName);
483
500
  if (import_) {
484
501
  const configValueSource = {
502
+ locationId,
485
503
  configEnv,
486
504
  valueIsImportedAtRuntime: true,
487
505
  definedAt: import_
@@ -504,6 +522,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
504
522
  }
505
523
  // Defined by config file, i.e. +config.js file
506
524
  const configValueSource = {
525
+ locationId,
507
526
  value: configValue,
508
527
  configEnv,
509
528
  valueIsImportedAtRuntime: false,
@@ -516,6 +535,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
516
535
  const valueAlreadyLoaded = 'configValue' in conf;
517
536
  assert(valueAlreadyLoaded === !!configEnv.config);
518
537
  const configValueSource = {
538
+ locationId,
519
539
  configEnv,
520
540
  valueIsImportedAtRuntime: !valueAlreadyLoaded,
521
541
  definedAt: {
@@ -546,8 +566,10 @@ function isDefiningPageConfig(configName) {
546
566
  return ['Page', 'route'].includes(configName);
547
567
  }
548
568
  function getConfigDefinitions(interfaceFilesRelevant) {
549
- const configDefinitions = { ...configDefinitionsBuiltIn };
550
- Object.entries(interfaceFilesRelevant).forEach(([_locationId, interfaceFiles]) => {
569
+ const configDefinitionsMerged = { ...configDefinitionsBuiltIn };
570
+ Object.entries(interfaceFilesRelevant)
571
+ .reverse()
572
+ .forEach(([_locationId, interfaceFiles]) => {
551
573
  interfaceFiles.forEach((interfaceFile) => {
552
574
  const configMeta = interfaceFile.fileExportsByConfigName['meta'];
553
575
  if (!configMeta)
@@ -566,13 +588,14 @@ function getConfigDefinitions(interfaceFilesRelevant) {
566
588
  });
567
589
  objectEntries(meta).forEach(([configName, configDefinition]) => {
568
590
  // User can override an existing config definition
569
- configDefinitions[configName] = {
570
- ...configDefinitions[configName],
591
+ configDefinitionsMerged[configName] = {
592
+ ...configDefinitionsMerged[configName],
571
593
  ...configDefinition
572
594
  };
573
595
  });
574
596
  });
575
597
  });
598
+ const configDefinitions = configDefinitionsMerged;
576
599
  return configDefinitions;
577
600
  }
578
601
  function assertMetaValue(metaVal, configMetaDefinedAt) {
@@ -611,8 +634,8 @@ function assertMetaValue(metaVal, configMetaDefinedAt) {
611
634
  }
612
635
  });
613
636
  }
614
- function applyEffectsAll(configValueSources, configDefinitionsRelevant) {
615
- objectEntries(configDefinitionsRelevant).forEach(([configName, configDef]) => {
637
+ function applyEffectsAll(configValueSources, configDefinitions) {
638
+ objectEntries(configDefinitions).forEach(([configName, configDef]) => {
616
639
  if (!configDef.effect)
617
640
  return;
618
641
  // 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,9 +694,9 @@ function applyEffect(configModFromEffect, configValueSources, configDefEffect) {
671
694
  }
672
695
  });
673
696
  }
674
- function getComputed(configValueSources, configDefinitionsRelevant) {
697
+ function getComputed(configValueSources, configDefinitions) {
675
698
  const configValuesComputed = {};
676
- objectEntries(configDefinitionsRelevant).forEach(([configName, configDef]) => {
699
+ objectEntries(configDefinitions).forEach(([configName, configDef]) => {
677
700
  if (!configDef._computed)
678
701
  return;
679
702
  const value = configDef._computed(configValueSources);
@@ -688,15 +711,7 @@ function getComputed(configValueSources, configDefinitionsRelevant) {
688
711
  }
689
712
  async function findPlusFiles(userRootDir, outDirRoot, isDev, extensions) {
690
713
  const files = await crawlPlusFiles(userRootDir, outDirRoot, isDev);
691
- const plusFiles = files.map(({ filePathRelativeToUserRootDir, filePathAbsoluteFilesystem }) => {
692
- return {
693
- filePathRelativeToUserRootDir,
694
- filePathAbsoluteVite: filePathRelativeToUserRootDir,
695
- filePathAbsoluteFilesystem,
696
- filePathToShowToUser: filePathRelativeToUserRootDir,
697
- importPathAbsolute: null
698
- };
699
- });
714
+ const plusFiles = files.map(({ filePathRelativeToUserRootDir }) => resolveFilePathRelativeToUserRootDir(filePathRelativeToUserRootDir, userRootDir));
700
715
  // TODO/v1-release: remove
701
716
  extensions.forEach((extension) => {
702
717
  extension.pageConfigsDistFiles?.forEach((pageConfigDistFile) => {
@@ -748,22 +763,6 @@ function assertNoUnexpectedPlusSign(filePath: string, fileName: string) {
748
763
  )
749
764
  }
750
765
  */
751
- function isGlobalConfig(configName) {
752
- if (configName === 'prerender')
753
- return false;
754
- const configNamesGlobal = getConfigNamesGlobal();
755
- return arrayIncludes(configNamesGlobal, configName);
756
- }
757
- function getConfigNamesGlobal() {
758
- return Object.keys(configDefinitionsBuiltInGlobal);
759
- }
760
- function assertConfigExists(configName, configNamesRelevant, filePathToShowToUser) {
761
- const configNames = [...configNamesRelevant, ...getConfigNamesGlobal()];
762
- if (configNames.includes(configName))
763
- return;
764
- handleUnknownConfig(configName, configNames, filePathToShowToUser);
765
- assert(false);
766
- }
767
766
  function handleUnknownConfig(configName, configNames, filePathToShowToUser) {
768
767
  let errMsg = `${filePathToShowToUser} defines an unknown config ${pc.cyan(configName)}`;
769
768
  let configNameSimilar = null;
@@ -833,7 +832,7 @@ function determineIsErrorPage(routeFilesystem) {
833
832
  function isVikeConfigFile(filePath) {
834
833
  return !!getConfigName(filePath);
835
834
  }
836
- function getConfigValues(configValueSources, configValuesComputed, configDefinitionsRelevant) {
835
+ function getConfigValues(configValueSources, configValuesComputed, configDefinitions) {
837
836
  const configValues = {};
838
837
  Object.entries(configValuesComputed).forEach(([configName, configValueComputed]) => {
839
838
  configValues[configName] = {
@@ -842,7 +841,7 @@ function getConfigValues(configValueSources, configValuesComputed, configDefinit
842
841
  };
843
842
  });
844
843
  Object.entries(configValueSources).forEach(([configName, sources]) => {
845
- const configDef = configDefinitionsRelevant[configName];
844
+ const configDef = configDefinitions[configName];
846
845
  assert(configDef);
847
846
  if (!configDef.cumulative) {
848
847
  const configValueSource = sources[0];
@@ -956,3 +955,48 @@ function getConfigEnvValue(val, errMsgIntro) {
956
955
  */
957
956
  return val;
958
957
  }
958
+ function getConfigDefinition(configDefinitions, configName, filePathToShowToUser) {
959
+ const configDef = configDefinitions[configName];
960
+ assertConfigExists(configName, Object.keys(configDefinitions), filePathToShowToUser);
961
+ assert(configDef);
962
+ return configDef;
963
+ }
964
+ function getConfigDefinitionOptional(configDefinitions, configName) {
965
+ return configDefinitions[configName] ?? null;
966
+ }
967
+ function isConfigEnv(configDef, configName) {
968
+ const configEnv = configDef.env;
969
+ if (configDef.cumulative) {
970
+ // In principle we could lift that requirement (but it requires non-trivial modifications)
971
+ assertUsage(configEnv.config, `Config ${pc.cyan(configName)} needs its ${pc.cyan('env')} to have ${pc.cyan('{ config: true }')} (because ${pc.cyan(configName)} is a ${pc.cyan('cumulative')} config)`);
972
+ }
973
+ return !!configEnv.config;
974
+ }
975
+ function isGlobalConfig(configName) {
976
+ if (configName === 'prerender')
977
+ return false;
978
+ const configNamesGlobal = getConfigNamesGlobal();
979
+ return arrayIncludes(configNamesGlobal, configName);
980
+ }
981
+ function getConfigNamesGlobal() {
982
+ return Object.keys(configDefinitionsBuiltInGlobal);
983
+ }
984
+ function assertConfigExists(configName, configNamesRelevant, filePathToShowToUser) {
985
+ const configNames = [...configNamesRelevant, ...getConfigNamesGlobal()];
986
+ if (configNames.includes(configName))
987
+ return;
988
+ handleUnknownConfig(configName, configNames, filePathToShowToUser);
989
+ assert(false);
990
+ }
991
+ function sortConfigValueSources(configValueSources, locationIdPage) {
992
+ return Object.fromEntries(Object.entries(configValueSources)
993
+ // Make order deterministic (no other purpose)
994
+ .sort(([, [source1]], [, [source2]]) => source1.definedAt.filePathAbsoluteVite < source2.definedAt.filePathAbsoluteVite ? -1 : 1)
995
+ // Sort after whether the config value was defined by an npm package
996
+ .sort(makeFirst(([, [source]]) => {
997
+ const { importPathAbsolute } = source.definedAt;
998
+ return !!importPathAbsolute && isNpmPackageImport(importPathAbsolute);
999
+ }))
1000
+ // Sort after the filesystem inheritance of the config value
1001
+ .sort(([, [source1]], [, [source2]]) => reverse(sortAfterInheritanceOrder(source1.locationId, source2.locationId, locationIdPage))));
1002
+ }
@@ -10,6 +10,7 @@ import { isRuntimeEnvMatch } from './isRuntimeEnvMatch.js';
10
10
  import { serializeConfigValueImported } from '../../../../../shared/page-configs/serialize/serializeConfigValue.js';
11
11
  import { getConfigVike } from '../../../../shared/getConfigVike.js';
12
12
  import { getConfigValuesSerialized } from './getConfigValuesSerialized.js';
13
+ import { fixServerAssets_isEnabled } from '../../buildConfig/fixServerAssets.js';
13
14
  async function getVirtualFilePageConfigValuesAll(id, isDev, config) {
14
15
  const result = isVirtualFileIdPageConfigValuesAll(id);
15
16
  assert(result);
@@ -42,7 +43,7 @@ function getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, includeAsse
42
43
  isClientRouting
43
44
  })));
44
45
  lines.push('};');
45
- if (includeAssetsImportedByServer && isForClientSide && !isDev) {
46
+ if (!fixServerAssets_isEnabled() && includeAssetsImportedByServer && isForClientSide && !isDev) {
46
47
  importStatements.push(`import '${extractAssetsAddQuery(getVirtualFileIdPageConfigValuesAll(pageId, false))}'`);
47
48
  }
48
49
  const code = [...importStatements, ...lines].join('\n');
@@ -5,7 +5,6 @@ export * from '../../utils/getDependencyPackageJson.js';
5
5
  export * from '../../utils/requireResolve.js';
6
6
  export * from '../../utils/arrayIncludes.js';
7
7
  export * from '../../utils/isDev.js';
8
- export * from '../../utils/objectKeys.js';
9
8
  export * from '../../utils/getMostSimilar.js';
10
9
  export * from '../../utils/getRandomId.js';
11
10
  export * from '../../utils/joinEnglish.js';
@@ -13,10 +12,12 @@ export * from '../../utils/escapeRegex.js';
13
12
  export * from '../../utils/stripAnsi.js';
14
13
  export * from '../../utils/trimWithAnsi.js';
15
14
  export * from '../../utils/removeEmptyLines.js';
16
- export * from '../../utils/findUserPackageJsonPath.js';
15
+ export * from '../../utils/findFile.js';
17
16
  export * from '../../utils/getPropAccessNotation.js';
18
17
  export * from '../../utils/mergeCumulativeValues.js';
19
18
  export * from '../../utils/deepEqual.js';
20
19
  export * from '../../utils/assertKeys.js';
21
20
  export * from '../../utils/injectRollupInputs.js';
22
21
  export * from '../../utils/humanizeTime.js';
22
+ export * from '../../utils/pLimit.js';
23
+ export * from '../../utils/isVersionOrAbove.js';
@@ -11,7 +11,6 @@ export * from '../../utils/getDependencyPackageJson.js';
11
11
  export * from '../../utils/requireResolve.js';
12
12
  export * from '../../utils/arrayIncludes.js';
13
13
  export * from '../../utils/isDev.js';
14
- export * from '../../utils/objectKeys.js';
15
14
  export * from '../../utils/getMostSimilar.js';
16
15
  export * from '../../utils/getRandomId.js';
17
16
  export * from '../../utils/joinEnglish.js';
@@ -19,10 +18,12 @@ export * from '../../utils/escapeRegex.js';
19
18
  export * from '../../utils/stripAnsi.js';
20
19
  export * from '../../utils/trimWithAnsi.js';
21
20
  export * from '../../utils/removeEmptyLines.js';
22
- export * from '../../utils/findUserPackageJsonPath.js';
21
+ export * from '../../utils/findFile.js';
23
22
  export * from '../../utils/getPropAccessNotation.js';
24
23
  export * from '../../utils/mergeCumulativeValues.js';
25
24
  export * from '../../utils/deepEqual.js';
26
25
  export * from '../../utils/assertKeys.js';
27
26
  export * from '../../utils/injectRollupInputs.js';
28
27
  export * from '../../utils/humanizeTime.js';
28
+ export * from '../../utils/pLimit.js';
29
+ export * from '../../utils/isVersionOrAbove.js';
@@ -5,7 +5,7 @@ export { runPrerender_forceExit };
5
5
  import '../runtime/page-files/setup.js';
6
6
  import path from 'path';
7
7
  import { route } from '../../shared/route/index.js';
8
- import { assert, assertUsage, assertWarning, hasProp, projectInfo, objectAssign, isObjectWithKeys, isCallable, getOutDirs, isPropertyGetter, assertPosixPath, urlToFile, executeHook, isPlainObject, setNodeEnvToProduction, isUserHookError } from './utils.js';
8
+ import { assert, assertUsage, assertWarning, hasProp, projectInfo, objectAssign, isObjectWithKeys, isCallable, getOutDirs, isPropertyGetter, assertPosixPath, urlToFile, executeHook, isPlainObject, setNodeEnvToProduction, isUserHookError, assertNodeEnvIsNotDev, getNodeEnv } from './utils.js';
9
9
  import { pLimit } from '../../utils/pLimit.js';
10
10
  import { prerenderPage, prerender404Page, getRenderContext, getPageContextInitEnhanced } from '../runtime/renderPage/renderPageAlreadyRouted.js';
11
11
  import pc from '@brillout/picocolors';
@@ -26,11 +26,11 @@ import { loadUserFilesServerSide } from '../runtime/renderPage/loadUserFilesServ
26
26
  import { getHookFromPageConfig, getHookFromPageConfigGlobal, getHookTimeoutDefault, setIsPrerenderering } from '../../shared/hooks/getHook.js';
27
27
  import { noRouteMatch } from '../../shared/route/noRouteMatch.js';
28
28
  import { getVikeConfig } from '../plugin/plugins/importUserCode/v1-design/getVikeConfig.js';
29
- import { logHintForCjsEsmError } from '../runtime/renderPage/logHintForCjsEsmError.js';
29
+ import { logErrorHint } from '../runtime/renderPage/logErrorHint.js';
30
30
  async function runPrerenderFromAPI(options = {}) {
31
31
  await runPrerender(options, 'prerender()');
32
32
  // - We purposely propagate the error to the user land, so that the error interrupts the user land. It's also, I guess, a nice-to-have that the user has control over the error.
33
- // - We don't use logHintForCjsEsmError() because we don't have control over what happens with the error. For example, if the user land purposely swallows the error then the hint shouldn't be logged. Also, it's best if the hint is shown to the user *after* the error, but we cannot do/guarentee that.
33
+ // - We don't use logErrorHint() because we don't have control over what happens with the error. For example, if the user land purposely swallows the error then the hint shouldn't be logged. Also, it's best if the hint is shown to the user *after* the error, but we cannot do/guarentee that.
34
34
  }
35
35
  async function runPrerenderFromCLI(options) {
36
36
  try {
@@ -38,7 +38,7 @@ async function runPrerenderFromCLI(options) {
38
38
  }
39
39
  catch (err) {
40
40
  console.error(err);
41
- logHintForCjsEsmError(err);
41
+ logErrorHint(err);
42
42
  process.exit(1);
43
43
  }
44
44
  }
@@ -48,7 +48,7 @@ async function runPrerenderFromAutoFullBuild(options) {
48
48
  }
49
49
  catch (err) {
50
50
  console.error(err);
51
- logHintForCjsEsmError(err);
51
+ logErrorHint(err);
52
52
  process.exit(1);
53
53
  }
54
54
  }
@@ -59,7 +59,7 @@ async function runPrerender(options, manuallyTriggered) {
59
59
  if (logLevel === 'info') {
60
60
  console.log(`${pc.cyan(`vike v${projectInfo.projectVersion}`)} ${pc.green('pre-rendering HTML...')}`);
61
61
  }
62
- setNodeEnvToProduction();
62
+ handleNodeEnv();
63
63
  await disableReactStreaming();
64
64
  const viteConfig = await resolveConfig(options.viteConfig || {}, 'vike pre-rendering', 'production');
65
65
  assertLoadedConfig(viteConfig, options);
@@ -713,3 +713,10 @@ function assertIsNotAbort(err, urlOr404) {
713
713
  assert(abortCall);
714
714
  assertUsage(false, `${pc.cyan(abortCall)} thrown${thrownBy} while pre-rendering ${urlOr404} but ${pc.cyan(abortCaller)} isn't supported for pre-rendered pages`);
715
715
  }
716
+ function handleNodeEnv() {
717
+ const assertNodeEnv = () => assertNodeEnvIsNotDev('pre-rendering');
718
+ if (getNodeEnv())
719
+ assertNodeEnv();
720
+ setNodeEnvToProduction();
721
+ assertNodeEnv();
722
+ }
@@ -6,7 +6,7 @@ export { setGlobalContext_viteDevServer };
6
6
  export { setGlobalContext_vitePreviewServer };
7
7
  export { setGlobalContext_viteConfig };
8
8
  export { getRuntimeManifest };
9
- import { assert, assertUsage, getGlobalObject, getNodeEnv, isNodeEnvDev, isPlainObject, objectAssign } from './utils.js';
9
+ import { assert, assertUsage, getGlobalObject, getNodeEnv, getNodeEnvDesc, isNodeEnvDev, isPlainObject, objectAssign } from './utils.js';
10
10
  import { loadImportBuild } from './globalContext/loadImportBuild.js';
11
11
  import { setPageFiles } from '../../shared/getPageFiles.js';
12
12
  import { assertPluginManifest } from '../shared/assertPluginManifest.js';
@@ -151,8 +151,11 @@ function assertNodeEnv(hasViteDevServer) {
151
151
  const nodeEnv = getNodeEnv();
152
152
  if (nodeEnv === null || nodeEnv === 'test')
153
153
  return;
154
- const isDevNodeEnv = isNodeEnvDev();
155
- // - Calling Vite's createServer() is enough for hasViteDevServer to be true, even without actually adding Vite's development middleware to the server: https://github.com/vikejs/vike/issues/792#issuecomment-1516830759
156
- // - We should change this to be a warning if it blocks users (e.g. if a bad-citizen tool sets a wrong process.env.NODE_ENV value).
157
- assertUsage(hasViteDevServer === isDevNodeEnv, `Vite's development server was${hasViteDevServer ? '' : "n't"} instantiated while the environment is set to be a ${isDevNodeEnv ? 'development' : 'production'} environment by ${pc.cyan(`process.env.NODE_ENV === ${JSON.stringify(nodeEnv)}`)} which is contradictory, see https://vike.dev/NODE_ENV`);
154
+ const isDev = isNodeEnvDev();
155
+ // Calling Vite's createServer() is enough for hasViteDevServer to be true, even without actually adding Vite's development middleware to the server: https://github.com/vikejs/vike/issues/792#issuecomment-1516830759
156
+ if (hasViteDevServer === isDev)
157
+ return;
158
+ const nodeEnvDesc = getNodeEnvDesc();
159
+ // We should change this to be a warning if it blocks users (e.g. if a bad-citizen tool sets a wrong process.env.NODE_ENV value)
160
+ assertUsage(false, `Vite's development server was${hasViteDevServer ? '' : "n't"} instantiated while the ${nodeEnvDesc} which is contradictory, see https://vike.dev/NODE_ENV`);
158
161
  }
@@ -85,8 +85,8 @@ async function getHtmlTags(pageContext, injectToStream, injectFilter) {
85
85
  // See https://github.com/vikejs/vike/pull/1271
86
86
  const positionJavaScriptEntry = (() => {
87
87
  if (pageContext._pageContextPromise) {
88
- assertWarning(!injectToStream, "[getHtmlTags()] We recommend against using streaming and a pageContext promise at the same time as progressive hydration won't work", { onlyOnce: true });
89
- // If there is a pageContext._pageContextPromise (which is resolved after the stream has ended) then the pageContext JSON data needs to await for it: https://vike.dev/stream#initial-data-after-stream-end
88
+ assertWarning(!injectToStream, "[getHtmlTags()] We recommend against using streaming and a pageContext promise at the same time, because progressive hydration won't work.", { onlyOnce: true });
89
+ // If there is a pageContext._pageContextPromise (which is resolved after the stream has ended) then the pageContext JSON data needs to await for it: https://vike.dev/streaming#initial-data-after-stream-end
90
90
  return 'HTML_END';
91
91
  }
92
92
  if (injectToStream) {
@@ -181,7 +181,7 @@ async function renderTemplate(templateContent, pageContext) {
181
181
  const varType = typeof templateVar;
182
182
  const streamNote = ['boolean', 'number', 'bigint', 'symbol'].includes(varType)
183
183
  ? null
184
- : '(See https://vike.dev/stream for HTML streaming.)';
184
+ : '(See https://vike.dev/streaming for HTML streaming.)';
185
185
  assertUsage(varType === 'string', getErrMsg(pc.cyan(`typeof htmlVar === "${varType}"`), streamNote));
186
186
  }
187
187
  {
@@ -634,7 +634,7 @@ function isStream(something) {
634
634
  const __streamPipeWeb = '__streamPipeWeb';
635
635
  /** @deprecated */
636
636
  function pipeWebStream(pipe) {
637
- assertWarning(false, 'pipeWebStream() is outdated, use stampPipe() instead. See https://vike.dev/stream', {
637
+ assertWarning(false, 'pipeWebStream() is outdated, use stampPipe() instead. See https://vike.dev/streaming', {
638
638
  onlyOnce: true,
639
639
  showStackTrace: true
640
640
  });
@@ -669,7 +669,7 @@ function isStreamPipeWeb(thing) {
669
669
  const __streamPipeNode = '__streamPipeNode';
670
670
  /** @deprecated */
671
671
  function pipeNodeStream(pipe) {
672
- assertWarning(false, 'pipeNodeStream() is outdated, use stampPipe() instead. See https://vike.dev/stream', {
672
+ assertWarning(false, 'pipeNodeStream() is outdated, use stampPipe() instead. See https://vike.dev/streaming', {
673
673
  onlyOnce: true,
674
674
  showStackTrace: true
675
675
  });