vike 0.4.213 → 0.4.215

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 (69) hide show
  1. package/dist/cjs/node/api/build.js +9 -3
  2. package/dist/cjs/node/api/context.js +18 -0
  3. package/dist/cjs/node/api/dev.js +6 -3
  4. package/dist/cjs/node/api/onLoad.js +9 -0
  5. package/dist/cjs/node/api/{enhanceViteConfig.js → prepareApiCall.js} +11 -6
  6. package/dist/cjs/node/api/prerender.js +6 -3
  7. package/dist/cjs/node/api/preview.js +6 -3
  8. package/dist/cjs/node/api/utils.js +21 -0
  9. package/dist/cjs/node/cli/entry.js +8 -8
  10. package/dist/cjs/node/cli/onLoad.js +2 -0
  11. package/dist/cjs/node/cli/parseCli.js +2 -2
  12. package/dist/cjs/node/plugin/index.js +3 -1
  13. package/dist/cjs/node/plugin/plugins/autoFullBuild.js +0 -3
  14. package/dist/cjs/node/plugin/plugins/commonConfig/pluginName.js +1 -1
  15. package/dist/cjs/node/plugin/plugins/commonConfig.js +5 -1
  16. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +1 -15
  17. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +7 -7
  18. package/dist/cjs/node/plugin/plugins/vite6HmrRegressionWorkaround.js +35 -0
  19. package/dist/cjs/node/prerender/runPrerender.js +4 -3
  20. package/dist/cjs/shared/page-configs/getConfigValue.js +2 -31
  21. package/dist/cjs/shared/page-configs/getConfigValueBuildTime.js +2 -2
  22. package/dist/cjs/shared/page-configs/getConfigValueTyped.js +32 -0
  23. package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
  24. package/dist/esm/node/api/build.d.ts +5 -3
  25. package/dist/esm/node/api/build.js +9 -3
  26. package/dist/esm/node/api/context.d.ts +5 -0
  27. package/dist/esm/node/api/context.js +17 -0
  28. package/dist/esm/node/api/dev.d.ts +6 -2
  29. package/dist/esm/node/api/dev.js +6 -3
  30. package/dist/esm/node/api/onLoad.d.ts +2 -0
  31. package/dist/esm/node/api/onLoad.js +7 -0
  32. package/dist/esm/node/api/prepareApiCall.d.ts +7 -0
  33. package/dist/esm/node/api/{enhanceViteConfig.js → prepareApiCall.js} +11 -6
  34. package/dist/esm/node/api/prerender.d.ts +4 -1
  35. package/dist/esm/node/api/prerender.js +6 -3
  36. package/dist/esm/node/api/preview.d.ts +6 -2
  37. package/dist/esm/node/api/preview.js +6 -3
  38. package/dist/esm/node/api/{APIOptions.d.ts → types.d.ts} +3 -1
  39. package/dist/esm/node/api/utils.d.ts +1 -0
  40. package/dist/esm/node/api/utils.js +5 -0
  41. package/dist/esm/node/cli/entry.js +8 -8
  42. package/dist/esm/node/cli/onLoad.js +2 -0
  43. package/dist/esm/node/cli/parseCli.js +2 -2
  44. package/dist/esm/node/plugin/index.js +3 -1
  45. package/dist/esm/node/plugin/plugins/autoFullBuild.js +0 -3
  46. package/dist/esm/node/plugin/plugins/commonConfig/pluginName.d.ts +1 -1
  47. package/dist/esm/node/plugin/plugins/commonConfig/pluginName.js +1 -1
  48. package/dist/esm/node/plugin/plugins/commonConfig.js +5 -1
  49. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.d.ts +1 -1
  50. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +2 -16
  51. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +7 -7
  52. package/dist/esm/node/plugin/plugins/vite6HmrRegressionWorkaround.d.ts +3 -0
  53. package/dist/esm/node/plugin/plugins/vite6HmrRegressionWorkaround.js +33 -0
  54. package/dist/esm/node/prerender/runPrerender.d.ts +5 -3
  55. package/dist/esm/node/prerender/runPrerender.js +4 -3
  56. package/dist/esm/shared/ConfigVike.d.ts +1 -1
  57. package/dist/esm/shared/page-configs/getConfigValue.d.ts +2 -8
  58. package/dist/esm/shared/page-configs/getConfigValue.js +1 -27
  59. package/dist/esm/shared/page-configs/getConfigValueBuildTime.d.ts +2 -3
  60. package/dist/esm/shared/page-configs/getConfigValueBuildTime.js +1 -1
  61. package/dist/esm/shared/page-configs/getConfigValueTyped.d.ts +9 -0
  62. package/dist/esm/shared/page-configs/getConfigValueTyped.js +27 -0
  63. package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
  64. package/dist/esm/utils/PROJECT_VERSION.js +1 -1
  65. package/dist/esm/utils/projectInfo.d.ts +1 -1
  66. package/package.json +13 -6
  67. package/dist/esm/node/api/enhanceViteConfig.d.ts +0 -6
  68. /package/dist/cjs/node/api/{APIOptions.js → types.js} +0 -0
  69. /package/dist/esm/node/api/{APIOptions.js → types.js} +0 -0
