vike 0.4.259-commit-656fc24 → 0.4.259-commit-f2bab48

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.
@@ -29,28 +29,41 @@ function getCommand() {
29
29
  function getCliOptions() {
30
30
  let cliOptions = {};
31
31
  let configNameCurrent;
32
- const commitIfDefinedWithoutValue = () => {
32
+ const addConfig = (configValue) => {
33
+ assert(configNameCurrent);
34
+ cliOptions[configNameCurrent] = configValue;
35
+ configNameCurrent = undefined;
36
+ };
37
+ const addConfigWithoutValue = () => {
33
38
  if (configNameCurrent)
34
- commit(true);
39
+ addConfig(true);
35
40
  };
36
- const commit = (val) => {
41
+ const addConfigWithValue = (configValueStr) => {
37
42
  assert(configNameCurrent);
38
- cliOptions[configNameCurrent] = val;
39
- configNameCurrent = undefined;
43
+ addConfig(parseJson5(configValueStr, `CLI option --${configNameCurrent}`));
40
44
  };
41
45
  for (const arg of process.argv.slice(3)) {
42
46
  showHelpOrVersion(arg);
43
47
  if (arg.startsWith('--')) {
44
- commitIfDefinedWithoutValue();
45
- configNameCurrent = arg.slice('--'.length);
48
+ addConfigWithoutValue();
49
+ const str = arg.slice('--'.length);
50
+ const eqIdx = str.indexOf('=');
51
+ if (eqIdx === -1) {
52
+ configNameCurrent = str;
53
+ }
54
+ else {
55
+ configNameCurrent = str.slice(0, eqIdx);
56
+ const configValueStr = str.slice(eqIdx + 1);
57
+ addConfigWithValue(configValueStr);
58
+ }
46
59
  }
47
60
  else {
48
61
  if (!configNameCurrent)
49
62
  wrongUsage(`Unknown option ${pc.bold(arg)}`);
50
- commit(parseJson5(arg, `CLI option --${configNameCurrent}`));
63
+ addConfigWithValue(arg);
51
64
  }
52
65
  }
53
- commitIfDefinedWithoutValue();
66
+ addConfigWithoutValue();
54
67
  return cliOptions;
55
68
  }
56
69
  function showHelp() {
@@ -1,5 +1,5 @@
1
1
  export { generateVirtualFilePageEntry };
2
- import { assert, getProjectError } from '../../../../utils/assert.js';
2
+ import { assert, getDebugInfoStr, getProjectError } from '../../../../utils/assert.js';
3
3
  import { parseVirtualFileId, generateVirtualFileId } from '../../../../shared-server-node/virtualFileId.js';
4
4
  import { getVikeConfigInternal } from '../../shared/resolveVikeConfigInternal.js';
5
5
  import { extractAssetsAddQuery } from '../../../../shared-server-node/extractAssetsQuery.js';
@@ -26,12 +26,10 @@ async function generateVirtualFilePageEntry(id, isDev) {
26
26
  assert(pageConfig);
27
27
  }
28
28
  else {
29
- /* This assertion sometimes fail. It happens very seldom and I couldn't reproduce it (https://gist.github.com/brillout/9e212ce829f4d62a912ca163ffa8881a). I suspect some kind of HMR race condition. UPDATE: [December 2024] This just happened at test/@cloudflare_vite-plugin/ — it isn't blocking, reloading the page fixes the issue.
30
- assert(pageConfig, { id, pageId })
31
- /*/
32
- if (!pageConfig)
33
- throw getProjectError('Outdated request');
34
- //*/
29
+ if (!pageConfig) {
30
+ // Happens very seldomly and can't reproduce reliably. Some kind of HMR race condition? It still happens as of June 2026 with Cloudflare Workers in developement — but it isn't blocking, reloading the page fixes the issue.
31
+ throw getProjectError(`Outdated request. Try again. ${getDebugInfoStr({ id, pageId })}`);
32
+ }
35
33
  }
36
34
  const code = getCode(pageConfig, isForClientSide, pageId, resolveIncludeAssetsImportedByServer(vikeConfig.config), isDev);
37
35
  debug(id, isForClientSide ? 'CLIENT-SIDE' : 'SERVER-SIDE', code);
@@ -219,7 +219,7 @@ async function resolveVikeConfigInternal(userRootDir, vikeVitePluginOptions, esb
219
219
  globalObject.isV1Design_ = pageConfigs.length > 0;
220
220
  // Backwards compatibility for vike(options) in vite.config.js
221
221
  temp_interopVikeVitePlugin(pageConfigGlobal, vikeVitePluginOptions, userRootDir);
222
- setCliAndApiOptions(pageConfigGlobal, configDefinitionsResolved);
222
+ setCliAndApiOptions(pageConfigGlobal, pageConfigs, configDefinitionsResolved);
223
223
  const globalConfigPublic = resolveGlobalConfig(pageConfigGlobal, pageConfigs);
224
224
  const prerenderContext = await resolvePrerenderContext({
225
225
  config: globalConfigPublic.config,
@@ -283,7 +283,7 @@ async function resolveConfigDefinitions(plusFilesByLocationId, userRootDir, esbu
283
283
  configNamesKnownAll,
284
284
  configNamesKnownGlobal,
285
285
  };
286
- assertKnownConfigs(configDefinitionsResolved);
286
+ warnUnknownConfigs(configDefinitionsResolved);
287
287
  return configDefinitionsResolved;
288
288
  }
289
289
  // Load value files (with `env.config===true`) of *custom* configs.
@@ -464,29 +464,47 @@ function temp_interopVikeVitePlugin(pageConfigGlobal, vikeVitePluginOptions, use
464
464
  }, pageConfigGlobal.configDefinitions));
465
465
  });
466
466
  }
467
- function setCliAndApiOptions(pageConfigGlobal, configDefinitionsResolved) {
467
+ function setCliAndApiOptions(pageConfigGlobal, pageConfigs, configDefinitionsResolved) {
468
468
  // Vike API — passed options [lowest precedence]
469
469
  const vikeApiOperation = getVikeApiOperation();
470
470
  if (vikeApiOperation?.options.vikeConfig) {
471
- addSources(vikeApiOperation.options.vikeConfig, { definedBy: 'api', operation: vikeApiOperation.operation }, false);
471
+ addSources(vikeApiOperation.options.vikeConfig, {
472
+ definedBy: 'api',
473
+ operation: vikeApiOperation.operation,
474
+ });
472
475
  }
473
476
  const { configFromCliOptions, configFromEnvVar } = getVikeConfigFromCliOrEnv();
474
477
  // Vike CLI options
475
478
  if (configFromCliOptions) {
476
- addSources(configFromCliOptions, { definedBy: 'cli' }, true);
479
+ addSources(configFromCliOptions, { definedBy: 'cli' });
477
480
  }
478
481
  // VIKE_CONFIG [highest precedence]
479
482
  if (configFromEnvVar) {
480
- addSources(configFromEnvVar, { definedBy: 'env' }, false);
483
+ addSources(configFromEnvVar, { definedBy: 'env' });
481
484
  }
482
485
  return;
483
- function addSources(configValues, definedBy, exitOnError) {
486
+ function addSources(configValues, definedBy) {
484
487
  Object.entries(configValues).forEach(([configName, value]) => {
485
488
  var _a;
486
489
  const sourceName = `The ${getDefinedByString(definedBy, configName)}`;
487
- assertKnownConfig(configName, configDefinitionsResolved.configNamesKnownGlobal, configDefinitionsResolved, '/', false, sourceName, exitOnError);
488
- const sources = ((_a = pageConfigGlobal.configValueSources)[configName] ?? (_a[configName] = []));
489
- sources.unshift(getSourceNonConfigFile(configName, value, definedBy, pageConfigGlobal.configDefinitions));
490
+ const isUnknown = isUnknownConfig(configName, configDefinitionsResolved.configNamesKnownAll, configDefinitionsResolved, '/', false, sourceName);
491
+ if (isUnknown)
492
+ return;
493
+ if (configName in pageConfigGlobal.configDefinitions) {
494
+ const sources = ((_a = pageConfigGlobal.configValueSources)[configName] ?? (_a[configName] = []));
495
+ const source = getSourceNonConfigFile(configName, value, definedBy, pageConfigGlobal.configDefinitions);
496
+ sources.unshift(source);
497
+ return;
498
+ }
499
+ // Non-global config: inject into every page config that knows about it (highest precedence)
500
+ pageConfigs.forEach((pageConfig) => {
501
+ var _a;
502
+ if (!(configName in pageConfig.configDefinitions))
503
+ return;
504
+ const sources = ((_a = pageConfig.configValueSources)[configName] ?? (_a[configName] = []));
505
+ const source = getSourceNonConfigFile(configName, value, definedBy, pageConfig.configDefinitions);
506
+ sources.unshift(source);
507
+ });
490
508
  });
491
509
  }
492
510
  }
@@ -973,29 +991,32 @@ function getComputed(pageConfig) {
973
991
  });
974
992
  return configValuesComputed;
975
993
  }
976
- // Show error message upon unknown config
977
- function assertKnownConfigs(configDefinitionsResolved) {
994
+ function warnUnknownConfigs(configDefinitionsResolved) {
978
995
  objectEntries(configDefinitionsResolved.configDefinitionsLocal).forEach(([_locationId, { configNamesKnownLocal, plusFiles }]) => {
979
996
  plusFiles.forEach((plusFile) => {
980
997
  const configNames = getConfigNamesSetByPlusFile(plusFile);
981
998
  configNames.forEach((configName) => {
982
999
  const { locationId } = plusFile;
983
1000
  const sourceName = plusFile.filePath.filePathToShowToUser;
984
- assertKnownConfig(configName, configNamesKnownLocal, configDefinitionsResolved, locationId, true, sourceName, false);
1001
+ isUnknownConfig(configName, configNamesKnownLocal, configDefinitionsResolved, locationId, true, sourceName);
985
1002
  });
986
1003
  });
987
1004
  });
988
1005
  }
989
- function assertKnownConfig(configName, configNamesKnownRelevant, configDefinitionsResolved, locationId, isPlusFile, sourceName, exitOnError) {
1006
+ function isUnknownConfig(configName, configNamesKnownRelevant, configDefinitionsResolved, locationId, isPlusFile, sourceName) {
990
1007
  const { configNamesKnownAll } = configDefinitionsResolved;
991
1008
  if (configNamesKnownRelevant.includes(configName)) {
992
1009
  assert(configNamesKnownAll.includes(configName));
993
- return;
1010
+ return false;
994
1011
  }
995
1012
  const configNameColored = pc.cyan(configName);
1013
+ const warn = (msg) => {
1014
+ assertWarning(false, msg, { onlyOnce: true });
1015
+ return true;
1016
+ };
996
1017
  // Inheritance issue: config is known but isn't defined at `locationId`
997
1018
  if (configNamesKnownAll.includes(configName)) {
998
- assertUsage(false, `${sourceName} sets the value of the config ${configNameColored} which is a custom config that is defined with ${pc.underline('https://vike.dev/meta')} at a path that doesn't apply to ${locationId} — see ${pc.underline('https://vike.dev/config#inheritance')}`, { exitOnError });
1019
+ return warn(`${sourceName} sets the value of the config ${configNameColored} which is a custom config that is defined with ${pc.underline('https://vike.dev/meta')} at a path that doesn't apply to ${locationId} — see ${pc.underline('https://vike.dev/config#inheritance')}`);
999
1020
  }
1000
1021
  const errMsg = isPlusFile
1001
1022
  ? `${sourceName} sets an unknown config ${configNameColored}`
@@ -1018,7 +1039,7 @@ function assertKnownConfig(configName, configNamesKnownRelevant, configDefinitio
1018
1039
  if (configName in knownVikeExntensionConfigs) {
1019
1040
  const requiredVikeExtension = joinEnglish(knownVikeExntensionConfigs[configName].map((e) => pc.bold(e)), 'or');
1020
1041
  const errMsgEnhanced = `${errMsg}. If you want to use the configuration ${configNameColored} documented at ${pc.underline(`https://vike.dev/${configName}`)} then make sure to install ${requiredVikeExtension}. (Alternatively, you can define ${configNameColored} yourself by using ${pc.cyan('meta')}, see ${pc.underline('https://vike.dev/meta')} for more information.)`;
1021
- assertUsage(false, errMsgEnhanced, { exitOnError });
1042
+ return warn(errMsgEnhanced);
1022
1043
  }
1023
1044
  }
1024
1045
  // Similarity hint
@@ -1035,9 +1056,9 @@ function assertKnownConfig(configName, configNamesKnownRelevant, configDefinitio
1035
1056
  if (configName === 'page') {
1036
1057
  errMsgEnhanced += ` (The name of the config ${pc.cyan('Page')} starts with a capital letter ${pc.cyan('P')} because it defines a UI component: a ubiquitous JavaScript convention is that the name of UI components start with a capital letter.)`;
1037
1058
  }
1038
- assertUsage(false, errMsgEnhanced, { exitOnError });
1059
+ return warn(errMsgEnhanced);
1039
1060
  }
1040
- assertUsage(false, errMsg, { exitOnError });
1061
+ return warn(errMsg);
1041
1062
  }
1042
1063
  function determineRouteFilesystem(locationId, configValueSources) {
1043
1064
  const configName = 'filesystemRoutingRoot';
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.259-commit-656fc24";
1
+ export declare const PROJECT_VERSION: "0.4.259-commit-f2bab48";
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.259-commit-656fc24';
2
+ export const PROJECT_VERSION = '0.4.259-commit-f2bab48';
@@ -3,6 +3,7 @@ export { assertUsage };
3
3
  export { assertWarning };
4
4
  export { assertInfo };
5
5
  export { getProjectError };
6
+ export { getDebugInfoStr };
6
7
  export { isVikeBug };
7
8
  export { setAssertOnBeforeLog };
8
9
  export { setAssertOnBeforeErr };
@@ -10,6 +11,7 @@ export { setAssertAlwaysShowStackTrace };
10
11
  export { setAssertAddAssertTagsDev };
11
12
  import type { AddAssertTagsDev } from '../node/vite/shared/loggerDev.js';
12
13
  declare function assert(condition: unknown, debugInfo?: unknown): asserts condition;
14
+ declare function getDebugInfoStr(debugInfo: unknown): string | null;
13
15
  declare function assertUsage(condition: unknown, errMsg: string, { showStackTrace, exitOnError }?: {
14
16
  showStackTrace?: true;
15
17
  exitOnError?: boolean;
@@ -3,6 +3,7 @@ export { assertUsage };
3
3
  export { assertWarning };
4
4
  export { assertInfo };
5
5
  export { getProjectError };
6
+ export { getDebugInfoStr };
6
7
  export { isVikeBug };
7
8
  export { setAssertOnBeforeLog };
8
9
  export { setAssertOnBeforeErr };
@@ -24,17 +25,10 @@ const tagTypeBug = 'Bug';
24
25
  function assert(condition, debugInfo) {
25
26
  if (condition)
26
27
  return;
27
- const debugStr = (() => {
28
- if (!debugInfo) {
29
- return null;
30
- }
31
- const debugInfoSerialized = typeof debugInfo === 'string' ? debugInfo : JSON.stringify(debugInfo);
32
- return pc.dim(`Debug for maintainers (you can ignore this): ${debugInfoSerialized}`);
33
- })();
34
28
  const link = pc.underline('https://github.com/vikejs/vike/issues/new?template=bug.yml');
35
29
  let errMsg = [
36
30
  `You stumbled upon a Vike bug. Go to ${link} and copy-paste this error. A maintainer will fix the bug (usually within 24 hours).`,
37
- debugStr,
31
+ getDebugInfoStr(debugInfo),
38
32
  ]
39
33
  .filter(Boolean)
40
34
  .join(' ');
@@ -44,6 +38,12 @@ function assert(condition, debugInfo) {
44
38
  globalObject.onBeforeErr?.(internalError);
45
39
  throw internalError;
46
40
  }
41
+ function getDebugInfoStr(debugInfo) {
42
+ if (!debugInfo)
43
+ return null;
44
+ const debugInfoSerialized = typeof debugInfo === 'string' ? debugInfo : JSON.stringify(debugInfo);
45
+ return pc.dim(`Debug for maintainers (you can ignore this): ${debugInfoSerialized}`);
46
+ }
47
47
  function assertUsage(condition, errMsg, { showStackTrace, exitOnError } = {}) {
48
48
  if (condition)
49
49
  return;
@@ -36,7 +36,7 @@ function createRpcClient() {
36
36
  const hot = import.meta.hot;
37
37
  assert(hot);
38
38
  const callId = getRandomId();
39
- const { promise, resolve } = genPromise({ timeout: 3 * 1000 });
39
+ const { promise, resolve } = genPromise({ timeout: 10 * 1000 });
40
40
  listeners.push({
41
41
  callId,
42
42
  cb: (functionReturn) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.259-commit-656fc24",
3
+ "version": "0.4.259-commit-f2bab48",
4
4
  "repository": "https://github.com/vikejs/vike",
5
5
  "exports": {
6
6
  "./server": {