vike 0.4.259-commit-f2bab48 → 0.4.259-commit-85c5e84

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,41 +29,28 @@ function getCommand() {
29
29
  function getCliOptions() {
30
30
  let cliOptions = {};
31
31
  let configNameCurrent;
32
- const addConfig = (configValue) => {
33
- assert(configNameCurrent);
34
- cliOptions[configNameCurrent] = configValue;
35
- configNameCurrent = undefined;
36
- };
37
- const addConfigWithoutValue = () => {
32
+ const commitIfDefinedWithoutValue = () => {
38
33
  if (configNameCurrent)
39
- addConfig(true);
34
+ commit(true);
40
35
  };
41
- const addConfigWithValue = (configValueStr) => {
36
+ const commit = (val) => {
42
37
  assert(configNameCurrent);
43
- addConfig(parseJson5(configValueStr, `CLI option --${configNameCurrent}`));
38
+ cliOptions[configNameCurrent] = val;
39
+ configNameCurrent = undefined;
44
40
  };
45
41
  for (const arg of process.argv.slice(3)) {
46
42
  showHelpOrVersion(arg);
47
43
  if (arg.startsWith('--')) {
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
- }
44
+ commitIfDefinedWithoutValue();
45
+ configNameCurrent = arg.slice('--'.length);
59
46
  }
60
47
  else {
61
48
  if (!configNameCurrent)
62
49
  wrongUsage(`Unknown option ${pc.bold(arg)}`);
63
- addConfigWithValue(arg);
50
+ commit(parseJson5(arg, `CLI option --${configNameCurrent}`));
64
51
  }
65
52
  }
66
- addConfigWithoutValue();
53
+ commitIfDefinedWithoutValue();
67
54
  return cliOptions;
68
55
  }
69
56
  function showHelp() {
@@ -7,5 +7,6 @@ declare function getServerConfig(vikeConfig: VikeConfigInternal): {
7
7
  serverEntryId: string;
8
8
  serverEntryVike: string;
9
9
  serverFilePath: string | null;
10
+ isServerEntry: boolean;
10
11
  } | undefined;
11
12
  declare function isUniversalDeployVitePreview(vikeConfig: VikeConfigInternal, viteConfigResolved: ResolvedConfig): boolean | null;
@@ -1,5 +1,6 @@
1
1
  export { getServerConfig };
2
2
  export { isUniversalDeployVitePreview };
3
+ import { dirname, resolve } from 'node:path';
3
4
  import { catchAllEntry } from '@universal-deploy/store';
4
5
  import { assert } from '../../../../utils/assert.js';
5
6
  import '../../assertEnvVite.js';
@@ -7,6 +8,7 @@ function getServerConfig(vikeConfig) {
7
8
  let serverEntryId;
8
9
  let serverFilePath = null;
9
10
  let serverEntryVike;
11
+ let isServerEntry = false;
10
12
  // universal-deploy support must be manually enabled
11
13
  const serverConfig =
12
14
  // +config.js > `export default { server: true }`
@@ -21,8 +23,13 @@ function getServerConfig(vikeConfig) {
21
23
  assert('filePathAbsoluteFilesystem' in serverPlusFile.definedAt);
22
24
  serverFilePath = serverPlusFile.definedAt.filePathAbsoluteFilesystem;
23
25
  assert(serverFilePath);
24
- serverEntryId = serverFilePath;
25
- serverEntryVike = serverFilePath;
26
+ assert(serverPlusFile.valueIsLoaded);
27
+ assert(typeof serverPlusFile.value === 'object');
28
+ // +server.js > `export default { entry: './server/entrypoint.ts' }`
29
+ const entry = serverPlusFile.value.entry;
30
+ isServerEntry = typeof entry === 'string';
31
+ assert(entry === undefined || isServerEntry);
32
+ serverEntryVike = serverEntryId = isServerEntry ? resolve(dirname(serverFilePath), entry) : serverFilePath;
26
33
  }
27
34
  else {
28
35
  serverEntryId = catchAllEntry;
@@ -36,6 +43,7 @@ function getServerConfig(vikeConfig) {
36
43
  // It either points to the default fetchable endpoint (vike/fetch), or one defined by the user through +server.
37
44
  serverEntryVike,
38
45
  serverFilePath,
46
+ isServerEntry,
39
47
  };
40
48
  }
41
49
  function isUniversalDeployVitePreview(vikeConfig, viteConfigResolved) {
@@ -24,9 +24,9 @@ function pluginUniversalDeploy(vikeConfig) {
24
24
  assertUsage(target === undefined, `${target} requires +server — see https://vike.dev/server`);
25
25
  }),
26
26
  ];
27
- const { serverEntryVike, serverEntryId, serverFilePath } = serverConfig;
27
+ const { serverEntryVike, serverEntryId, serverFilePath, isServerEntry } = serverConfig;
28
28
  return [
29
- ...universalDeploy(),
29
+ ...universalDeploy({ entry: isServerEntry ? serverEntryVike : undefined }),
30
30
  {
31
31
  name: 'vike:pluginUniversalDeploy:entries',
32
32
  config() {
@@ -1,5 +1,5 @@
1
1
  export { generateVirtualFilePageEntry };
2
- import { assert, getDebugInfoStr, getProjectError } from '../../../../utils/assert.js';
2
+ import { assert, 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,10 +26,12 @@ async function generateVirtualFilePageEntry(id, isDev) {
26
26
  assert(pageConfig);
27
27
  }
28
28
  else {
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
- }
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
+ //*/
33
35
  }
34
36
  const code = getCode(pageConfig, isForClientSide, pageId, resolveIncludeAssetsImportedByServer(vikeConfig.config), isDev);
35
37
  debug(id, isForClientSide ? 'CLIENT-SIDE' : 'SERVER-SIDE', code);
@@ -227,7 +227,7 @@ const metaBuiltIn = {
227
227
  global: true,
228
228
  },
229
229
  server: {
230
- env: { server: true },
230
+ env: { server: true, config: true },
231
231
  global: true,
232
232
  },
233
233
  cli: {
@@ -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, pageConfigs, configDefinitionsResolved);
222
+ setCliAndApiOptions(pageConfigGlobal, 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
- warnUnknownConfigs(configDefinitionsResolved);
286
+ assertKnownConfigs(configDefinitionsResolved);
287
287
  return configDefinitionsResolved;
288
288
  }
289
289
  // Load value files (with `env.config===true`) of *custom* configs.
@@ -464,47 +464,29 @@ function temp_interopVikeVitePlugin(pageConfigGlobal, vikeVitePluginOptions, use
464
464
  }, pageConfigGlobal.configDefinitions));
465
465
  });
466
466
  }
467
- function setCliAndApiOptions(pageConfigGlobal, pageConfigs, configDefinitionsResolved) {
467
+ function setCliAndApiOptions(pageConfigGlobal, 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, {
472
- definedBy: 'api',
473
- operation: vikeApiOperation.operation,
474
- });
471
+ addSources(vikeApiOperation.options.vikeConfig, { definedBy: 'api', operation: vikeApiOperation.operation }, false);
475
472
  }
476
473
  const { configFromCliOptions, configFromEnvVar } = getVikeConfigFromCliOrEnv();
477
474
  // Vike CLI options
478
475
  if (configFromCliOptions) {
479
- addSources(configFromCliOptions, { definedBy: 'cli' });
476
+ addSources(configFromCliOptions, { definedBy: 'cli' }, true);
480
477
  }
481
478
  // VIKE_CONFIG [highest precedence]
482
479
  if (configFromEnvVar) {
483
- addSources(configFromEnvVar, { definedBy: 'env' });
480
+ addSources(configFromEnvVar, { definedBy: 'env' }, false);
484
481
  }
485
482
  return;
486
- function addSources(configValues, definedBy) {
483
+ function addSources(configValues, definedBy, exitOnError) {
487
484
  Object.entries(configValues).forEach(([configName, value]) => {
488
485
  var _a;
489
486
  const sourceName = `The ${getDefinedByString(definedBy, configName)}`;
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
- });
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));
508
490
  });