@@ -24,10 +24,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.build = build;
27
- const enhanceViteConfig_js_1 = require("./enhanceViteConfig.js");
27
+ const prepareApiCall_js_1 = require("./prepareApiCall.js");
28
28
  const vite_1 = require("vite");
29
29
  async function build(options = {}) {
30
- const { viteConfigEnhanced, configVike } = await (0, enhanceViteConfig_js_1.enhanceViteConfig)(options.viteConfig, 'build');
30
+ const { viteConfigEnhanced, configVike } = await (0, prepareApiCall_js_1.prepareApiCall)(options.viteConfig, 'build');
31
31
  // Build client-side
32
32
  const outputClient = await (0, vite_1.build)(viteConfigEnhanced);
33
33
  // Build server-side
@@ -37,7 +37,13 @@ async function build(options = {}) {
37
37
  const { runPrerenderFromAutoRun } = await Promise.resolve().then(() => __importStar(require('../prerender/runPrerender.js')));
38
38
  await runPrerenderFromAutoRun(viteConfigEnhanced, true);
39
39
  }
40
- return { outputClient, outputServer };
40
+ return {
41
+ /* We don't return `viteConfig` because `viteConfigEnhanced` is `InlineConfig` not `ResolvedConfig`
42
+ viteConfig: viteConfigEnhanced,
43
+ */
44
+ rollupOutputClient: outputClient,
45
+ rollupOutputServer: outputServer
46
+ };
41
47
  }
