vike 0.4.224-commit-00ed9fe → 0.4.225

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 (90) hide show
  1. package/dist/cjs/node/api/build.js +1 -1
  2. package/dist/cjs/node/api/context.js +4 -4
  3. package/dist/cjs/node/api/dev.js +1 -1
  4. package/dist/cjs/node/api/prepareViteApiCall.js +3 -2
  5. package/dist/cjs/node/api/prerender.js +1 -1
  6. package/dist/cjs/node/api/preview.js +1 -1
  7. package/dist/cjs/node/cli/context.js +5 -4
  8. package/dist/cjs/node/cli/entry.js +3 -3
  9. package/dist/cjs/node/cli/parseCli.js +43 -15
  10. package/dist/cjs/node/cli/utils.js +1 -1
  11. package/dist/cjs/node/plugin/plugins/build/pluginBuildEntry.js +1 -1
  12. package/dist/cjs/node/plugin/plugins/commonConfig.js +15 -4
  13. package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +2 -0
  14. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +9 -1
  15. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +75 -21
  16. package/dist/cjs/node/plugin/shared/getEnvVarObject.js +9 -8
  17. package/dist/cjs/node/plugin/shared/loggerNotProd/log.js +1 -1
  18. package/dist/cjs/node/prerender/resolvePrerenderConfig.js +25 -17
  19. package/dist/cjs/node/prerender/runPrerender.js +2 -2
  20. package/dist/cjs/node/prerender/utils.js +1 -1
  21. package/dist/cjs/node/runtime/globalContext.js +9 -5
  22. package/dist/cjs/node/runtime/utils.js +0 -1
  23. package/dist/cjs/node/runtime-dev/createDevMiddleware.js +10 -8
  24. package/dist/cjs/node/shared/assertV1Design.js +2 -1
  25. package/dist/cjs/node/shared/utils.js +0 -1
  26. package/dist/cjs/shared/page-configs/getConfigDefinedAt.js +18 -2
  27. package/dist/cjs/shared/page-configs/getConfigValueBuildTime.js +8 -5
  28. package/dist/cjs/shared/page-configs/helpers.js +1 -1
  29. package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +2 -5
  30. package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +6 -2
  31. package/dist/cjs/shared/route/loadPageRoutes.js +2 -2
  32. package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
  33. package/dist/cjs/utils/assert.js +2 -2
  34. package/dist/cjs/utils/assertSingleInstance.js +11 -17
  35. package/dist/esm/node/api/build.js +1 -1
  36. package/dist/esm/node/api/context.d.ts +8 -2
  37. package/dist/esm/node/api/context.js +4 -4
  38. package/dist/esm/node/api/dev.js +1 -1
  39. package/dist/esm/node/api/prepareViteApiCall.d.ts +2 -2
  40. package/dist/esm/node/api/prepareViteApiCall.js +3 -2
  41. package/dist/esm/node/api/prerender.js +1 -1
  42. package/dist/esm/node/api/preview.js +1 -1
  43. package/dist/esm/node/api/types.d.ts +7 -0
  44. package/dist/esm/node/cli/context.d.ts +4 -2
  45. package/dist/esm/node/cli/context.js +5 -4
  46. package/dist/esm/node/cli/entry.js +4 -4
  47. package/dist/esm/node/cli/parseCli.d.ts +3 -0
  48. package/dist/esm/node/cli/parseCli.js +44 -16
  49. package/dist/esm/node/cli/utils.d.ts +1 -1
  50. package/dist/esm/node/cli/utils.js +1 -1
  51. package/dist/esm/node/plugin/plugins/build/pluginBuildEntry.js +2 -2
  52. package/dist/esm/node/plugin/plugins/commonConfig.js +15 -4
  53. package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +2 -0
  54. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +3 -1
  55. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +9 -1
  56. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +75 -21
  57. package/dist/esm/node/plugin/shared/getEnvVarObject.d.ts +3 -1
  58. package/dist/esm/node/plugin/shared/getEnvVarObject.js +9 -8
  59. package/dist/esm/node/plugin/shared/loggerNotProd/log.js +2 -2
  60. package/dist/esm/node/prerender/resolvePrerenderConfig.js +26 -18
  61. package/dist/esm/node/prerender/runPrerender.js +3 -3
  62. package/dist/esm/node/prerender/utils.d.ts +1 -1
  63. package/dist/esm/node/prerender/utils.js +1 -1
  64. package/dist/esm/node/runtime/globalContext.js +10 -6
  65. package/dist/esm/node/runtime/index-deprecated.d.ts +1 -3
  66. package/dist/esm/node/runtime/utils.d.ts +0 -1
  67. package/dist/esm/node/runtime/utils.js +0 -1
  68. package/dist/esm/node/runtime-dev/createDevMiddleware.js +10 -8
  69. package/dist/esm/node/shared/assertV1Design.js +2 -1
  70. package/dist/esm/node/shared/utils.d.ts +0 -1
  71. package/dist/esm/node/shared/utils.js +0 -1
  72. package/dist/esm/shared/page-configs/Config.d.ts +19 -1
  73. package/dist/esm/shared/page-configs/PageConfig.d.ts +16 -5
  74. package/dist/esm/shared/page-configs/getConfigDefinedAt.d.ts +3 -3
  75. package/dist/esm/shared/page-configs/getConfigDefinedAt.js +19 -3
  76. package/dist/esm/shared/page-configs/getConfigValueBuildTime.js +8 -5
  77. package/dist/esm/shared/page-configs/helpers.js +1 -1
  78. package/dist/esm/shared/page-configs/serialize/parsePageConfigs.d.ts +1 -1
  79. package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +2 -5
  80. package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +3 -3
  81. package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +6 -2
  82. package/dist/esm/shared/route/loadPageRoutes.js +2 -2
  83. package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
  84. package/dist/esm/utils/PROJECT_VERSION.js +1 -1
  85. package/dist/esm/utils/assert.js +2 -2
  86. package/dist/esm/utils/assertSingleInstance.js +11 -17
  87. package/package.json +3 -3
  88. package/dist/cjs/utils/projectInfo.js +0 -8
  89. package/dist/esm/utils/projectInfo.d.ts +0 -4
  90. package/dist/esm/utils/projectInfo.js +0 -5
