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
@@ -76,7 +76,7 @@ async function runPrerenderFromAPI(options = {}) {
76
76
  }
77
77
  async function runPrerenderFromCLIPrerenderCommand() {
78
78
  try {
79
- const { viteConfigEnhanced } = await (0, prepareViteApiCall_js_1.prepareViteApiCall)(undefined, 'prerender');
79
+ const { viteConfigEnhanced } = await (0, prepareViteApiCall_js_1.prepareViteApiCall)({}, 'prerender');
80
80
  await runPrerender({ viteConfig: viteConfigEnhanced }, '$ vike prerender');
81
81
  }
82
82
  catch (err) {
@@ -113,7 +113,7 @@ async function runPrerender(options = {}, standaloneTrigger) {
113
113
  (0, getHook_js_1.getHook_setIsPrerenderering)();
114
114
  const logLevel = !!options.onPagePrerender ? 'warn' : 'info';
115
115
  if (logLevel === 'info') {
116
- console.log(`${picocolors_1.default.cyan(`vike v${utils_js_1.projectInfo.projectVersion}`)} ${picocolors_1.default.green('pre-rendering HTML...')}`);
116
+ console.log(`${picocolors_1.default.cyan(`vike v${utils_js_1.PROJECT_VERSION}`)} ${picocolors_1.default.green('pre-rendering HTML...')}`);
117
117
  }
118
118
  await disableReactStreaming();
119
119
  const viteConfig = await (0, vite_1.resolveConfig)(options.viteConfig || {}, 'build', 'production');
@@ -18,7 +18,7 @@ const assertIsNotBrowser_js_1 = require("../../utils/assertIsNotBrowser.js");
18
18
  (0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
19
19
  __exportStar(require("../../utils/assert.js"), exports);
20
20
  __exportStar(require("../../utils/hasProp.js"), exports);
21
- __exportStar(require("../../utils/projectInfo.js"), exports);
21
+ __exportStar(require("../../utils/PROJECT_VERSION.js"), exports);
22
22
  __exportStar(require("../../utils/objectAssign.js"), exports);
23
23
  __exportStar(require("../../utils/isObjectWithKeys.js"), exports);
24
24
  __exportStar(require("../../utils/isCallable.js"), exports);
@@ -92,9 +92,10 @@ function makePublic(globalContext) {
92
92
  async function setGlobalContext_viteDevServer(viteDevServer) {
93
93
  debug('setGlobalContext_viteDevServer()');
94
94
  setIsProduction(false);
95
- if (globalObject.viteDevServer)
96
- return;
97
- assertIsNotInitilizedYet();
95
+ /* 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.
96
+ if (globalObject.viteDevServer) return
97
+ assertIsNotInitilizedYet()
98
+ */
98
99
  (0, utils_js_1.assert)(globalObject.viteConfig);
99
100
  globalObject.viteDevServer = viteDevServer;
100
101
  await updateUserFiles();
@@ -354,7 +355,7 @@ function assertBuildInfo(buildInfo) {
354
355
  (0, utils_js_1.checkType)({ ...buildInfo, viteConfigRuntime: buildInfo.viteConfigRuntime });
355
356
  }
356
357
  function assertVersionAtBuildTime(versionAtBuildTime) {
357
- const versionAtRuntime = utils_js_1.projectInfo.projectVersion;
358
+ const versionAtRuntime = utils_js_1.PROJECT_VERSION;
358
359
  const pretty = (version) => picocolors_1.default.bold(`vike@${version}`);
359
360
  (0, utils_js_1.assertUsage)(versionAtBuildTime === versionAtRuntime, `Re-build your app (you're using ${pretty(versionAtRuntime)} but your app was built with ${pretty(versionAtBuildTime)})`);
360
361
  }
@@ -372,7 +373,7 @@ async function updateUserFiles() {
372
373
  const { promise, resolve } = (0, utils_js_1.genPromise)();
373
374
  (0, utils_js_1.assert)(!globalObject.isProduction);
374
375
  globalObject.waitForUserFilesUpdate = promise;
375
- const viteDevServer = getViteDevServer();
376
+ const { viteDevServer } = globalObject;
376
377
  (0, utils_js_1.assert)(viteDevServer);
377
378
  let virtualFileExports;
378
379
  try {
@@ -384,6 +385,9 @@ async function updateUserFiles() {
384
385
  }
385
386
  virtualFileExports = virtualFileExports.default || virtualFileExports;
386
387
  (0, utils_js_1.debugGlob)('Glob result: ', virtualFileExports);
388
+ // 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).
389
+ if (viteDevServer !== globalObject.viteDevServer)
390
+ return;
387
391
  await setUserFiles(virtualFileExports);
388
392
  resolve();
389
393
  }
@@ -31,7 +31,6 @@ __exportStar(require("../../utils/parseUrl.js"), exports);
31
31
  __exportStar(require("../../utils/parseUrl-extras.js"), exports);
32
32
  __exportStar(require("../../utils/slice.js"), exports);
33
33
  __exportStar(require("../../utils/sorter.js"), exports);
34
- __exportStar(require("../../utils/projectInfo.js"), exports);
35
34
  __exportStar(require("../../utils/isArray.js"), exports);
36
35
  __exportStar(require("../../utils/isObject.js"), exports);
37
36
  __exportStar(require("../../utils/objectAssign.js"), exports);
@@ -11,16 +11,18 @@ const globalContext_js_1 = require("../runtime/globalContext.js");
11
11
  */
12
12
  async function createDevMiddleware(options = {}) {
13
13
  (0, globalContext_js_1.setGlobalContext_isProduction)(false);
14
- const viteConfigFromOptions = {
15
- ...options.viteConfig,
16
- server: {
17
- ...options.viteConfig?.server,
18
- middlewareMode: options.viteConfig?.server?.middlewareMode ?? true
14
+ const optionsMod = {
15
+ ...options,
16
+ viteConfig: {
17
+ ...options.viteConfig,
18
+ root: options.root ?? options.viteConfig?.root,
19
+ server: {
20
+ ...options.viteConfig?.server,
21
+ middlewareMode: options.viteConfig?.server?.middlewareMode ?? true
22
+ }
19
23
  }
20
24
  };
21
- if (options.root)
22
- viteConfigFromOptions.root = options.root;
23
- const { viteConfigEnhanced } = await (0, prepareViteApiCall_js_1.prepareViteApiCall)(viteConfigFromOptions, 'dev');
25
+ const { viteConfigEnhanced } = await (0, prepareViteApiCall_js_1.prepareViteApiCall)(optionsMod, 'dev');
24
26
  const server = await (0, vite_1.createServer)(viteConfigEnhanced);
25
27
  const devMiddleware = server.middlewares;
26
28
  return { devMiddleware, viteServer: server, viteConfig: server.config };
@@ -12,7 +12,8 @@ function assertV1Design(pageConfigs, pageFilesAll) {
12
12
  (0, utils_js_1.assert)(pageConfigs.length > 0);
13
13
  const filesV1 = (0, utils_js_1.unique)(pageConfigs
14
14
  .map((p) => Object.values(p.configValueSources).map((sources) => sources
15
- .map((c) => c.definedAtFilePath.filePathAbsoluteUserRootDir)
15
+ .map((c) => c.definedAtFilePath)
16
+ .map((definedAt) => (definedAt.definedBy ? null : definedAt.filePathAbsoluteUserRootDir))
16
17
  .filter(utils_js_1.isNotNullish)
17
18
  .map((filePathToShowToUser) => indent + filePathToShowToUser)))
18
19
  .flat(2));
@@ -19,7 +19,6 @@ const assertIsNotBrowser_js_1 = require("../../utils/assertIsNotBrowser.js");
19
19
  __exportStar(require("../../utils/assert.js"), exports);
20
20
  __exportStar(require("../../utils/getFileExtension.js"), exports);
21
21
  __exportStar(require("../../utils/isPlainObject.js"), exports);
22
- __exportStar(require("../../utils/projectInfo.js"), exports);
23
22
  __exportStar(require("../../utils/checkType.js"), exports);
24
23
  __exportStar(require("../../utils/hasProp.js"), exports);
25
24
  __exportStar(require("../../utils/objectAssign.js"), exports);
@@ -33,8 +33,10 @@ function getDefinedAtString(definedAtData, configName) {
33
33
  }
34
34
  (0, utils_js_1.assert)(files.length >= 1);
35
35
  const definedAtString = files
36
- .map((source) => {
37
- const { filePathToShowToUser, fileExportPathToShowToUser } = source;
36
+ .map((definedAt) => {
37
+ if (definedAt.definedBy)
38
+ return getDefinedByString(definedAt, configName);
39
+ const { filePathToShowToUser, fileExportPathToShowToUser } = definedAt;
38
40
  let s = filePathToShowToUser;
39
41
  const exportPath = (0, getExportPath_js_1.getExportPath)(fileExportPathToShowToUser, configName);
40
42
  if (exportPath) {
@@ -45,3 +47,17 @@ function getDefinedAtString(definedAtData, configName) {
45
47
  .join(' / ');
46
48
  return definedAtString;
47
49
  }
50
+ function getDefinedByString(definedAt, configName) {
51
+ if (definedAt.definedBy === 'api') {
52
+ return `API call ${picocolors_1.default.cyan(`${definedAt.operation}({${configName}})`)}`;
53
+ }
54
+ const { definedBy } = definedAt;
55
+ if (definedBy === 'cli') {
56
+ return `CLI option ${picocolors_1.default.cyan(`--${configName}`)}`;
57
+ }
58
+ if (definedBy === 'env') {
59
+ return `environment variable ${picocolors_1.default.cyan(`VIKE_OPTIONS="{${configName}}"`)}`;
60
+ }
61
+ (0, utils_js_1.checkType)(definedBy);
62
+ (0, utils_js_1.assert)(false);
63
+ }
@@ -33,7 +33,7 @@ function getConfigValue(pageConfig, configName) {
33
33
  return {
34
34
  type: 'standard',
35
35
  value: configValueSource.value,
36
- definedAtData: getDefinedAtFile(configValueSource)
36
+ definedAtData: getDefinedAt(configValueSource)
37
37
  };
38
38
  }
39
39
  else {
@@ -53,13 +53,16 @@ function mergeCumulative(configValueSources) {
53
53
  (0, utils_js_1.assert)(configValueSource.configEnv.config === true);
54
54
  (0, utils_js_1.assert)(configValueSource.valueIsLoaded);
55
55
  value.push(configValueSource.value);
56
- definedAtData.push(getDefinedAtFile(configValueSource));
56
+ definedAtData.push(getDefinedAt(configValueSource));
57
57
  });
58
58
  return { value, definedAtData };
59
59
  }
60
- function getDefinedAtFile(configValueSource) {
60
+ function getDefinedAt(configValueSource) {
61
+ const { definedAtFilePath } = configValueSource;
62
+ if (definedAtFilePath.definedBy)
63
+ return definedAtFilePath;
61
64
  return {
62
- filePathToShowToUser: configValueSource.definedAtFilePath.filePathToShowToUser,
63
- fileExportPathToShowToUser: configValueSource.definedAtFilePath.fileExportPathToShowToUser
65
+ filePathToShowToUser: definedAtFilePath.filePathToShowToUser,
66
+ fileExportPathToShowToUser: definedAtFilePath.fileExportPathToShowToUser
64
67
  };
65
68
  }
@@ -14,7 +14,7 @@ function getConfigValueFilePathToShowToUser(definedAtData) {
14
14
  // A unique file path only exists if the config value isn't cumulative nor computed:
15
15
  // - cumulative config values have multiple file paths
16
16
  // - computed values don't have any file path
17
- if (!definedAtData || (0, utils_js_1.isArray)(definedAtData))
17
+ if (!definedAtData || (0, utils_js_1.isArray)(definedAtData) || definedAtData.definedBy)
18
18
  return null;
19
19
  const { filePathToShowToUser } = definedAtData;
20
20
  (0, utils_js_1.assert)(filePathToShowToUser);
@@ -6,10 +6,6 @@ const utils_js_1 = require("../../utils.js");
6
6
  const getConfigDefinedAt_js_1 = require("../getConfigDefinedAt.js");
7
7
  const parse_1 = require("@brillout/json-serializer/parse");
8
8
  const assertPlusFileExport_js_1 = require("../assertPlusFileExport.js");
9
- function parseConfigValuesSerialized(configValuesSerialized) {
10
- const configValues = parseConfigValuesSerialized_tmp(configValuesSerialized);
11
- return configValues;
12
- }
13
9
  function parsePageConfigs(pageConfigsSerialized, pageConfigGlobalSerialized) {
14
10
  // pageConfigs
15
11
  const pageConfigs = pageConfigsSerialized.map((pageConfigSerialized) => {
@@ -45,7 +41,7 @@ function assertRouteConfigValue(configValues) {
45
41
  }
46
42
  */
47
43
  }
48
- function parseConfigValuesSerialized_tmp(configValuesSerialized) {
44
+ function parseConfigValuesSerialized(configValuesSerialized) {
49
45
  const configValues = {};
50
46
  Object.entries(configValuesSerialized).forEach(([configName, configValueSeriliazed]) => {
51
47
  let configValue;
@@ -102,6 +98,7 @@ function parseValueSerialized(valueSerialized, configName, getDefinedAtFile) {
102
98
  if (valueSerialized.type === 'plus-file') {
103
99
  const definedAtFile = getDefinedAtFile();
104
100
  const { exportValues } = valueSerialized;
101
+ (0, utils_js_1.assert)(!definedAtFile.definedBy);
105
102
  (0, assertPlusFileExport_js_1.assertPlusFileExport)(exportValues, definedAtFile.filePathToShowToUser, configName);
106
103
  let value;
107
104
  let valueWasFound = false;
@@ -104,6 +104,7 @@ function serializeConfigValue(configValueBase, valueData, configName, lines, tab
104
104
  function getValueSerializedWithImport(configValueSource, importStatements, filesEnv, configName) {
105
105
  (0, utils_js_1.assert)(!configValueSource.valueIsFilePath);
106
106
  const { valueIsDefinedByPlusValueFile, definedAtFilePath, configEnv } = configValueSource;
107
+ (0, utils_js_1.assert)(!definedAtFilePath.definedBy);
107
108
  const { filePathAbsoluteVite, fileExportName } = definedAtFilePath;
108
109
  if (valueIsDefinedByPlusValueFile)
109
110
  (0, utils_js_1.assert)(fileExportName === undefined);
@@ -231,9 +232,12 @@ function getConfigValuesBase(pageConfig, isEnvMatch, isEager) {
231
232
  return [...fromComputed, ...fromSources].filter((r) => r !== 'SKIP');
232
233
  }
233
234
  function getDefinedAtFileSource(source) {
235
+ const { definedAtFilePath } = source;
236
+ if (definedAtFilePath.definedBy)
237
+ return definedAtFilePath;
234
238
  const definedAtFile = {
235
- filePathToShowToUser: source.definedAtFilePath.filePathToShowToUser,
236
- fileExportPathToShowToUser: source.definedAtFilePath.fileExportPathToShowToUser
239
+ filePathToShowToUser: definedAtFilePath.filePathToShowToUser,
240
+ fileExportPathToShowToUser: definedAtFilePath.fileExportPathToShowToUser
237
241
  };
238
242
  return definedAtFile;
239
243
  }
@@ -62,11 +62,11 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
62
62
  if (!pageRoute) {
63
63
  const { routeFilesystem } = pageConfig;
64
64
  (0, utils_js_1.assert)(routeFilesystem);
65
- const { routeString, definedBy } = routeFilesystem;
65
+ const { routeString, definedAtLocation } = routeFilesystem;
66
66
  (0, utils_js_1.assert)(routeFilesystem.routeString.startsWith('/'));
67
67
  pageRoute = {
68
68
  pageId,
69
- routeFilesystemDefinedBy: definedBy,
69
+ routeFilesystemDefinedBy: definedAtLocation,
70
70
  comesFromV1PageConfig,
71
71
  routeString,
72
72
  routeDefinedAtString: null,
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PROJECT_VERSION = void 0;
4
4
  // Automatically updated by @brillout/release-me
5
- exports.PROJECT_VERSION = '0.4.224-commit-00ed9fe';
5
+ exports.PROJECT_VERSION = '0.4.225';
@@ -17,7 +17,7 @@ const assertSingleInstance_js_1 = require("./assertSingleInstance.js");
17
17
  const createErrorWithCleanStackTrace_js_1 = require("./createErrorWithCleanStackTrace.js");
18
18
  const getGlobalObject_js_1 = require("./getGlobalObject.js");
19
19
  const isObject_js_1 = require("./isObject.js");
20
- const projectInfo_js_1 = require("./projectInfo.js");
20
+ const PROJECT_VERSION_js_1 = require("./PROJECT_VERSION.js");
21
21
  const picocolors_1 = __importDefault(require("@brillout/picocolors"));
22
22
  const globalObject = (0, getGlobalObject_js_1.getGlobalObject)('utils/assert.ts', {
23
23
  alreadyLogged: new Set(),
@@ -34,7 +34,7 @@ const globalObject = (0, getGlobalObject_js_1.getGlobalObject)('utils/assert.ts'
34
34
  });
35
35
  (0, assertSingleInstance_js_1.assertSingleInstance_onAssertModuleLoad)();
36
36
  const projectTag = `[vike]`;
37
- const projectTagWithVersion = `[vike@${projectInfo_js_1.projectInfo.projectVersion}]`;
37
+ const projectTagWithVersion = `[vike@${PROJECT_VERSION_js_1.PROJECT_VERSION}]`;
38
38
  const bugTag = 'Bug';
39
39
  const numberOfStackTraceLinesToRemove = 2;
40
40
  function assert(condition, debugInfo) {
@@ -6,15 +6,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.assertSingleInstance_onClientEntryServerRouting = assertSingleInstance_onClientEntryServerRouting;
7
7
  exports.assertSingleInstance_onClientEntryClientRouting = assertSingleInstance_onClientEntryClientRouting;
8
8
  exports.assertSingleInstance_onAssertModuleLoad = assertSingleInstance_onAssertModuleLoad;
9
- // - Throw error if there are two different versions of vike loaded
9
+ // - Show warning if there are two different Vike versions loaded
10
10
  // - Show warning if entry of Client Routing and entry of Server Routing are both loaded
11
- // - Show warning if vike is loaded twice
11
+ // - Show warning if Vike is loaded twice
12
12
  const unique_js_1 = require("./unique.js");
13
13
  const getGlobalObject_js_1 = require("./getGlobalObject.js");
14
- const projectInfo_js_1 = require("./projectInfo.js");
15
14
  const picocolors_1 = __importDefault(require("@brillout/picocolors"));
16
- /* Use original assertUsage() & assertWarning() after all CJS is removed from node_modules/vike/dist/
17
- import { assertUsage, assertWarning } from './assert.js'
15
+ const PROJECT_VERSION_js_1 = require("./PROJECT_VERSION.js");
16
+ /* Use original assertWarning() after all CJS is removed from node_modules/vike/dist/
17
+ import { assertWarning } from './assert.js'
18
18
  */
19
19
  const globalObject = (0, getGlobalObject_js_1.getGlobalObject)('utils/assertSingleInstance.ts', {
20
20
  instances: [],
@@ -25,9 +25,10 @@ const clientNotSingleInstance = 'Client runtime loaded twice https://vike.dev/cl
25
25
  function assertSingleInstance() {
26
26
  {
27
27
  const versions = (0, unique_js_1.unique)(globalObject.instances);
28
- assertUsage(versions.length <= 1,
29
- // 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
30
- `vike@${picocolors_1.default.bold(versions[0])} and vike@${picocolors_1.default.bold(versions[1])} loaded but it's forbidden to load different versions`);
28
+ assertWarning(versions.length <= 1,
29
+ // Do *NOT* patch Vike to remove this warning: you *will* eventually encounter the issues listed at https://vike.dev/warning/version-mismatch
30
+ // - This happened before: https://github.com/vikejs/vike/issues/1108#issuecomment-1719061509
31
+ `vike@${picocolors_1.default.bold(versions[0])} and vike@${picocolors_1.default.bold(versions[1])} loaded which is highly discouraged, see ${picocolors_1.default.underline('https://vike.dev/warning/version-mismatch')}`, { onlyOnce: true, showStackTrace: false });
31
32
  }
32
33
  if (globalObject.checkSingleInstance && globalObject.instances.length > 1) {
33
34
  /*/ Not sure whether circular dependency can cause problems? In principle not since client-side code is ESM.
@@ -67,21 +68,14 @@ function assertSingleInstance_onClientEntryClientRouting(isProduction) {
67
68
  }
68
69
  // 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`.)
69
70
  function assertSingleInstance_onAssertModuleLoad() {
70
- globalObject.instances.push(projectInfo_js_1.projectInfo.projectVersion);
71
+ globalObject.instances.push(PROJECT_VERSION_js_1.PROJECT_VERSION);
71
72
  assertSingleInstance();
72
73
  }
73
- function assertUsage(condition, errorMessage) {
74
- if (condition) {
75
- return;
76
- }
77
- const errMsg = `[vike][Wrong Usage] ${errorMessage}`;
78
- throw new Error(errMsg);
79
- }
80
74
  function assertWarning(condition, errorMessage, { onlyOnce, showStackTrace }) {
81
75
  if (condition) {
82
76
  return;
83
77
  }
84
- const msg = `[vike][Warning] ${errorMessage}`;
78
+ const msg = `[Vike][Warning] ${errorMessage}`;
85
79
  if (onlyOnce) {
86
80
  const { alreadyLogged } = globalObject;
87
81
  const key = onlyOnce === true ? msg : onlyOnce;
@@ -11,7 +11,7 @@ import { assertVersion } from './utils.js';
11
11
  * https://vike.dev/api#build
12
12
  */
13
13
  async function build(options = {}) {
14
- const { viteConfigEnhanced, vikeConfig } = await prepareViteApiCall(options.viteConfig, 'build');
14
+ const { viteConfigEnhanced, vikeConfig } = await prepareViteApiCall(options, 'build');
15
15
  // Pass it to pluginAutoFullBuild()
16
16
  if (viteConfigEnhanced)
17
17
  viteConfigEnhanced._viteConfigEnhanced = viteConfigEnhanced;
@@ -1,7 +1,13 @@
1
1
  export { isVikeCliOrApi };
2
2
  export { setContextApiOperation };
3
3
  export { clearContextApiOperation };
4
- import type { Operation } from './types.js';
4
+ export { getApiOperation };
5
+ import type { APIOptions, Operation } from './types.js';
6
+ type ApiOperation = {
7
+ operation: Operation;
8
+ options: APIOptions;
9
+ };
10
+ declare function getApiOperation(): ApiOperation | null;
5
11
  declare function isVikeCliOrApi(): boolean;
6
- declare function setContextApiOperation(operation: Operation): void;
12
+ declare function setContextApiOperation(operation: Operation, options: APIOptions): void;
7
13
  declare function clearContextApiOperation(): void;
@@ -1,19 +1,19 @@
1
1
  export { isVikeCliOrApi };
2
2
  export { setContextApiOperation };
3
3
  export { clearContextApiOperation };
4
+ export { getApiOperation };
4
5
  import { assert, getGlobalObject } from './utils.js';
5
6
  const globalObject = getGlobalObject('api/context.ts', {});
6
7
  function getApiOperation() {
7
- assert(globalObject.apiOperation);
8
- return globalObject.apiOperation;
8
+ return globalObject.apiOperation ?? null;
9
9
  }
10
10
  function isVikeCliOrApi() {
11
11
  // The CLI uses the API
12
12
  return !!globalObject.apiOperation;
13
13
  }
14
- function setContextApiOperation(operation) {
14
+ function setContextApiOperation(operation, options) {
15
15
  assert(!globalObject.apiOperation);
16
- globalObject.apiOperation = operation;
16
+ globalObject.apiOperation = { operation, options };
17
17
  }
18
18
  function clearContextApiOperation() {
19
19
  globalObject.apiOperation = undefined;
@@ -7,7 +7,7 @@ import { createServer } from 'vite';
7
7
  * https://vike.dev/api#dev
8
8
  */
9
9
  async function dev(options = {}) {
10
- const { viteConfigEnhanced } = await prepareViteApiCall(options.viteConfig, 'dev');
10
+ const { viteConfigEnhanced } = await prepareViteApiCall(options, 'dev');
11
11
  const server = await createServer(viteConfigEnhanced);
12
12
  return {
13
13
  viteServer: server,
@@ -3,9 +3,9 @@ export { getViteRoot };
3
3
  export { assertViteRoot };
4
4
  export { normalizeViteRoot };
5
5
  import type { InlineConfig, ResolvedConfig } from 'vite';
6
- import type { Operation } from './types.js';
6
+ import type { APIOptions, Operation } from './types.js';
7
7
  import { type VikeConfigObject } from '../plugin/plugins/importUserCode/v1-design/getVikeConfig.js';
8
- declare function prepareViteApiCall(viteConfigFromOptions: InlineConfig | undefined, operation: Operation): Promise<{
8
+ declare function prepareViteApiCall(options: APIOptions, operation: Operation): Promise<{
9
9
  vikeConfig: VikeConfigObject;
10
10
  viteConfigEnhanced: InlineConfig | undefined;
11
11
  }>;
@@ -10,9 +10,10 @@ import { assert, assertUsage, getGlobalObject, isObject, toPosixPath } from './u
10
10
  import pc from '@brillout/picocolors';
11
11
  import { clearGlobalContext } from '../runtime/globalContext.js';
12
12
  const globalObject = getGlobalObject('api/prepareViteApiCall.ts', {});
13
- async function prepareViteApiCall(viteConfigFromOptions, operation) {
13
+ async function prepareViteApiCall(options, operation) {
14
14
  clear();
15
- setContextApiOperation(operation);
15
+ setContextApiOperation(operation, options);
16
+ const viteConfigFromOptions = options.viteConfig;
16
17
  return enhanceViteConfig(viteConfigFromOptions, operation);
17
18
  }
18
19
  // For subsequent API calls, e.g. calling prerender() after build()
@@ -8,7 +8,7 @@ import { prepareViteApiCall } from './prepareViteApiCall.js';
8
8
  * https://vike.dev/api#prerender
9
9
  */
10
10
  async function prerender(options = {}) {
11
- const { viteConfigEnhanced } = await prepareViteApiCall(options.viteConfig, 'prerender');
11
+ const { viteConfigEnhanced } = await prepareViteApiCall(options, 'prerender');
12
12
  options.viteConfig = viteConfigEnhanced;
13
13
  const { viteConfig } = await runPrerenderFromAPI(options);
14
14
  return {
@@ -7,7 +7,7 @@ import { preview as previewVite } from 'vite';
7
7
  * https://vike.dev/api#preview
8
8
  */
9
9
  async function preview(options = {}) {
10
- const { viteConfigEnhanced } = await prepareViteApiCall(options.viteConfig, 'preview');
10
+ const { viteConfigEnhanced } = await prepareViteApiCall(options, 'preview');
11
11
  const server = await previewVite(viteConfigEnhanced);
12
12
  return {
13
13
  viteServer: server,
@@ -1,6 +1,7 @@
1
1
  export type { APIOptions };
2
2
  export type { Operation };
3
3
  import type { InlineConfig } from 'vite';
4
+ import type { Config } from '../../shared/page-configs/Config.js';
4
5
  type APIOptions = {
5
6
  /**
6
7
  * Vite config.
@@ -8,5 +9,11 @@ type APIOptions = {
8
9
  * https://vike.dev/api
9
10
  */
10
11
  viteConfig?: InlineConfig;
12
+ /**
13
+ * Vike config.
14
+ *
15
+ * https://vike.dev/api
16
+ */
17
+ vikeConfig?: Config;
11
18
  };
12
19
  type Operation = 'build' | 'dev' | 'preview' | 'prerender';
@@ -1,5 +1,7 @@
1
1
  export { isVikeCli };
2
2
  export { setContextCliCommand };
3
- import type { Command } from './parseCli.js';
3
+ export { getCliOptions };
4
+ import type { CliOptions, Command } from './parseCli.js';
5
+ declare function getCliOptions(): CliOptions | null;
4
6
  declare function isVikeCli(): boolean;
5
- declare function setContextCliCommand(command: Command): void;
7
+ declare function setContextCliCommand(command: Command, cliOptions: CliOptions): void;
@@ -1,14 +1,15 @@
1
1
  export { isVikeCli };
2
2
  export { setContextCliCommand };
3
+ export { getCliOptions };
3
4
  import { assert, getGlobalObject } from './utils.js';
4
5
  const globalObject = getGlobalObject('cli/context.ts', {});
5
- function getCliCommand() {
6
- return globalObject.cliCommand;
6
+ function getCliOptions() {
7
+ return globalObject.cliCommand?.cliOptions ?? null;
7
8
  }
8
9
  function isVikeCli() {
9
10
  return !!globalObject.cliCommand;
10
11
  }
11
- function setContextCliCommand(command) {
12
+ function setContextCliCommand(command, cliOptions) {
12
13
  assert(!globalObject.cliCommand);
13
- globalObject.cliCommand = command;
14
+ globalObject.cliCommand = { command, cliOptions };
14
15
  }
@@ -1,12 +1,12 @@
1
- import { projectInfo } from './utils.js';
1
+ import { PROJECT_VERSION } from './utils.js';
2
2
  import { dev, build, preview } from '../api/index.js';
3
3
  import pc from '@brillout/picocolors';
4
4
  import { parseCli } from './parseCli.js';
5
5
  import { setContextCliCommand } from './context.js';
6
6
  cli();
7
7
  async function cli() {
8
- const { command } = parseCli();
9
- setContextCliCommand(command);
8
+ const { command, cliOptions } = parseCli();
9
+ setContextCliCommand(command, cliOptions);
10
10
  if (command === 'dev') {
11
11
  await cmdDev();
12
12
  }
@@ -28,7 +28,7 @@ async function cmdDev() {
28
28
  const info = viteServer.config.logger.info;
29
29
  const startupDurationString = pc.dim(`ready in ${pc.reset(pc.bold(String(Math.ceil(performance.now() - startTime))))} ms`);
30
30
  const hasExistingLogs = process.stdout.bytesWritten > 0 || process.stderr.bytesWritten > 0;
31
- info(` ${pc.yellow(`${pc.bold(projectInfo.projectName)} v${projectInfo.projectVersion}`)} ${startupDurationString}\n`, {
31
+ info(` ${pc.yellow(`${pc.bold('Vike')} v${PROJECT_VERSION}`)} ${startupDurationString}\n`, {
32
32
  clear: !hasExistingLogs
33
33
  });
34
34
  viteServer.printUrls();
@@ -1,6 +1,9 @@
1
1
  export { parseCli };
2
2
  export type { Command };
3
+ export type { CliOptions };
4
+ type CliOptions = Record<string, unknown>;
3
5
  type Command = 'dev' | 'build' | 'preview' | 'prerender';
4
6
  declare function parseCli(): {
5
7
  command: Command;
8
+ cliOptions: CliOptions;
6
9
  };