509
491
  }
510
492
  }
@@ -991,32 +973,29 @@ function getComputed(pageConfig) {
991
973
  });
992
974
  return configValuesComputed;
993
975
  }
994
- function warnUnknownConfigs(configDefinitionsResolved) {
976
+ // Show error message upon unknown config
977
+ function assertKnownConfigs(configDefinitionsResolved) {
995
978
  objectEntries(configDefinitionsResolved.configDefinitionsLocal).forEach(([_locationId, { configNamesKnownLocal, plusFiles }]) => {
996
979
  plusFiles.forEach((plusFile) => {
997
980
  const configNames = getConfigNamesSetByPlusFile(plusFile);
998
981
  configNames.forEach((configName) => {
999
982
  const { locationId } = plusFile;
1000
983
  const sourceName = plusFile.filePath.filePathToShowToUser;
1001
- isUnknownConfig(configName, configNamesKnownLocal, configDefinitionsResolved, locationId, true, sourceName);
984
+ assertKnownConfig(configName, configNamesKnownLocal, configDefinitionsResolved, locationId, true, sourceName, false);
1002
985
  });
1003
986
  });
1004
987
  });
1005
988
  }
1006
- function isUnknownConfig(configName, configNamesKnownRelevant, configDefinitionsResolved, locationId, isPlusFile, sourceName) {
989
+ function assertKnownConfig(configName, configNamesKnownRelevant, configDefinitionsResolved, locationId, isPlusFile, sourceName, exitOnError) {
1007
990
  const { configNamesKnownAll } = configDefinitionsResolved;
1008
991
  if (configNamesKnownRelevant.includes(configName)) {
1009
992
  assert(configNamesKnownAll.includes(configName));
1010
- return false;
993
+ return;
1011
994
  }
1012
995
  const configNameColored = pc.cyan(configName);
1013
- const warn = (msg) => {
1014
- assertWarning(false, msg, { onlyOnce: true });
1015
- return true;
1016
- };
1017
996
  // Inheritance issue: config is known but isn't defined at `locationId`
1018
997
  if (configNamesKnownAll.includes(configName)) {
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')}`);
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 });
1020
999
  }
1021
1000
  const errMsg = isPlusFile
1022
1001
  ? `${sourceName} sets an unknown config ${configNameColored}`
@@ -1039,7 +1018,7 @@ function isUnknownConfig(configName, configNamesKnownRelevant, configDefinitions
1039
1018
  if (configName in knownVikeExntensionConfigs) {
1040
1019
  const requiredVikeExtension = joinEnglish(knownVikeExntensionConfigs[configName].map((e) => pc.bold(e)), 'or');
1041
1020
  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.)`;
1042
- return warn(errMsgEnhanced);
1021
+ assertUsage(false, errMsgEnhanced, { exitOnError });
1043
1022
  }
1044
1023
  }
1045
1024
  // Similarity hint
@@ -1056,9 +1035,9 @@ function isUnknownConfig(configName, configNamesKnownRelevant, configDefinitions
1056
1035
  if (configName === 'page') {
1057
1036
  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.)`;
1058
1037
  }
1059
- return warn(errMsgEnhanced);
1038
+ assertUsage(false, errMsgEnhanced, { exitOnError });
1060
1039
  }