@@ -25,7 +25,7 @@ export { updateUserFiles };
25
25
  // - Without vike-server it's manually loaded here using importServerProductionEntry() which uses @brillout/vite-plugin-server-entry's autoImporter or crawler
26
26
  // - In development: globalObject.viteDevServer which is Vite's development server
27
27
  // - globalObject.viteDevServer is used by updateUserFiles() which then sets globalConfig.userFiles
28
- import { assert, onSetupRuntime, assertUsage, assertWarning, isPlainObject, objectAssign, objectReplace, isObject, hasProp, debugGlob, getGlobalObject, genPromise, createDebugger, makePublicCopy, projectInfo, checkType } from './utils.js';
28
+ import { assert, onSetupRuntime, assertUsage, assertWarning, isPlainObject, objectAssign, objectReplace, isObject, hasProp, debugGlob, getGlobalObject, genPromise, createDebugger, makePublicCopy, checkType, PROJECT_VERSION } from './utils.js';
29
29
  import { importServerProductionEntry } from '@brillout/vite-plugin-server-entry/runtime';
30
30
  import { virtualFileIdImportUserCodeServer } from '../shared/virtual-files/virtualFileImportUserCode.js';
31
31
  import pc from '@brillout/picocolors';
@@ -89,9 +89,10 @@ function makePublic(globalContext) {
89
89
  async function setGlobalContext_viteDevServer(viteDevServer) {
90
90
  debug('setGlobalContext_viteDevServer()');
91
91
  setIsProduction(false);
92
- if (globalObject.viteDevServer)
93
- return;
94
- assertIsNotInitilizedYet();
92
+ /* We cannot cache globalObject.viteDevServer because it's fully replaced when the user modifies vite.config.js => Vite's dev server is fully reloaded and a new viteDevServer replaces the previous one.
93
+ if (globalObject.viteDevServer) return
94
+ assertIsNotInitilizedYet()
95
+ */
95
96
  assert(globalObject.viteConfig);
96
97
  globalObject.viteDevServer = viteDevServer;
97
98
  await updateUserFiles();
@@ -351,7 +352,7 @@ function assertBuildInfo(buildInfo) {
351
352
  checkType({ ...buildInfo, viteConfigRuntime: buildInfo.viteConfigRuntime });
352
353
  }
353
354
  function assertVersionAtBuildTime(versionAtBuildTime) {
354
- const versionAtRuntime = projectInfo.projectVersion;
355
+ const versionAtRuntime = PROJECT_VERSION;
355
356
  const pretty = (version) => pc.bold(`vike@${version}`);
356
357
  assertUsage(versionAtBuildTime === versionAtRuntime, `Re-build your app (you're using ${pretty(versionAtRuntime)} but your app was built with ${pretty(versionAtBuildTime)})`);
357
358
  }
@@ -369,7 +370,7 @@ async function updateUserFiles() {
369
370
  const { promise, resolve } = genPromise();
370
371
  assert(!globalObject.isProduction);
371
372
  globalObject.waitForUserFilesUpdate = promise;
372
- const viteDevServer = getViteDevServer();
373
+ const { viteDevServer } = globalObject;
373
374
  assert(viteDevServer);
374
375
  let virtualFileExports;
375
376
  try {
@@ -381,6 +382,9 @@ async function updateUserFiles() {
381
382
  }
382
383
  virtualFileExports = virtualFileExports.default || virtualFileExports;
383
384
  debugGlob('Glob result: ', virtualFileExports);
385
+ // Avoid race condition: abort if there is a new globalObject.viteDevServer (happens when vite.config.js is modified => Vite's dev server is fully reloaded).
386
+ if (viteDevServer !== globalObject.viteDevServer)
387
+ return;
384
388
  await setUserFiles(virtualFileExports);
385
389
  resolve();
386
390
  }
@@ -13,6 +13,4 @@ import { RenderErrorPage as RenderErrorPage_ } from '../../shared/route/abort.js
13
13
  *
14
14
  * See https://vike.dev/render
15
15
  */
16
- export declare const RenderErrorPage: (args_0?: {
17
- pageContext?: Record<string, unknown>;
18
- } | undefined) => Error;
16
+ export declare const RenderErrorPage: (...args: Parameters<typeof RenderErrorPage_>) => Error;
@@ -11,7 +11,6 @@ export * from '../../utils/parseUrl.js';
11
11
  export * from '../../utils/parseUrl-extras.js';
12
12
  export * from '../../utils/slice.js';
13
13
  export * from '../../utils/sorter.js';
14
- export * from '../../utils/projectInfo.js';
15
14
  export * from '../../utils/isArray.js';
16
15
  export * from '../../utils/isObject.js';
17
16
  export * from '../../utils/objectAssign.js';
@@ -15,7 +15,6 @@ export * from '../../utils/parseUrl.js';
15
15
  export * from '../../utils/parseUrl-extras.js';
16
16
  export * from '../../utils/slice.js';
17
17
  export * from '../../utils/sorter.js';
18
- export * from '../../utils/projectInfo.js';
19
18
  export * from '../../utils/isArray.js';
20
19
  export * from '../../utils/isObject.js';
21
20
  export * from '../../utils/objectAssign.js';
@@ -9,16 +9,18 @@ import { setGlobalContext_isProduction } from '../runtime/globalContext.js';
9
9
  */
10
10
  async function createDevMiddleware(options = {}) {
11
11
  setGlobalContext_isProduction(false);
12
- const viteConfigFromOptions = {
13
- ...options.viteConfig,
14
- server: {
15
- ...options.viteConfig?.server,
16
- middlewareMode: options.viteConfig?.server?.middlewareMode ?? true
12
+ const optionsMod = {
13
+ ...options,
14
+ viteConfig: {
15
+ ...options.viteConfig,
16
+ root: options.root ?? options.viteConfig?.root,
17
+ server: {
18
+ ...options.viteConfig?.server,
19
+ middlewareMode: options.viteConfig?.server?.middlewareMode ?? true
20
+ }
17
21
  }
18
22
  };
19
- if (options.root)
20
- viteConfigFromOptions.root = options.root;
21
- const { viteConfigEnhanced } = await prepareViteApiCall(viteConfigFromOptions, 'dev');
23
+ const { viteConfigEnhanced } = await prepareViteApiCall(optionsMod, 'dev');
22
24
  const server = await createServer(viteConfigEnhanced);
23
25
  const devMiddleware = server.middlewares;
24
26
  return { devMiddleware, viteServer: server, viteConfig: server.config };
@@ -10,7 +10,8 @@ function assertV1Design(pageConfigs, pageFilesAll) {
10
10
  assert(pageConfigs.length > 0);
11
11
  const filesV1 = unique(pageConfigs
12
12
  .map((p) => Object.values(p.configValueSources).map((sources) => sources
13
- .map((c) => c.definedAtFilePath.filePathAbsoluteUserRootDir)
13
+ .map((c) => c.definedAtFilePath)
14
+ .map((definedAt) => (definedAt.definedBy ? null : definedAt.filePathAbsoluteUserRootDir))
14
15
  .filter(isNotNullish)
15
16
  .map((filePathToShowToUser) => indent + filePathToShowToUser)))
16
17
  .flat(2));
@@ -1,7 +1,6 @@
1
1
  export * from '../../utils/assert.js';
2
2
  export * from '../../utils/getFileExtension.js';
3
3
  export * from '../../utils/isPlainObject.js';
4
- export * from '../../utils/projectInfo.js';
5
4
  export * from '../../utils/checkType.js';
6
5
  export * from '../../utils/hasProp.js';
7
6
  export * from '../../utils/objectAssign.js';
@@ -3,7 +3,6 @@ assertIsNotBrowser();
3
3
  export * from '../../utils/assert.js';
4
4
  export * from '../../utils/getFileExtension.js';
5
5
  export * from '../../utils/isPlainObject.js';
6
- export * from '../../utils/projectInfo.js';
7
6
  export * from '../../utils/checkType.js';
8
7
  export * from '../../utils/hasProp.js';
9
8
  export * from '../../utils/objectAssign.js';
@@ -297,7 +297,9 @@ type ConfigBuiltIn = {
297
297
  */
298
298
  disableAutoRun?: boolean;
299
299
  /**
300
- * Set prerender settings without enabling pre-rendering.
300
+ * Whether to enable pre-rendering.
301
+ *
302
+ * Setting `value: null` enables you to set prerender settings without activating pre-rendering. (Useful for Vike extensions.)
301
303
  *
302
304
  * https://vike.dev/prerender#value
303
305
  *
@@ -471,6 +473,22 @@ type ConfigBuiltIn = {
471
473
  * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
472
474
  */
473
475
  cacheControl?: string;
476
+ /**
477
+ * Make development/preview server available over LAN and public addresses.
478
+ *
479
+ * Default: `false` (or `true` if running inside Docker/Podman).
480
+ *
481
+ * https://vike.dev/host
482
+ */
483
+ host?: boolean | string;
484
+ /**
485
+ * Change port of development/preview server.
486
+ *
487
+ * @default 3000
488
+ *
489
+ * https://vike.dev/port
490
+ */
491
+ port?: number;
474
492
  /** Where scripts are injected in the HTML.
475
493
  *
476
494
  * https://vike.dev/injectScriptsAt
@@ -17,12 +17,15 @@ export type { ConfigValueSources };
17
17
  export type { ConfigValuesComputed };
18
18
  export type { DefinedAtData };
19
19
  export type { DefinedAtFile };
20
+ export type { DefinedAt };
21
+ export type { DefinedBy };
20
22
  export type { DefinedAtFilePath };
21
23
  import type { ConfigValueSerialized } from './serialize/PageConfigSerialized.js';
22
24
  import type { LocationId } from '../../node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js';
23
25
  import type { FilePath } from './FilePath.js';
24
26
  import type { ConfigDefinitions } from '../../node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js';
25
27
  import type { PlusFile } from '../../node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.js';
28
+ import type { Operation } from '../../node/api/types.js';
26
29
  type PageConfigCommon = {
27
30
  pageId: string;
28
31
  } & PageConfigRoute;
@@ -33,7 +36,7 @@ type PageConfigRoute = {
33
36
  isErrorPage?: undefined;
34
37
  routeFilesystem: {
35
38
  routeString: string;
36
- definedBy: string;
39
+ definedAtLocation: string;
37
40
  };
38
41
  };
39
42
  /** Page config, runtime data structure */
@@ -89,7 +92,7 @@ type ConfigValueSources = Record<string, // configName
89
92
  ConfigValueSource[]>;
90
93
  type ConfigValueSource = {
91
94
  configEnv: ConfigEnvInternal;
92
- definedAtFilePath: DefinedAtFilePath;
95
+ definedAtFilePath: DefinedAtFilePath | DefinedBy;
93
96
  plusFile: PlusFile | null;
94
97
  locationId: LocationId;
95
98
  /** Wether the config value is loaded at runtime, for example config.Page or config.onBeforeRender */
@@ -119,13 +122,13 @@ type ConfigValue = ConfigValueStandard | ConfigValueCumulative | ConfigValueComp
119
122
  type ConfigValueStandard = {
120
123
  type: 'standard';
121
124
  value: unknown;
122
- definedAtData: DefinedAtFile;
125
+ definedAtData: DefinedAt;
123
126
  };
124
127
  /** Defined by multiple sources (thus multiple file paths). */
125
128
  type ConfigValueCumulative = {
126
129
  type: 'cumulative';
127
130
  value: unknown[];
128
- definedAtData: DefinedAtFile[];
131
+ definedAtData: DefinedAt[];
129
132
  };
130
133
  /** Defined internally by Vike (currently, Vike doesn't support computed configs created by users). */
131
134
  type ConfigValueComputed = {
@@ -133,8 +136,16 @@ type ConfigValueComputed = {
133
136
  value: unknown;
134
137
  definedAtData: null;
135
138
  };
136
- type DefinedAtData = DefinedAtFile | DefinedAtFile[] | null;
139
+ type DefinedAtData = DefinedAt | DefinedAt[] | null;
140
+ type DefinedAt = DefinedAtFile | DefinedBy;
141
+ type DefinedBy = {
142
+ definedBy: 'cli' | 'env';
143
+ } | {
144
+ definedBy: 'api';
145
+ operation: Operation;
146
+ };
137
147
  type DefinedAtFile = {
138
148
  filePathToShowToUser: string;
139
149
  fileExportPathToShowToUser: null | string[];
150
+ definedBy?: undefined;
140
151
  };
@@ -3,9 +3,9 @@ export { getConfigDefinedAtOptional };
3
3
  export { getDefinedAtString };
4
4
  export type { ConfigDefinedAt };
5
5
  export type { ConfigDefinedAtOptional };
6
- import type { DefinedAtData, DefinedAtFile } from './PageConfig.js';
6
+ import type { DefinedAtData } from './PageConfig.js';
7
7
  type ConfigDefinedAtOptional = ConfigDefinedAt | `Config ${string} defined internally`;
8
8
  type ConfigDefinedAt = `Config ${string} defined at ${string}`;
9
- declare function getConfigDefinedAt<SentenceBegin extends 'Config' | 'config', ConfigName extends string>(sentenceBegin: SentenceBegin, configName: ConfigName, definedAtData: DefinedAtFile | DefinedAtFile[]): `${SentenceBegin} ${ConfigName} defined at ${string}`;
9
+ declare function getConfigDefinedAt<SentenceBegin extends 'Config' | 'config', ConfigName extends string>(sentenceBegin: SentenceBegin, configName: ConfigName, definedAtData: NonNullable<DefinedAtData>): `${SentenceBegin} ${ConfigName} defined at ${string}`;
10
10
  declare function getConfigDefinedAtOptional<SentenceBegin extends 'Config' | 'config', ConfigName extends string>(sentenceBegin: SentenceBegin, configName: ConfigName, definedAtData: DefinedAtData): `${SentenceBegin} ${ConfigName} defined ${'internally' | `at ${string}`}`;
11
- declare function getDefinedAtString(definedAtData: DefinedAtFile | DefinedAtFile[], configName: string): string;
11
+ declare function getDefinedAtString(definedAtData: NonNullable<DefinedAtData>, configName: string): string;
@@ -1,7 +1,7 @@
1
1
  export { getConfigDefinedAt };
2
2
  export { getConfigDefinedAtOptional };
3
3
  export { getDefinedAtString };
4
- import { assert, isArray } from '../utils.js';
4
+ import { assert, checkType, isArray } from '../utils.js';
5
5
  import pc from '@brillout/picocolors';
6
6
  import { getExportPath } from './getExportPath.js';
7
7
  function getConfigDefinedAt(sentenceBegin, configName, definedAtData) {
@@ -28,8 +28,10 @@ function getDefinedAtString(definedAtData, configName) {
28
28
  }
29
29
  assert(files.length >= 1);
30
30
  const definedAtString = files
31
- .map((source) => {
32
- const { filePathToShowToUser, fileExportPathToShowToUser } = source;
31
+ .map((definedAt) => {
32
+ if (definedAt.definedBy)
33
+ return getDefinedByString(definedAt, configName);
34
+ const { filePathToShowToUser, fileExportPathToShowToUser } = definedAt;
33
35
  let s = filePathToShowToUser;
34
36
  const exportPath = getExportPath(fileExportPathToShowToUser, configName);
35
37
  if (exportPath) {
@@ -40,3 +42,17 @@ function getDefinedAtString(definedAtData, configName) {
40
42
  .join(' / ');
41
43
  return definedAtString;
42
44
  }
45
+ function getDefinedByString(definedAt, configName) {
46
+ if (definedAt.definedBy === 'api') {
47
+ return `API call ${pc.cyan(`${definedAt.operation}({${configName}})`)}`;
48
+ }
49
+ const { definedBy } = definedAt;
50
+ if (definedBy === 'cli') {
51
+ return `CLI option ${pc.cyan(`--${configName}`)}`;
52
+ }
53
+ if (definedBy === 'env') {
54
+ return `environment variable ${pc.cyan(`VIKE_OPTIONS="{${configName}}"`)}`;
55
+ }
56
+ checkType(definedBy);
57
+ assert(false);
58
+ }
@@ -31,7 +31,7 @@ function getConfigValue(pageConfig, configName) {
31
31
  return {
32
32
  type: 'standard',
33
33
  value: configValueSource.value,
34
- definedAtData: getDefinedAtFile(configValueSource)
34
+ definedAtData: getDefinedAt(configValueSource)
35
35
  };
36
36
  }
37
37
  else {
@@ -51,13 +51,16 @@ function mergeCumulative(configValueSources) {
51
51
  assert(configValueSource.configEnv.config === true);
52
52
  assert(configValueSource.valueIsLoaded);
53
53
  value.push(configValueSource.value);
54
- definedAtData.push(getDefinedAtFile(configValueSource));
54
+ definedAtData.push(getDefinedAt(configValueSource));
55
55
  });
56
56
  return { value, definedAtData };
57
57
  }
58
- function getDefinedAtFile(configValueSource) {
58
+ function getDefinedAt(configValueSource) {
59
+ const { definedAtFilePath } = configValueSource;
60
+ if (definedAtFilePath.definedBy)
61
+ return definedAtFilePath;
59
62
  return {
60
- filePathToShowToUser: configValueSource.definedAtFilePath.filePathToShowToUser,
61
- fileExportPathToShowToUser: configValueSource.definedAtFilePath.fileExportPathToShowToUser
63
+ filePathToShowToUser: definedAtFilePath.filePathToShowToUser,
64
+ fileExportPathToShowToUser: definedAtFilePath.fileExportPathToShowToUser
62
65
  };
63
66
  }
@@ -12,7 +12,7 @@ function getConfigValueFilePathToShowToUser(definedAtData) {
12
12
  // A unique file path only exists if the config value isn't cumulative nor computed:
13
13
  // - cumulative config values have multiple file paths
14
14
  // - computed values don't have any file path
15
- if (!definedAtData || isArray(definedAtData))
15
+ if (!definedAtData || isArray(definedAtData) || definedAtData.definedBy)
16
16
  return null;
17
17
  const { filePathToShowToUser } = definedAtData;
18
18
  assert(filePathToShowToUser);
@@ -3,8 +3,8 @@ export { parseConfigValuesSerialized };
3
3
  import type { ConfigValues, PageConfigRuntime, PageConfigGlobalRuntime } from '../PageConfig.js';
4
4
  import type { PageConfigGlobalRuntimeSerialized, PageConfigRuntimeSerialized } from './PageConfigSerialized.js';
5
5
  import type { ConfigValueSerialized } from './PageConfigSerialized.js';
6
- declare function parseConfigValuesSerialized(configValuesSerialized: Record<string, ConfigValueSerialized>): ConfigValues;
7
6
  declare function parsePageConfigs(pageConfigsSerialized: PageConfigRuntimeSerialized[], pageConfigGlobalSerialized: PageConfigGlobalRuntimeSerialized): {
8
7
  pageConfigs: PageConfigRuntime[];
9
8
  pageConfigGlobal: PageConfigGlobalRuntime;
10
9
  };
10
+ declare function parseConfigValuesSerialized(configValuesSerialized: Record<string, ConfigValueSerialized>): ConfigValues;
@@ -4,10 +4,6 @@ import { assert, assertUsage, isCallable } from '../../utils.js';
4
4
  import { getConfigDefinedAt } from '../getConfigDefinedAt.js';
5
5
  import { parseTransform } from '@brillout/json-serializer/parse';
6
6
  import { assertPlusFileExport } from '../assertPlusFileExport.js';
7
- function parseConfigValuesSerialized(configValuesSerialized) {
8
- const configValues = parseConfigValuesSerialized_tmp(configValuesSerialized);
9
- return configValues;
10
- }
11
7
  function parsePageConfigs(pageConfigsSerialized, pageConfigGlobalSerialized) {
12
8
  // pageConfigs
13
9
  const pageConfigs = pageConfigsSerialized.map((pageConfigSerialized) => {
@@ -43,7 +39,7 @@ function assertRouteConfigValue(configValues) {
43
39
  }
44
40
  */
45
41
  }
46
- function parseConfigValuesSerialized_tmp(configValuesSerialized) {
42
+ function parseConfigValuesSerialized(configValuesSerialized) {
47
43
  const configValues = {};
48
44
  Object.entries(configValuesSerialized).forEach(([configName, configValueSeriliazed]) => {
49
45
  let configValue;
@@ -100,6 +96,7 @@ function parseValueSerialized(valueSerialized, configName, getDefinedAtFile) {
100
96
  if (valueSerialized.type === 'plus-file') {
101
97
  const definedAtFile = getDefinedAtFile();
102
98
  const { exportValues } = valueSerialized;
99
+ assert(!definedAtFile.definedBy);
103
100
  assertPlusFileExport(exportValues, definedAtFile.filePathToShowToUser, configName);
104
101
  let value;
105
102
  let valueWasFound = false;
@@ -2,7 +2,7 @@ export { serializeConfigValues };
2
2
  export { getConfigValuesBase };
3
3
  export { isJsonValue };
4
4
  export type { FilesEnv };
5
- import type { ConfigEnvInternal, ConfigValueSource, DefinedAtFile, PageConfigBuildTime, PageConfigGlobalBuildTime } from '../PageConfig.js';
5
+ import type { ConfigEnvInternal, ConfigValueSource, DefinedAt, PageConfigBuildTime, PageConfigGlobalBuildTime } from '../PageConfig.js';
6
6
  declare function serializeConfigValues(pageConfig: PageConfigBuildTime | PageConfigGlobalBuildTime, importStatements: string[], filesEnv: FilesEnv, isEnvMatch: (configEnv: ConfigEnvInternal) => boolean, tabspace: string, isEager: boolean | null): string[];
7
7
  declare function isJsonValue(value: unknown): boolean;
8
8
  declare function getConfigValuesBase(pageConfig: PageConfigBuildTime | PageConfigGlobalBuildTime, isEnvMatch: (configEnv: ConfigEnvInternal) => boolean, isEager: boolean | null): ConfigValuesBase;
@@ -17,14 +17,14 @@ type ConfigValuesBase = ({
17
17
  } | {
18
18
  configValueBase: {
19
19
  type: 'standard';
20
- definedAtData: DefinedAtFile;
20
+ definedAtData: DefinedAt;
21
21
  };
22
22
  sourceRelevant: ConfigValueSource;
23
23
  configName: string;
24
24
  } | {
25
25
  configValueBase: {
26
26
  type: 'cumulative';
27
- definedAtData: DefinedAtFile[];
27
+ definedAtData: DefinedAt[];
28
28
  };
29
29
  sourcesRelevant: ConfigValueSource[];
30
30
  configName: string;
@@ -99,6 +99,7 @@ function serializeConfigValue(configValueBase, valueData, configName, lines, tab
99
99
  function getValueSerializedWithImport(configValueSource, importStatements, filesEnv, configName) {
100
100
  assert(!configValueSource.valueIsFilePath);
101
101
  const { valueIsDefinedByPlusValueFile, definedAtFilePath, configEnv } = configValueSource;
102
+ assert(!definedAtFilePath.definedBy);
102
103
  const { filePathAbsoluteVite, fileExportName } = definedAtFilePath;
103
104
  if (valueIsDefinedByPlusValueFile)
104
105
  assert(fileExportName === undefined);
@@ -226,9 +227,12 @@ function getConfigValuesBase(pageConfig, isEnvMatch, isEager) {
226
227
  return [...fromComputed, ...fromSources].filter((r) => r !== 'SKIP');
227
228
  }
228
229
  function getDefinedAtFileSource(source) {
230
+ const { definedAtFilePath } = source;
231
+ if (definedAtFilePath.definedBy)
232
+ return definedAtFilePath;
229
233
  const definedAtFile = {
230
- filePathToShowToUser: source.definedAtFilePath.filePathToShowToUser,
231
- fileExportPathToShowToUser: source.definedAtFilePath.fileExportPathToShowToUser
234
+ filePathToShowToUser: definedAtFilePath.filePathToShowToUser,
235
+ fileExportPathToShowToUser: definedAtFilePath.fileExportPathToShowToUser
232
236
  };
233
237
  return definedAtFile;
234
238
  }
@@ -60,11 +60,11 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
60
60
  if (!pageRoute) {
61
61
  const { routeFilesystem } = pageConfig;
62
62
  assert(routeFilesystem);
63
- const { routeString, definedBy } = routeFilesystem;
63
+ const { routeString, definedAtLocation } = routeFilesystem;
64
64
  assert(routeFilesystem.routeString.startsWith('/'));
65
65
  pageRoute = {
66
66
  pageId,
67
- routeFilesystemDefinedBy: definedBy,
67
+ routeFilesystemDefinedBy: definedAtLocation,
68
68
  comesFromV1PageConfig,
69
69
  routeString,
70
70
  routeDefinedAtString: null,
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.224-commit-00ed9fe";
1
+ export declare const PROJECT_VERSION: "0.4.225";
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.224-commit-00ed9fe';
2
+ export const PROJECT_VERSION = '0.4.225';
@@ -12,7 +12,7 @@ import { assertSingleInstance_onAssertModuleLoad } from './assertSingleInstance.
12
12
  import { createErrorWithCleanStackTrace } from './createErrorWithCleanStackTrace.js';
13
13
  import { getGlobalObject } from './getGlobalObject.js';
14
14
  import { isObject } from './isObject.js';
15
- import { projectInfo } from './projectInfo.js';
15
+ import { PROJECT_VERSION } from './PROJECT_VERSION.js';
16
16
  import pc from '@brillout/picocolors';
17
17
  const globalObject = getGlobalObject('utils/assert.ts', {
18
18
  alreadyLogged: new Set(),
@@ -29,7 +29,7 @@ const globalObject = getGlobalObject('utils/assert.ts', {
29
29
  });
30
30
  assertSingleInstance_onAssertModuleLoad();
31
31
  const projectTag = `[vike]`;
32
- const projectTagWithVersion = `[vike@${projectInfo.projectVersion}]`;
32
+ const projectTagWithVersion = `[vike@${PROJECT_VERSION}]`;
33
33
  const bugTag = 'Bug';
34
34
  const numberOfStackTraceLinesToRemove = 2;
35
35
  function assert(condition, debugInfo) {
@@ -1,15 +1,15 @@
1
1
  export { assertSingleInstance_onClientEntryServerRouting };
2
2
  export { assertSingleInstance_onClientEntryClientRouting };
3
3
  export { assertSingleInstance_onAssertModuleLoad };
4
- // - Throw error if there are two different versions of vike loaded
4
+ // - Show warning if there are two different Vike versions loaded
5
5
  // - Show warning if entry of Client Routing and entry of Server Routing are both loaded
6
- // - Show warning if vike is loaded twice
6
+ // - Show warning if Vike is loaded twice
7
7
  import { unique } from './unique.js';
8
8
  import { getGlobalObject } from './getGlobalObject.js';
9
- import { projectInfo } from './projectInfo.js';
10
9
  import pc from '@brillout/picocolors';
11
- /* Use original assertUsage() & assertWarning() after all CJS is removed from node_modules/vike/dist/
12
- import { assertUsage, assertWarning } from './assert.js'
10
+ import { PROJECT_VERSION } from './PROJECT_VERSION.js';
11
+ /* Use original assertWarning() after all CJS is removed from node_modules/vike/dist/
12
+ import { assertWarning } from './assert.js'
13
13
  */
14
14
  const globalObject = getGlobalObject('utils/assertSingleInstance.ts', {
15
15
  instances: [],
@@ -20,9 +20,10 @@ const clientNotSingleInstance = 'Client runtime loaded twice https://vike.dev/cl
20
20
  function assertSingleInstance() {
21
21
  {
22
22
  const versions = unique(globalObject.instances);
23
- assertUsage(versions.length <= 1,
24
- // DO *NOT* patch vike to remove this error: because of multiple conflicting versions, you *will* eventually encounter insidious issues that hard to debug and potentially a security hazard, see for example https://github.com/vikejs/vike/issues/1108
25
- `vike@${pc.bold(versions[0])} and vike@${pc.bold(versions[1])} loaded but it's forbidden to load different versions`);
23
+ assertWarning(versions.length <= 1,
24
+ // Do *NOT* patch Vike to remove this warning: you *will* eventually encounter the issues listed at https://vike.dev/warning/version-mismatch
25
+ // - This happened before: https://github.com/vikejs/vike/issues/1108#issuecomment-1719061509
26
+ `vike@${pc.bold(versions[0])} and vike@${pc.bold(versions[1])} loaded which is highly discouraged, see ${pc.underline('https://vike.dev/warning/version-mismatch')}`, { onlyOnce: true, showStackTrace: false });
26
27
  }
27
28
  if (globalObject.checkSingleInstance && globalObject.instances.length > 1) {
28
29
  /*/ Not sure whether circular dependency can cause problems? In principle not since client-side code is ESM.
@@ -62,21 +63,14 @@ function assertSingleInstance_onClientEntryClientRouting(isProduction) {
62
63
  }
63
64
  // Called by utils/assert.ts which is (most certainly) loaded by all entries. That way we don't have to call a callback for every entry. (There are a lot of entries: `client/router/`, `client/`, `node/runtime/`, `node/plugin/`, `node/cli`.)
64
65
  function assertSingleInstance_onAssertModuleLoad() {
65
- globalObject.instances.push(projectInfo.projectVersion);
66
+ globalObject.instances.push(PROJECT_VERSION);
66
67
  assertSingleInstance();
67
68
  }
68
- function assertUsage(condition, errorMessage) {
69
- if (condition) {
70
- return;
71
- }
72
- const errMsg = `[vike][Wrong Usage] ${errorMessage}`;
73
- throw new Error(errMsg);
74
- }
75
69
  function assertWarning(condition, errorMessage, { onlyOnce, showStackTrace }) {
76
70
  if (condition) {
77
71
  return;
78
72
  }
79
- const msg = `[vike][Warning] ${errorMessage}`;
73
+ const msg = `[Vike][Warning] ${errorMessage}`;
80
74
  if (onlyOnce) {
81
75
  const { alreadyLogged } = globalObject;
82
76
  const key = onlyOnce === true ? msg : onlyOnce;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.224-commit-00ed9fe",
3
+ "version": "0.4.225",
4
4
  "repository": "https://github.com/vikejs/vike",
5
5
  "exports": {
6
6
  "./server": {
@@ -254,8 +254,8 @@
254
254
  "@types/source-map-support": "^0.5.10",
255
255
  "react-streaming": "^0.3.47",
256
256
  "rimraf": "^5.0.5",
257
- "typescript": "^5.7.3",
258
- "vite": "^6.2.0"
257
+ "typescript": "^5.8.2",
258
+ "vite": "^6.2.1"
259
259
  },
260
260
  "scripts": {
261
261
  "dev": "tsc --watch",
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.projectInfo = void 0;
4
- const PROJECT_VERSION_js_1 = require("./PROJECT_VERSION.js");
5
- exports.projectInfo = {
6
- projectName: 'Vike',
7
- projectVersion: PROJECT_VERSION_js_1.PROJECT_VERSION
8
- };
@@ -1,4 +0,0 @@
1
- export declare const projectInfo: {
2
- projectName: "Vike";
3
- projectVersion: "0.4.224-commit-00ed9fe";
4
- };
@@ -1,5 +0,0 @@
1
- import { PROJECT_VERSION } from './PROJECT_VERSION.js';
2
- export const projectInfo = {
3
- projectName: 'Vike',
4
- projectVersion: PROJECT_VERSION
5
- };