42
48
  function setSSR(viteConfig) {
43
49
  return {
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isVikeCliOrApi = isVikeCliOrApi;
4
+ exports.setOperation = setOperation;
5
+ const utils_js_1 = require("./utils.js");
6
+ let apiOperation;
7
+ function getOperation() {
8
+ (0, utils_js_1.assert)(apiOperation);
9
+ return apiOperation;
10
+ }
11
+ function isVikeCliOrApi() {
12
+ // The CLI uses the API
13
+ return !!apiOperation;
14
+ }
15
+ function setOperation(operation) {
16
+ (0, utils_js_1.assert)(!apiOperation);
17
+ apiOperation = operation;
18
+ }
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.dev = dev;
4
- const enhanceViteConfig_js_1 = require("./enhanceViteConfig.js");
4
+ const prepareApiCall_js_1 = require("./prepareApiCall.js");
5
5
  const vite_1 = require("vite");
6
6
  async function dev(options = {}) {
7
- const { viteConfigEnhanced } = await (0, enhanceViteConfig_js_1.enhanceViteConfig)(options.viteConfig, 'dev');
7
+ const { viteConfigEnhanced } = await (0, prepareApiCall_js_1.prepareApiCall)(options.viteConfig, 'dev');
8
8
  const server = await (0, vite_1.createServer)(viteConfigEnhanced);
9
- return server;
9
+ return {
10
+ viteServer: server,
11
+ viteConfig: server.config
12
+ };
10
13
  }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.onLoad = onLoad;
4
+ const assertIsNotBrowser_js_1 = require("../../utils/assertIsNotBrowser.js");
5
+ const utils_js_1 = require("../runtime/utils.js");
6
+ function onLoad() {
7
+ (0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
8
+ (0, utils_js_1.assertIsNotProductionRuntime)();
9
+ }
@@ -23,12 +23,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.enhanceViteConfig = enhanceViteConfig;
26
+ exports.prepareApiCall = prepareApiCall;
27
27
  const vite_1 = require("vite");
28
28
  const getConfigVike_js_1 = require("../shared/getConfigVike.js");
29
29
  const pluginName_js_1 = require("../plugin/plugins/commonConfig/pluginName.js");
30
- async function enhanceViteConfig(viteConfig = {}, command) {
31
- let viteConfigResolved = await resolveViteConfig(viteConfig, command);
30
+ const context_js_1 = require("./context.js");
31
+ async function prepareApiCall(viteConfig = {}, operation) {
32
+ (0, context_js_1.setOperation)(operation);
33
+ return enhanceViteConfig(viteConfig, operation);
34
+ }
35
+ async function enhanceViteConfig(viteConfig = {}, operation) {
36
+ let viteConfigResolved = await resolveViteConfig(viteConfig, operation);
32
37
  let viteConfigEnhanced = viteConfig;
33
38
  // Add vike to plugins if not present
34
39
  if (!viteConfigResolved.plugins.some((p) => p.name === pluginName_js_1.pluginName)) {
@@ -38,7 +43,7 @@ async function enhanceViteConfig(viteConfig = {}, command) {
38
43
  ...viteConfig,
39
44
  plugins: [...(viteConfig.plugins ?? []), vikePlugin()]
40
45
  };
41
- viteConfigResolved = await resolveViteConfig(viteConfigEnhanced, command);
46
+ viteConfigResolved = await resolveViteConfig(viteConfigEnhanced, operation);
42
47
  }
43
48
  const configVike = await (0, getConfigVike_js_1.getConfigVike)(viteConfigResolved);
44
49
  // TODO: enable Vike extensions to add Vite plugins
@@ -47,6 +52,6 @@ async function enhanceViteConfig(viteConfig = {}, command) {
47
52
  configVike
48
53
  };
49
54
  }
50
- async function resolveViteConfig(viteConfig, command) {
51
- return await (0, vite_1.resolveConfig)(viteConfig, command === 'build' || command === 'prerender' ? 'build' : 'serve', 'custom', command === 'dev' ? 'development' : 'production', command === 'preview');
55
+ async function resolveViteConfig(viteConfig, operation) {
56
+ return await (0, vite_1.resolveConfig)(viteConfig, operation === 'build' || operation === 'prerender' ? 'build' : 'serve', 'custom', operation === 'dev' ? 'development' : 'production', operation === 'preview');
52
57
  }
@@ -2,9 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.prerender = prerender;
4
4
  const runPrerender_js_1 = require("../prerender/runPrerender.js");
5
- const enhanceViteConfig_js_1 = require("./enhanceViteConfig.js");
5
+ const prepareApiCall_js_1 = require("./prepareApiCall.js");
6
6
  async function prerender(options = {}) {
7
- const { viteConfigEnhanced } = await (0, enhanceViteConfig_js_1.enhanceViteConfig)(options.viteConfig, 'prerender');
7
+ const { viteConfigEnhanced } = await (0, prepareApiCall_js_1.prepareApiCall)(options.viteConfig, 'prerender');
8
8
  options.viteConfig = viteConfigEnhanced;
9
- await (0, runPrerender_js_1.runPrerenderFromAPI)(options);
9
+ const { viteConfig } = await (0, runPrerender_js_1.runPrerenderFromAPI)(options);
10
+ return {
11
+ viteConfig
12
+ };
10
13
  }
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.preview = preview;
4
- const enhanceViteConfig_js_1 = require("./enhanceViteConfig.js");
4
+ const prepareApiCall_js_1 = require("./prepareApiCall.js");
5
5
  const vite_1 = require("vite");
6
6
  async function preview(options = {}) {
7
- const { viteConfigEnhanced } = await (0, enhanceViteConfig_js_1.enhanceViteConfig)(options.viteConfig, 'preview');
7
+ const { viteConfigEnhanced } = await (0, prepareApiCall_js_1.prepareApiCall)(options.viteConfig, 'preview');
8
8
  const server = await (0, vite_1.preview)(viteConfigEnhanced);
9
- return server;
9
+ return {
10
+ viteServer: server,
11
+ viteConfig: server.config
12
+ };
10
13
  }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ // Utils needed by Vike's API
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ // We call onLoad() here so that it's called even when only a subset of the API is loaded. (Making the assert() calls inside onLoad() a lot stronger.)
19
+ const onLoad_js_1 = require("./onLoad.js");
20
+ (0, onLoad_js_1.onLoad)();
21
+ __exportStar(require("../../utils/assert.js"), exports);
@@ -49,16 +49,16 @@ async function cli() {
49
49
  async function cmdDev() {
50
50
  const startTime = performance.now();
51
51
  try {
52
- const server = await (0, index_js_1.dev)();
53
- await server.listen();
54
- const info = server.config.logger.info;
52
+ const { viteServer } = await (0, index_js_1.dev)();
53
+ await viteServer.listen();
54
+ const info = viteServer.config.logger.info;
55
55
  const startupDurationString = picocolors_1.default.dim(`ready in ${picocolors_1.default.reset(picocolors_1.default.bold(String(Math.ceil(performance.now() - startTime))))} ms`);
56
56
  const hasExistingLogs = process.stdout.bytesWritten > 0 || process.stderr.bytesWritten > 0;
57
57
  info(` ${picocolors_1.default.yellow(`${picocolors_1.default.bold(utils_js_1.projectInfo.projectName)} v${utils_js_1.projectInfo.projectVersion}`)} ${startupDurationString}\n`, {
58
58
  clear: !hasExistingLogs
59
59
  });
60
- server.printUrls();
61
- server.bindCLIShortcuts({ print: true });
60
+ viteServer.printUrls();
61
+ viteServer.bindCLIShortcuts({ print: true });
62
62
  }
63
63
  catch (err) {
64
64
  console.error(picocolors_1.default.red(`Error while starting dev server:`));
@@ -80,9 +80,9 @@ async function cmdBuild() {
80
80
  }
81
81
  async function cmdPreview() {
82
82
  try {
83
- const server = await (0, index_js_1.preview)();
84
- server.printUrls();
85
- server.bindCLIShortcuts({ print: true });
83
+ const { viteServer } = await (0, index_js_1.preview)();
84
+ viteServer.printUrls();
85
+ viteServer.bindCLIShortcuts({ print: true });
86
86
  }
87
87
  catch (err) {
88
88
  console.error(picocolors_1.default.red(`Error while starting preview server:`));
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.onLoad = onLoad;
4
4
  const assertIsNotBrowser_js_1 = require("../../utils/assertIsNotBrowser.js");
5
+ const utils_js_1 = require("../runtime/utils.js");
5
6
  function onLoad() {
6
7
  (0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
8
+ (0, utils_js_1.assertIsNotProductionRuntime)();
7
9
  }
@@ -9,8 +9,8 @@ const utils_js_1 = require("./utils.js");
9
9
  const commands = [
10
10
  { name: 'dev', desc: 'Start development server' },
11
11
  { name: 'build', desc: 'Build for production' },
12
- { name: 'preview', desc: 'Start preview server using production build' },
13
- { name: 'prerender', desc: 'Pre-render pages' }
12
+ { name: 'preview', desc: 'Start preview server using production build (only works for SSG apps)' },
13
+ { name: 'prerender', desc: 'Pre-render pages (only needed when partial.disableAutoRun is true)' }
14
14
  ];
15
15
  function parseCli() {
16
16
  const command = (() => {
@@ -33,6 +33,7 @@ const fileEnv_js_1 = require("./plugins/fileEnv.js");
33
33
  const getPageAssets_js_1 = require("../runtime/renderPage/getPageAssets.js");
34
34
  const resolveClientEntriesDev_js_1 = require("./resolveClientEntriesDev.js");
35
35
  const workaroundCssModuleHmr_js_1 = require("./plugins/workaroundCssModuleHmr.js");
36
+ const vite6HmrRegressionWorkaround_js_1 = require("./plugins/vite6HmrRegressionWorkaround.js");
36
37
  (0, utils_js_2.assertNodeEnv_onVikePluginLoad)();
37
38
  (0, utils_js_2.markEnvAsVikePluginLoaded)();
38
39
  assertViteVersion();
@@ -58,7 +59,8 @@ function plugin(vikeConfig) {
58
59
  (0, baseUrls_js_1.baseUrls)(vikeConfig),
59
60
  (0, envVars_js_1.envVarsPlugin)(),
60
61
  (0, fileEnv_js_1.fileEnv)(),
61
- (0, workaroundCssModuleHmr_js_1.workaroundCssModuleHmr)()
62
+ (0, workaroundCssModuleHmr_js_1.workaroundCssModuleHmr)(),
63
+ (0, vite6HmrRegressionWorkaround_js_1.vite6HmrRegressionWorkaround)()
62
64
  ];
63
65
  return plugins;
64
66
  }
@@ -14,9 +14,6 @@ const picocolors_1 = __importDefault(require("@brillout/picocolors"));
14
14
  const logErrorHint_js_1 = require("../../runtime/renderPage/logErrorHint.js");
15
15
  const buildConfig_js_1 = require("./buildConfig.js");
16
16
  let forceExit = false;
17
- (0, utils_js_1.assertWarning)(!(0, isViteCliCall_js_1.isViteCliCall)(), `Vite's CLI is deprecated ${picocolors_1.default.underline('https://vike.dev/migration/cli')}`, {
18
- onlyOnce: true
19
- });
20
17
  function autoFullBuild() {
21
18
  let config;
22
19
  let configVike;
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.pluginName = void 0;
4
- exports.pluginName = 'vike:commonConfig-1';
4
+ exports.pluginName = 'vike:commonConfig';
@@ -13,6 +13,10 @@ const path_1 = __importDefault(require("path"));
13
13
  const assertResolveAlias_js_1 = require("./commonConfig/assertResolveAlias.js");
14
14
  const pluginName_js_1 = require("./commonConfig/pluginName.js");
15
15
  const getEnvVarObject_js_1 = require("../shared/getEnvVarObject.js");
16
+ const isViteCliCall_js_1 = require("../shared/isViteCliCall.js");
17
+ (0, utils_js_1.assertWarning)(!(0, isViteCliCall_js_1.isViteCliCall)(), `Vite's CLI is deprecated ${picocolors_1.default.underline('https://vike.dev/migration/cli')}`, {
18
+ onlyOnce: true
19
+ });
16
20
  function commonConfig() {
17
21
  return [
18
22
  {
@@ -23,7 +27,7 @@ function commonConfig() {
23
27
  }
24
28
  },
25
29
  {
26
- name: 'vike:commonConfig-2',
30
+ name: `${pluginName_js_1.pluginName}:post`,
27
31
  enforce: 'post',
28
32
  configResolved: {
29
33
  order: 'post',
@@ -10,14 +10,13 @@ const promises_1 = __importDefault(require("fs/promises"));
10
10
  const fast_glob_1 = __importDefault(require("fast-glob"));
11
11
  const child_process_1 = require("child_process");
12
12
  const util_1 = require("util");
13
- const picocolors_1 = __importDefault(require("@brillout/picocolors"));
14
13
  const transpileAndExecuteFile_js_1 = require("./transpileAndExecuteFile.js");
15
14
  const execA = (0, util_1.promisify)(child_process_1.exec);
16
15
  const TOO_MANY_UNTRACKED_FILES = 5;
17
16
  (0, utils_js_1.assertIsNotProductionRuntime)();
18
17
  (0, utils_js_1.assertIsSingleModuleInstance)('crawlPlusFiles.ts');
19
18
  let gitIsNotUsable = false;
20
- async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev, crawlWithGit) {
19
+ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, crawlWithGit) {
21
20
  (0, utils_js_1.assertPosixPath)(userRootDir);
22
21
  (0, utils_js_1.assertPosixPath)(outDirAbsoluteFilesystem);
23
22
  let outDirRelativeFromUserRootDir = path_1.default.posix.relative(userRootDir, outDirAbsoluteFilesystem);
@@ -32,7 +31,6 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev, craw
32
31
  (!outDirRelativeFromUserRootDir.startsWith('./') &&
33
32
  //
34
33
  !outDirRelativeFromUserRootDir.startsWith('../')));
35
- const timeBefore = new Date().getTime();
36
34
  // Crawl
37
35
  let files = [];
38
36
  const res = crawlWithGit !== false && (await gitLsFiles(userRootDir, outDirRelativeFromUserRootDir));
@@ -48,18 +46,6 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev, craw
48
46
  }
49
47
  // Filter build files
50
48
  files = files.filter((filePath) => !(0, transpileAndExecuteFile_js_1.isTemporaryBuildFile)(filePath));
51
- // Check performance
52
- {
53
- const timeAfter = new Date().getTime();
54
- const timeSpent = timeAfter - timeBefore;
55
- if (isDev) {
56
- // We only warn in dev, because while building it's expected to take a long time as crawling is competing for resources with other tasks.
57
- // Although, in dev, it's also competing for resources e.g. with Vite's `optimizeDeps`.
58
- (0, utils_js_1.assertWarning)(timeSpent < 3 * 1000, `Crawling your ${picocolors_1.default.cyan('+')} files took an unexpected long time (${(0, utils_js_1.humanizeTime)(timeSpent)}). If you consistently get this warning, then consider reaching out on GitHub.`, {
59
- onlyOnce: 'slow-crawling'
60
- });
61
- }
62
- }
63
49
  // Normalize
64
50
  const plusFiles = files.map((filePath) => {
65
51
  // Both `$ git-ls files` and fast-glob return posix paths
@@ -86,8 +86,8 @@ async function isV1Design(config, isDev) {
86
86
  const isV1Design = pageConfigs.length > 0;
87
87
  return isV1Design;
88
88
  }
89
- async function loadInterfaceFiles(userRootDir, outDirRoot, isDev, crawlWithGit) {
90
- const plusFiles = await findPlusFiles(userRootDir, outDirRoot, isDev, crawlWithGit);
89
+ async function loadInterfaceFiles(userRootDir, outDirRoot, crawlWithGit) {
90
+ const plusFiles = await findPlusFiles(userRootDir, outDirRoot, crawlWithGit);
91
91
  const configFiles = [];
92
92
  const valueFiles = [];
93
93
  plusFiles.forEach((f) => {
@@ -201,7 +201,7 @@ async function loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev,
201
201
  let ret;
202
202
  let err;
203
203
  try {
204
- ret = await loadVikeConfig(userRootDir, outDirRoot, isDev, crawlWithGit);
204
+ ret = await loadVikeConfig(userRootDir, outDirRoot, crawlWithGit);
205
205
  }
206
206
  catch (err_) {
207
207
  hasError = true;
@@ -238,8 +238,8 @@ async function loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev,
238
238
  }
239
239
  }
240
240
  }
241
- async function loadVikeConfig(userRootDir, outDirRoot, isDev, crawlWithGit) {
242
- const interfaceFilesByLocationId = await loadInterfaceFiles(userRootDir, outDirRoot, isDev, crawlWithGit);
241
+ async function loadVikeConfig(userRootDir, outDirRoot, crawlWithGit) {
242
+ const interfaceFilesByLocationId = await loadInterfaceFiles(userRootDir, outDirRoot, crawlWithGit);
243
243
  const importedFilesLoaded = {};
244
244
  const { globalVikeConfig, pageConfigGlobal } = await getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded);
245
245
  const pageConfigs = await Promise.all((0, utils_js_1.objectEntries)(interfaceFilesByLocationId)
@@ -785,8 +785,8 @@ function getComputed(configValueSources, configDefinitions) {
785
785
  });
786
786
  return configValuesComputed;
787
787
  }
788
- async function findPlusFiles(userRootDir, outDirRoot, isDev, crawlWithGit) {
789
- const files = await (0, crawlPlusFiles_js_1.crawlPlusFiles)(userRootDir, outDirRoot, isDev, crawlWithGit);
788
+ async function findPlusFiles(userRootDir, outDirRoot, crawlWithGit) {
789
+ const files = await (0, crawlPlusFiles_js_1.crawlPlusFiles)(userRootDir, outDirRoot, crawlWithGit);
790
790
  const plusFiles = files.map(({ filePathAbsoluteUserRootDir }) => (0, getFilePath_js_1.getFilePathResolved)({ filePathAbsoluteUserRootDir, userRootDir }));
791
791
  return plusFiles;
792
792
  }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.vite6HmrRegressionWorkaround = vite6HmrRegressionWorkaround;
4
+ // https://vite.dev/guide/migration (will be 404 after vite@7 release) > search for `hmrReload()`
5
+ // https://v6.vite.dev/guide/migration (will exist after vite@7 release) > search for `hmrReload()`
6
+ // Workaround seems to work for docs page /banner (which is HTML-only)
7
+ // But doesn't seem to work for /examples/render-modes/ (see https://github.com/vikejs/vike/pull/2069 commit `renable HMR test for HTML-only`)
8
+ function vite6HmrRegressionWorkaround() {
9
+ return {
10
+ name: 'vike:vite6HmrRegressionWorkaround',
11
+ enforce: 'post',
12
+ hotUpdate: {
13
+ order: 'post',
14
+ handler({ modules, server, timestamp }) {
15
+ if (this.environment.name !== 'ssr')
16
+ return;
17
+ let hasSsrOnlyModules = false;
18
+ const invalidatedModules = new Set();
19
+ for (const mod of modules) {
20
+ if (mod.id == null)
21
+ continue;
22
+ const clientModule = server.environments.client.moduleGraph.getModuleById(mod.id);
23
+ if (clientModule != null)
24
+ continue;
25
+ this.environment.moduleGraph.invalidateModule(mod, invalidatedModules, timestamp, true);
26
+ hasSsrOnlyModules = true;
27
+ }
28
+ if (hasSsrOnlyModules) {
29
+ server.ws.send({ type: 'full-reload' });
30
+ return [];
31
+ }
32
+ }
33
+ }
34
+ };
35
+ }
@@ -56,15 +56,15 @@ const getVikeConfig_js_1 = require("../plugin/plugins/importUserCode/v1-design/g
56
56
  const logErrorHint_js_1 = require("../runtime/renderPage/logErrorHint.js");
57
57
  const executeHook_js_1 = require("../../shared/hooks/executeHook.js");
58
58
  const getConfigValueBuildTime_js_1 = require("../../shared/page-configs/getConfigValueBuildTime.js");
59
- const enhanceViteConfig_js_1 = require("../api/enhanceViteConfig.js");
59
+ const prepareApiCall_js_1 = require("../api/prepareApiCall.js");
60
60
  async function runPrerenderFromAPI(options = {}) {
61
- await runPrerender(options, 'prerender()');
61
+ return await runPrerender(options, 'prerender()');
62
62
  // - We purposely propagate the error to the user land, so that the error interrupts the user land. It's also, I guess, a nice-to-have that the user has control over the error.
63
63
  // - We don't use logErrorHint() because we don't have control over what happens with the error. For example, if the user land purposely swallows the error then the hint shouldn't be logged. Also, it's best if the hint is shown to the user *after* the error, but we cannot do/guarentee that.
64
64
  }
65
65
  async function runPrerenderFromCLIPrerenderCommand() {
66
66
  try {
67
- const { viteConfigEnhanced } = await (0, enhanceViteConfig_js_1.enhanceViteConfig)(undefined, 'prerender');
67
+ const { viteConfigEnhanced } = await (0, prepareApiCall_js_1.prepareApiCall)(undefined, 'prerender');
68
68
  await runPrerender({ viteConfig: viteConfigEnhanced }, '$ vike prerender');
69
69
  }
70
70
  catch (err) {
@@ -143,6 +143,7 @@ async function runPrerender(options = {}, standaloneTrigger) {
143
143
  console.log(`${picocolors_1.default.green(`✓`)} ${prerenderedCount} HTML documents pre-rendered.`);
144
144
  }
145
145
  warnMissingPages(prerenderedPageContexts, doNotPrerenderList, renderContext, partial);
146
+ return { viteConfig };
146
147
  }
147
148
  async function collectDoNoPrerenderList(renderContext, pageConfigs, doNotPrerenderList, concurrencyLimit) {
148
149
  // V1 design
@@ -1,39 +1,10 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.getConfigValueRuntime = getConfigValueRuntime;
7
- exports.getConfigValueTyped = getConfigValueTyped;
8
- const utils_js_1 = require("../utils.js");
9
- const picocolors_1 = __importDefault(require("@brillout/picocolors"));
10
- const getConfigDefinedAt_js_1 = require("./getConfigDefinedAt.js");
11
- function getConfigValueTyped(configValue, configName, type) {
12
- /* [NULL_HANDLING] Do we really need this? This doesn't seem to make sense, let's eventually (re)move this.
13
- // Enable users to suppress global config values by setting the local config value to null
14
- if (configValue.value === null) return null
15
- */
16
- const { value, definedAtData } = configValue;
17
- if (type)
18
- assertConfigValueType(value, type, configName, definedAtData);
19
- return configValue;
20
- }
4
+ const getConfigValueTyped_js_1 = require("./getConfigValueTyped.js");
21
5
  function getConfigValueRuntime(pageConfig, configName, type) {
22
6
  const configValue = pageConfig.configValues[configName];
23
7
  if (!configValue)
24
8
  return null;
25
- return getConfigValueTyped(configValue, configName, type);
26
- }
27
- function assertConfigValueType(value, type, configName, definedAtData) {
28
- (0, utils_js_1.assert)(value !== null);
29
- const typeActual = typeof value;
30
- if (typeActual === type)
31
- return;
32
- const valuePrintable = (0, utils_js_1.getValuePrintable)(value);
33
- const problem = valuePrintable !== null
34
- ? `value ${picocolors_1.default.cyan(valuePrintable)}`
35
- : `type ${picocolors_1.default.cyan(typeActual)}`;
36
- const configDefinedAt = (0, getConfigDefinedAt_js_1.getConfigDefinedAtOptional)('Config', configName, definedAtData);
37
- const errMsg = `${configDefinedAt} has an invalid ${problem}: it should be a ${picocolors_1.default.cyan(type)} instead`;
38
- (0, utils_js_1.assertUsage)(false, errMsg);
9
+ return (0, getConfigValueTyped_js_1.getConfigValueTyped)(configValue, configName, type);
39
10
  }
@@ -2,14 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getConfigValueBuildTime = getConfigValueBuildTime;
4
4
  const utils_js_1 = require("../utils.js");
5
- const getConfigValue_js_1 = require("./getConfigValue.js");
6
5
  const assertIsNotProductionRuntime_js_1 = require("../../utils/assertIsNotProductionRuntime.js");
6
+ const getConfigValueTyped_js_1 = require("./getConfigValueTyped.js");
7
7
  (0, assertIsNotProductionRuntime_js_1.assertIsNotProductionRuntime)();
8
8
  function getConfigValueBuildTime(pageConfig, configName, type) {
9
9
  const configValue = getConfigValue(pageConfig, configName);
10
10
  if (!configValue)
11
11
  return null;
12
- return (0, getConfigValue_js_1.getConfigValueTyped)(configValue, configName, type);
12
+ return (0, getConfigValueTyped_js_1.getConfigValueTyped)(configValue, configName, type);
13
13
  }
14
14
  function getConfigValue(pageConfig, configName) {
15
15
  const { configValueSources, configValuesComputed, configDefinitions } = pageConfig;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getConfigValueTyped = getConfigValueTyped;
7
+ const utils_js_1 = require("../utils.js");
8
+ const picocolors_1 = __importDefault(require("@brillout/picocolors"));
9
+ const getConfigDefinedAt_js_1 = require("./getConfigDefinedAt.js");
10
+ function getConfigValueTyped(configValue, configName, type) {
11
+ /* [NULL_HANDLING] Do we really need this? This doesn't seem to make sense, let's eventually (re)move this.
12
+ // Enable users to suppress global config values by setting the local config value to null
13
+ if (configValue.value === null) return null
14
+ */
15
+ const { value, definedAtData } = configValue;
16
+ if (type)
17
+ assertConfigValueType(value, type, configName, definedAtData);
18
+ return configValue;
19
+ }
20
+ function assertConfigValueType(value, type, configName, definedAtData) {
21
+ (0, utils_js_1.assert)(value !== null);
22
+ const typeActual = typeof value;
23
+ if (typeActual === type)
24
+ return;
25
+ const valuePrintable = (0, utils_js_1.getValuePrintable)(value);
26
+ const problem = valuePrintable !== null
27
+ ? `value ${picocolors_1.default.cyan(valuePrintable)}`
28
+ : `type ${picocolors_1.default.cyan(typeActual)}`;
29
+ const configDefinedAt = (0, getConfigDefinedAt_js_1.getConfigDefinedAtOptional)('Config', configName, definedAtData);
30
+ const errMsg = `${configDefinedAt} has an invalid ${problem}: it should be a ${picocolors_1.default.cyan(type)} instead`;
31
+ (0, utils_js_1.assertUsage)(false, errMsg);
32
+ }
@@ -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.213';
5
+ exports.PROJECT_VERSION = '0.4.215';
@@ -1,6 +1,8 @@
1
1
  export { build };
2
- import type { APIOptions } from './APIOptions.js';
2
+ import { type Rollup } from 'vite';
3
+ import type { APIOptions } from './types.js';
4
+ type RollupOutput = Rollup.RollupOutput | Rollup.RollupOutput[] | Rollup.RollupWatcher;
3
5
  declare function build(options?: APIOptions): Promise<{
4
- outputClient: import("rollup").RollupOutput | import("rollup").RollupOutput[] | import("rollup").RollupWatcher;
5
- outputServer: import("rollup").RollupOutput | import("rollup").RollupOutput[] | import("rollup").RollupWatcher;
6
+ rollupOutputClient: RollupOutput;
7
+ rollupOutputServer: RollupOutput;
6
8
  }>;
@@ -1,8 +1,8 @@
1
1
  export { build };
2
- import { enhanceViteConfig } from './enhanceViteConfig.js';
2
+ import { prepareApiCall } from './prepareApiCall.js';
3
3
  import { build as buildVite } from 'vite';
4
4
  async function build(options = {}) {
5
- const { viteConfigEnhanced, configVike } = await enhanceViteConfig(options.viteConfig, 'build');
5
+ const { viteConfigEnhanced, configVike } = await prepareApiCall(options.viteConfig, 'build');
6
6
  // Build client-side
7
7
  const outputClient = await buildVite(viteConfigEnhanced);
8
8
  // Build server-side
@@ -12,7 +12,13 @@ async function build(options = {}) {
12
12
  const { runPrerenderFromAutoRun } = await import('../prerender/runPrerender.js');
13
13
  await runPrerenderFromAutoRun(viteConfigEnhanced, true);
14
14
  }
15
- return { outputClient, outputServer };
15
+ return {
16
+ /* We don't return `viteConfig` because `viteConfigEnhanced` is `InlineConfig` not `ResolvedConfig`
17
+ viteConfig: viteConfigEnhanced,
18
+ */
19
+ rollupOutputClient: outputClient,
20
+ rollupOutputServer: outputServer
21
+ };
16
22
  }
17
23
  function setSSR(viteConfig) {
18
24
  return {
@@ -0,0 +1,5 @@
1
+ export { isVikeCliOrApi };
2
+ export { setOperation as setOperation };
3
+ import type { Operation } from './types.js';
4
+ declare function isVikeCliOrApi(): boolean;
5
+ declare function setOperation(operation: Operation): void;
@@ -0,0 +1,17 @@
1
+ export { isVikeCliOrApi };
2
+ // export { getOperation }
3
+ export { setOperation as setOperation };
4
+ import { assert } from './utils.js';
5
+ let apiOperation;
6
+ function getOperation() {
7
+ assert(apiOperation);
8
+ return apiOperation;
9
+ }
10
+ function isVikeCliOrApi() {
11
+ // The CLI uses the API
12
+ return !!apiOperation;
13
+ }
14
+ function setOperation(operation) {
15
+ assert(!apiOperation);
16
+ apiOperation = operation;
17
+ }
@@ -1,3 +1,7 @@
1
1
  export { dev };
2
- import type { APIOptions } from './APIOptions.js';
3
- declare function dev(options?: APIOptions): Promise<import("vite").ViteDevServer>;
2
+ import { type ResolvedConfig, type ViteDevServer } from 'vite';
3
+ import type { APIOptions } from './types.js';
4
+ declare function dev(options?: APIOptions): Promise<{
5
+ viteServer: ViteDevServer;
6
+ viteConfig: ResolvedConfig;
7
+ }>;
@@ -1,8 +1,11 @@
1
1
  export { dev };
2
- import { enhanceViteConfig } from './enhanceViteConfig.js';
2
+ import { prepareApiCall } from './prepareApiCall.js';
3
3
  import { createServer } from 'vite';
4
4
  async function dev(options = {}) {
5
- const { viteConfigEnhanced } = await enhanceViteConfig(options.viteConfig, 'dev');
5
+ const { viteConfigEnhanced } = await prepareApiCall(options.viteConfig, 'dev');
6
6
  const server = await createServer(viteConfigEnhanced);
7
- return server;
7
+ return {
8
+ viteServer: server,
9
+ viteConfig: server.config
10
+ };
8
11
  }
@@ -0,0 +1,2 @@
1
+ export { onLoad };
2
+ declare function onLoad(): void;