1061
- return warn(errMsg);
1040
+ assertUsage(false, errMsg, { exitOnError });
1062
1041
  }
1063
1042
  function determineRouteFilesystem(locationId, configValueSources) {
1064
1043
  const configName = 'filesystemRoutingRoot';
@@ -8,5 +8,6 @@ import type { Fetchable, ServerOptions } from '@universal-deploy/store';
8
8
  interface Server extends Fetchable {
9
9
  prod?: Omit<ServerOptions, 'fetch'> & {
10
10
  static?: boolean | string;
11
+ entry?: string;
11
12
  };
12
13
  }
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.259-commit-f2bab48";
1
+ export declare const PROJECT_VERSION: "0.4.259-commit-85c5e84";
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.259-commit-f2bab48';
2
+ export const PROJECT_VERSION = '0.4.259-commit-85c5e84';
@@ -3,7 +3,6 @@ export { assertUsage };
3
3
  export { assertWarning };
4
4
  export { assertInfo };
5
5
  export { getProjectError };
6
- export { getDebugInfoStr };
7
6
  export { isVikeBug };
8
7
  export { setAssertOnBeforeLog };
9
8
  export { setAssertOnBeforeErr };
@@ -11,7 +10,6 @@ export { setAssertAlwaysShowStackTrace };
11
10
  export { setAssertAddAssertTagsDev };
12
11
  import type { AddAssertTagsDev } from '../node/vite/shared/loggerDev.js';
13
12
  declare function assert(condition: unknown, debugInfo?: unknown): asserts condition;
14
- declare function getDebugInfoStr(debugInfo: unknown): string | null;
15
13
  declare function assertUsage(condition: unknown, errMsg: string, { showStackTrace, exitOnError }?: {
16
14
  showStackTrace?: true;
17
15
  exitOnError?: boolean;
@@ -3,7 +3,6 @@ export { assertUsage };
3
3
  export { assertWarning };
4
4
  export { assertInfo };
5
5
  export { getProjectError };
6
- export { getDebugInfoStr };
7
6
  export { isVikeBug };
8
7
  export { setAssertOnBeforeLog };
9
8
  export { setAssertOnBeforeErr };
@@ -25,10 +24,17 @@ const tagTypeBug = 'Bug';
25
24
  function assert(condition, debugInfo) {
26
25
  if (condition)
27
26
  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
+ })();
28
34
  const link = pc.underline('https://github.com/vikejs/vike/issues/new?template=bug.yml');
29
35
  let errMsg = [
30
36
  `You stumbled upon a Vike bug. Go to ${link} and copy-paste this error. A maintainer will fix the bug (usually within 24 hours).`,
31
- getDebugInfoStr(debugInfo),
37
+ debugStr,
32
38
  ]
33
39
  .filter(Boolean)
34
40
  .join(' ');
@@ -38,12 +44,6 @@ function assert(condition, debugInfo) {
38
44
  globalObject.onBeforeErr?.(internalError);
39
45
  throw internalError;
40
46
  }
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: 10 * 1000 });
39
+ const { promise, resolve } = genPromise({ timeout: 3 * 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-f2bab48",
3
+ "version": "0.4.259-commit-85c5e84",
4
4
  "repository": "https://github.com/vikejs/vike",
5
5
  "exports": {
6
6
  "./server": {