vike 0.4.237-commit-e549c30 → 0.4.237-commit-fd8294f

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 (86) hide show
  1. package/dist/cjs/client/runtime-server-routing/utils.js +1 -1
  2. package/dist/cjs/node/api/build.js +4 -30
  3. package/dist/cjs/node/prerender/runPrerender.js +5 -6
  4. package/dist/cjs/node/runtime/renderPage/analyzePage.js +3 -1
  5. package/dist/cjs/node/runtime/renderPage/createPageContextServerSide.js +1 -1
  6. package/dist/cjs/node/runtime/renderPage/execHookOnRenderHtml.js +1 -11
  7. package/dist/cjs/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +42 -46
  8. package/dist/cjs/node/runtime/renderPage/{renderPageAlreadyRouted.js → renderPageAfterRoute.js} +3 -4
  9. package/dist/cjs/node/runtime/renderPage.js +6 -9
  10. package/dist/cjs/node/runtime/utils.js +1 -1
  11. package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +3 -5
  12. package/dist/cjs/node/vite/plugins/pluginBuild/pluginAutoFullBuild.js +8 -26
  13. package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +2 -9
  14. package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +0 -8
  15. package/dist/cjs/node/vite/plugins/pluginDev/determineOptimizeDeps.js +3 -2
  16. package/dist/cjs/node/vite/plugins/pluginFileEnv.js +4 -3
  17. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js +51 -21
  18. package/dist/cjs/node/vite/shared/getOutDirs.js +5 -4
  19. package/dist/cjs/node/vite/shared/isViteServerSide.js +46 -19
  20. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +20 -36
  21. package/dist/cjs/shared/page-configs/{loadPageEntry.js → loadAndParseVirtualFilePageEntry.js} +2 -2
  22. package/dist/cjs/shared/page-configs/resolveVikeConfigPublic.js +5 -0
  23. package/dist/cjs/shared/route/execHookOnBeforeRoute.js +0 -1
  24. package/dist/cjs/shared/route/index.js +0 -1
  25. package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
  26. package/dist/cjs/utils/{augmentType.js → updateType.js} +3 -3
  27. package/dist/esm/__internal/index.d.ts +1 -1
  28. package/dist/esm/client/runtime-client-routing/createPageContextClientSide.js +2 -2
  29. package/dist/esm/client/runtime-client-routing/renderPageClientSide.js +6 -6
  30. package/dist/esm/client/runtime-client-routing/utils.d.ts +1 -1
  31. package/dist/esm/client/runtime-client-routing/utils.js +1 -1
  32. package/dist/esm/client/runtime-server-routing/createPageContextClientSide.js +3 -3
  33. package/dist/esm/client/runtime-server-routing/utils.d.ts +1 -1
  34. package/dist/esm/client/runtime-server-routing/utils.js +1 -1
  35. package/dist/esm/client/shared/loadPageConfigsLazyClientSide.js +2 -2
  36. package/dist/esm/node/api/build.js +5 -31
  37. package/dist/esm/node/prerender/runPrerender.d.ts +9 -300
  38. package/dist/esm/node/prerender/runPrerender.js +6 -7
  39. package/dist/esm/node/runtime/renderPage/analyzePage.d.ts +4 -3
  40. package/dist/esm/node/runtime/renderPage/analyzePage.js +3 -1
  41. package/dist/esm/node/runtime/renderPage/createPageContextServerSide.js +2 -2
  42. package/dist/esm/node/runtime/renderPage/execHookOnRenderHtml.d.ts +0 -1
  43. package/dist/esm/node/runtime/renderPage/execHookOnRenderHtml.js +1 -11
  44. package/dist/esm/node/runtime/renderPage/getPageAssets.d.ts +2 -4
  45. package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.d.ts +1 -1
  46. package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.d.ts +105 -19
  47. package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +44 -48
  48. package/dist/esm/node/runtime/renderPage/{renderPageAlreadyRouted.d.ts → renderPageAfterRoute.d.ts} +20 -4
  49. package/dist/esm/node/runtime/renderPage/{renderPageAlreadyRouted.js → renderPageAfterRoute.js} +5 -6
  50. package/dist/esm/node/runtime/renderPage.js +8 -11
  51. package/dist/esm/node/runtime/utils.d.ts +1 -1
  52. package/dist/esm/node/runtime/utils.js +1 -1
  53. package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.d.ts +0 -1
  54. package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.js +5 -7
  55. package/dist/esm/node/vite/plugins/pluginBuild/pluginAutoFullBuild.js +10 -28
  56. package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildApp.js +2 -9
  57. package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +0 -8
  58. package/dist/esm/node/vite/plugins/pluginDev/determineOptimizeDeps.js +3 -2
  59. package/dist/esm/node/vite/plugins/pluginFileEnv.js +4 -3
  60. package/dist/esm/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.d.ts +5 -1
  61. package/dist/esm/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js +52 -22
  62. package/dist/esm/node/vite/shared/getOutDirs.js +5 -4
  63. package/dist/esm/node/vite/shared/isViteServerSide.d.ts +1 -1
  64. package/dist/esm/node/vite/shared/isViteServerSide.js +46 -19
  65. package/dist/esm/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.d.ts +3 -2
  66. package/dist/esm/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +21 -37
  67. package/dist/esm/node/vite/shared/resolveVikeConfigInternal.d.ts +2 -0
  68. package/dist/esm/shared/page-configs/loadAndParseVirtualFilePageEntry.d.ts +3 -0
  69. package/dist/esm/shared/page-configs/{loadPageEntry.js → loadAndParseVirtualFilePageEntry.js} +2 -2
  70. package/dist/esm/shared/page-configs/resolveVikeConfigPublic.js +5 -0
  71. package/dist/esm/shared/route/execHookOnBeforeRoute.d.ts +3 -3
  72. package/dist/esm/shared/route/execHookOnBeforeRoute.js +0 -1
  73. package/dist/esm/shared/route/index.d.ts +5 -6
  74. package/dist/esm/shared/route/index.js +0 -1
  75. package/dist/esm/types/Config.d.ts +2 -4
  76. package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
  77. package/dist/esm/utils/PROJECT_VERSION.js +1 -1
  78. package/dist/esm/utils/updateType.d.ts +3 -0
  79. package/dist/esm/utils/updateType.js +7 -0
  80. package/package.json +4 -4
  81. package/dist/cjs/node/runtime/renderPage/debugPageFiles.js +0 -52
  82. package/dist/esm/node/runtime/renderPage/debugPageFiles.d.ts +0 -23
  83. package/dist/esm/node/runtime/renderPage/debugPageFiles.js +0 -47
  84. package/dist/esm/shared/page-configs/loadPageEntry.d.ts +0 -3
  85. package/dist/esm/utils/augmentType.d.ts +0 -3
  86. package/dist/esm/utils/augmentType.js +0 -7
@@ -1,30 +1,49 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getConfigValueSourcesRelevant = getConfigValueSourcesRelevant;
4
+ exports.getConfigValueSourceRelevantAnyEnv = getConfigValueSourceRelevantAnyEnv;
4
5
  exports.isRuntimeEnvMatch = isRuntimeEnvMatch;
6
+ exports.isConfigSourceValueNull = isConfigSourceValueNull;
5
7
  const utils_js_1 = require("../../utils.js");
8
+ (0, utils_js_1.assertIsNotBrowser)();
6
9
  function getConfigValueSourcesRelevant(configName, runtimeEnv, pageConfig) {
7
10
  const configDef = pageConfig.configDefinitions[configName];
8
11
  (0, utils_js_1.assert)(configDef);
9
12
  let sourcesRelevant = pageConfig.configValueSources[configName];
10
13
  if (!sourcesRelevant)
11
14
  return [];
12
- if (!configDef.cumulative) {
15
+ // Ignore configs with value `undefined`
16
+ sourcesRelevant = sourcesRelevant.filter((source) => !isConfigSourceValueUndefined(source));
17
+ // Environment filtering
18
+ sourcesRelevant = sourcesRelevant.filter((source) => isRuntimeEnvMatch(source.configEnv, runtimeEnv));
19
+ // Overriding - non-cumulative configs
20
+ if (!configDef.cumulative && sourcesRelevant.length > 1) {
13
21
  const source = sourcesRelevant[0];
14
- if (source) {
15
- sourcesRelevant = [source];
16
- }
17
- else {
18
- (0, utils_js_1.assert)(sourcesRelevant.length === 0);
19
- }
22
+ (0, utils_js_1.assert)(source);
23
+ sourcesRelevant = [source];
20
24
  }
21
- else {
22
- // isOverridden() must be called before isRuntimeEnvMatch() is called (otherwise isOverridden() will return a wrong value)
23
- sourcesRelevant = sourcesRelevant.filter((source) => !isOverridden(source, configName, pageConfig));
25
+ // Overriding - cumulative configs
26
+ if (configDef.cumulative && sourcesRelevant.length > 0) {
27
+ sourcesRelevant = applyFilenameSuffix(sourcesRelevant);
24
28
  }
25
- sourcesRelevant = sourcesRelevant.filter((source) => isRuntimeEnvMatch(source.configEnv, runtimeEnv));
26
29
  return sourcesRelevant;
27
30
  }
31
+ function getConfigValueSourceRelevantAnyEnv(configName, pageConfig) {
32
+ const configDef = pageConfig.configDefinitions[configName];
33
+ (0, utils_js_1.assert)(configDef);
34
+ (0, utils_js_1.assert)(!configDef.cumulative); // So far, this function is only used by non-cumulative configs
35
+ let sourcesRelevant = pageConfig.configValueSources[configName];
36
+ if (!sourcesRelevant)
37
+ return null;
38
+ // Ignore configs with value `undefined`
39
+ sourcesRelevant = sourcesRelevant.filter((source) => !isConfigSourceValueUndefined(source));
40
+ const source = sourcesRelevant[0];
41
+ if (!source)
42
+ return null;
43
+ if (isConfigSourceValueNull(source))
44
+ return null;
45
+ return source;
46
+ }
28
47
  function isRuntimeEnvMatch(configEnv, runtimeEnv) {
29
48
  if ('isForConfig' in runtimeEnv)
30
49
  return !!configEnv.config;
@@ -54,14 +73,25 @@ function isRuntimeEnvMatch(configEnv, runtimeEnv) {
54
73
  }
55
74
  return true;
56
75
  }
57
- function isOverridden(source, configName, pageConfig) {
58
- const configDef = pageConfig.configDefinitions[configName];
59
- (0, utils_js_1.assert)(configDef);
60
- if (configDef.cumulative)
61
- return false;
62
- const sources = pageConfig.configValueSources[configName];
63
- (0, utils_js_1.assert)(sources);
64
- const idx = sources.indexOf(source);
65
- (0, utils_js_1.assert)(idx >= 0);
66
- return idx > 0;
76
+ // Setting a config to `undefined` should be equivalent to not setting it at all
77
+ function isConfigSourceValueUndefined(source) {
78
+ if (!source.valueIsLoaded)
79
+ return null;
80
+ return source.value === undefined;
81
+ }
82
+ // Setting a config to `null` enables the user to suppress inherited config by overriding it with `null` (this only works when setting the config value to `null` inside a +config.js file — it doesn't work when setting the config value to `null` with a +{configName}.js file).
83
+ function isConfigSourceValueNull(source) {
84
+ if (!source.valueIsLoaded)
85
+ return null;
86
+ return source.value === null;
87
+ }
88
+ function applyFilenameSuffix(sourcesRelevant) {
89
+ const getFileName = (source) => source.plusFile?.filePath.fileName ?? '';
90
+ // Apply `clear`: truncate at first clear file
91
+ const clearIndex = sourcesRelevant.findIndex((source) => getFileName(source).includes('.clear.'));
92
+ if (clearIndex !== -1)
93
+ sourcesRelevant = sourcesRelevant.slice(0, clearIndex + 1);
94
+ // Apply `default`: exclude defaults if any non-defaults exist, otherwise keep only first default
95
+ const nonDefaults = sourcesRelevant.filter((source) => !getFileName(source).includes('.default.'));
96
+ return nonDefaults.length > 0 ? nonDefaults : sourcesRelevant.slice(0, 1);
67
97
  }
@@ -12,7 +12,7 @@ const isViteServerSide_js_1 = require("./isViteServerSide.js");
12
12
  const debug = (0, utils_js_1.createDebugger)('vike:outDir');
13
13
  function getOutDirs(configGlobal, viteEnv) {
14
14
  debug('getOutDirs()', new Error().stack);
15
- const outDir = getOutDirFromResolvedConfig(configGlobal);
15
+ const outDir = getOutDirFromResolvedConfig(configGlobal, viteEnv);
16
16
  assertOutDirResolved(outDir, configGlobal, viteEnv);
17
17
  const outDirs = getOutDirsAll(outDir, configGlobal.root);
18
18
  assertNormalization(outDirs.outDirRoot);
@@ -119,7 +119,8 @@ function assertOutDirResolved(outDir, configGlobal, viteEnv) {
119
119
  (0, utils_js_1.assert)('/client'.length === '/server'.length);
120
120
  const outDirCorrected = outDir.slice(0, -1 * '/client'.length);
121
121
  const wrongUsage = `You've set Vite's config.build.outDir to ${picocolors_1.default.cyan(outDir)} but you should set it to ${picocolors_1.default.cyan(outDirCorrected)} instead.`;
122
- if ((0, isViteServerSide_js_1.isViteServerSide_withoutEnv)(configGlobal, viteEnv)) {
122
+ const isServerSide = (0, isViteServerSide_js_1.isViteServerSide_withoutEnv)(configGlobal, viteEnv);
123
+ if (isServerSide) {
123
124
  (0, utils_js_1.assertUsage)(outDir.endsWith('/server'), wrongUsage);
124
125
  }
125
126
  else {
@@ -133,8 +134,8 @@ function getOutDirFromViteUserConfig(config) {
133
134
  outDir = normalizeOutDir(outDir);
134
135
  return outDir;
135
136
  }
136
- function getOutDirFromResolvedConfig(config) {
137
- let outDir = config.build.outDir;
137
+ function getOutDirFromResolvedConfig(config, viteEnv) {
138
+ let outDir = viteEnv?.config.build?.outDir ?? config.build.outDir;
138
139
  (0, utils_js_1.assert)(outDir);
139
140
  outDir = normalizeOutDir(outDir);
140
141
  return outDir;
@@ -6,16 +6,16 @@ exports.isViteServerSide_withoutEnv = isViteServerSide_withoutEnv;
6
6
  exports.isViteServerSide_onlySsrEnv = isViteServerSide_onlySsrEnv;
7
7
  exports.isViteServerSide_extraSafe = isViteServerSide_extraSafe;
8
8
  const assert_js_1 = require("../../../utils/assert.js");
9
- function isViteServerSide_withoutEnv(configGlobal, viteEnv) {
9
+ function isViteServerSide_impl(configGlobal, viteEnv) {
10
10
  (0, assert_js_1.assert)(!('consumer' in configGlobal)); // make sure configGlobal isn't viteEnv.config
11
11
  const isServerSide1 = !viteEnv?.config.consumer ? null : viteEnv.config.consumer !== 'client';
12
- const isServerSide2 = !viteEnv?.name ? null : viteEnv.name !== 'client'; // I can't think of a use case for creating another client-side environment
13
- const isServerSide3 = !viteEnv ? null : !!viteEnv.config.build?.ssr;
14
- const isServerSide4 = !!configGlobal.build?.ssr;
12
+ const isServerSide2 = !viteEnv?.config.build ? null : getBuildSsrValue(viteEnv.config.build.ssr);
13
+ const isServerSide3 = !configGlobal.build ? null : getBuildSsrValue(configGlobal.build.ssr);
14
+ const isServerSide4 = viteEnv?.name === 'ssr' ? true : viteEnv?.name === 'client' ? false : null;
15
15
  const debug = {
16
- envIsUndefined: !viteEnv,
17
- envName: viteEnv?.name ?? null,
18
- envConsumer: viteEnv?.config.consumer ?? null,
16
+ viteEnvIsUndefined: !viteEnv,
17
+ viteEnvName: viteEnv?.name ?? null,
18
+ viteEnvConsumer: viteEnv?.config.consumer ?? null,
19
19
  configEnvBuildSsr: viteEnv?.config.build?.ssr ?? null,
20
20
  configGlobalBuildSsr: configGlobal.build?.ssr ?? null,
21
21
  isServerSide1,
@@ -24,25 +24,36 @@ function isViteServerSide_withoutEnv(configGlobal, viteEnv) {
24
24
  isServerSide4,
25
25
  };
26
26
  if (isServerSide1 !== null) {
27
- (0, assert_js_1.assert)(isServerSide1 === isServerSide2 || isServerSide2 === null, debug);
27
+ // assert(isServerSide1 === isServerSide4 || isServerSide4 === null, debug)
28
28
  /* This assertion can fail, seems to be a Vite bug?
29
- assert(isServerSide1 === isServerSide3, debug)
29
+ assert(isServerSide1 === isServerSide2, debug)
30
30
  */
31
31
  return isServerSide1;
32
32
  }
33
33
  if (isServerSide2 !== null) {
34
- /* This assertion can fail, seems to be a Vite bug?
35
- assert(isServerSide2 === isServerSide3, debug)
36
- */
34
+ // assert(isServerSide2 === isServerSide4 || isServerSide4 === null, debug)
37
35
  return isServerSide2;
38
36
  }
39
37
  if (isServerSide3 !== null) {
38
+ // assert(isServerSide3 === isServerSide4 || isServerSide4 === null, debug)
40
39
  return isServerSide3;
41
40
  }
42
- return isServerSide4;
41
+ if (isServerSide4 !== null) {
42
+ return isServerSide4;
43
+ }
44
+ (0, assert_js_1.assert)(!viteEnv);
45
+ return !!configGlobal.build?.ssr;
46
+ }
47
+ function getBuildSsrValue(buildSsr) {
48
+ if (buildSsr === undefined)
49
+ return null;
50
+ return !!buildSsr;
43
51
  }
44
52
  function isViteServerSide(configGlobal, viteEnv) {
45
- return isViteServerSide_withoutEnv(configGlobal, viteEnv);
53
+ return isViteServerSide_impl(configGlobal, viteEnv);
54
+ }
55
+ function isViteServerSide_withoutEnv(configGlobal, viteEnv) {
56
+ return isViteServerSide_impl(configGlobal, viteEnv);
46
57
  }
47
58
  function isViteClientSide(configGlobal, viteEnv) {
48
59
  return !isViteServerSide(configGlobal, viteEnv);
@@ -53,20 +64,36 @@ function isViteServerSide_onlySsrEnv(configGlobal, viteEnv) {
53
64
  }
54
65
  // Vite is quite messy about setting config.build.ssr — for security purposes, we use an extra safe implementation with lots of assertions, which is needed for the .client.js and .server.js guarantee.
55
66
  function isViteServerSide_extraSafe(config, options, viteEnv) {
67
+ const isServerSide = isViteServerSide(config, viteEnv);
68
+ const debug = {
69
+ configCommand: config.command,
70
+ configBuildSsr: config.build.ssr,
71
+ optionsIsUndefined: options === undefined,
72
+ optionsSsr: options?.ssr,
73
+ isServerSide,
74
+ };
75
+ if (true) {
76
+ const res = options?.ssr;
77
+ if (typeof res === 'boolean') {
78
+ (0, assert_js_1.assert)(res === isServerSide, debug);
79
+ return res;
80
+ }
81
+ return isServerSide;
82
+ }
56
83
  if (config.command === 'build') {
57
84
  const res = config.build.ssr;
58
- (0, assert_js_1.assert)(typeof res === 'boolean');
59
- (0, assert_js_1.assert)(res === options?.ssr || options?.ssr === undefined);
60
- (0, assert_js_1.assert)(res === isViteServerSide(config, viteEnv));
85
+ (0, assert_js_1.assert)(typeof res === 'boolean', debug);
86
+ (0, assert_js_1.assert)(res === options?.ssr || options?.ssr === undefined, debug);
87
+ (0, assert_js_1.assert)(res === isServerSide, debug);
61
88
  return res;
62
89
  }
63
90
  else {
64
91
  const res = options?.ssr;
65
- (0, assert_js_1.assert)(typeof res === 'boolean');
92
+ (0, assert_js_1.assert)(typeof res === 'boolean', debug);
66
93
  /* This assertion can fail, seems to be a Vite bug? It's very unexpected.
67
94
  if (typeof config.build.ssr === 'boolean') assert(res === config.build.ssr)
68
95
  */
69
- (0, assert_js_1.assert)(res === isViteServerSide(config, viteEnv));
96
+ (0, assert_js_1.assert)(res === isServerSide, debug);
70
97
  return res;
71
98
  }
72
99
  }
@@ -110,7 +110,9 @@ const configDefinitionsBuiltIn = {
110
110
  }, pageConfig))
111
111
  .flat(1)
112
112
  // Server-only
113
- .filter((source) => !source.configEnv.client);
113
+ .filter((source) => !source.configEnv.client)
114
+ // Config value isn't `null`
115
+ .filter((source) => !(0, getConfigValueSourcesRelevant_js_1.isConfigSourceValueNull)(source));
114
116
  return sources.length > 0;
115
117
  },
116
118
  },
@@ -122,22 +124,19 @@ const configDefinitionsBuiltIn = {
122
124
  env: { server: true, client: true },
123
125
  eager: true,
124
126
  _computed: (pageConfig) => {
125
- const { configValueSources } = pageConfig;
126
127
  {
127
- const source = getConfigValueSource(configValueSources, 'clientHooks');
128
+ const source = (0, getConfigValueSourcesRelevant_js_1.getConfigValueSourceRelevantAnyEnv)('clientHooks', pageConfig);
128
129
  if (source) {
129
130
  (0, utils_js_1.assert)(source.valueIsLoaded);
130
- if (source.value !== null) {
131
- const { value } = source;
132
- const definedAt = (0, getConfigDefinedAt_js_1.getConfigDefinedAt)('Config', 'clientHooks', source.definedAt);
133
- (0, utils_js_1.assertUsage)(typeof value === 'boolean', `${definedAt} should be a boolean`);
134
- return value;
135
- }
131
+ const { value, definedAt } = source;
132
+ const configDefinedAt = (0, getConfigDefinedAt_js_1.getConfigDefinedAt)('Config', 'clientHooks', definedAt);
133
+ (0, utils_js_1.assertUsage)(typeof value === 'boolean', `${configDefinedAt} should be a boolean`);
134
+ return value;
136
135
  }
137
136
  }
138
- return (isConfigSet(configValueSources, 'onRenderClient') &&
139
- isConfigSet(configValueSources, 'Page') &&
140
- !!getConfigEnv(configValueSources, 'Page')?.client);
137
+ return (isConfigSet(pageConfig, 'onRenderClient') &&
138
+ isConfigSet(pageConfig, 'Page') &&
139
+ !!getConfigEnv(pageConfig, 'Page')?.client);
141
140
  },
142
141
  },
143
142
  // TO-DO/soon/cumulative-hooks: remove and replace with new computed prop `clientOnlyHooks: string[]` (see other TO-DO/soon/cumulative-hooks entries)
@@ -145,10 +144,7 @@ const configDefinitionsBuiltIn = {
145
144
  env: { client: true },
146
145
  eager: true,
147
146
  _computed: (pageConfig) => {
148
- const { configValueSources } = pageConfig;
149
- return !isConfigSet(configValueSources, 'onBeforeRender')
150
- ? null
151
- : getConfigEnv(configValueSources, 'onBeforeRender');
147
+ return !isConfigSet(pageConfig, 'onBeforeRender') ? null : getConfigEnv(pageConfig, 'onBeforeRender');
152
148
  },
153
149
  },
154
150
  // TO-DO/soon/cumulative-hooks: remove and replace with new computed prop `clientOnlyHooks: string[]` (see other TO-DO/soon/cumulative-hooks entries)
@@ -156,8 +152,7 @@ const configDefinitionsBuiltIn = {
156
152
  env: { client: true },
157
153
  eager: true,
158
154
  _computed: (pageConfig) => {
159
- const { configValueSources } = pageConfig;
160
- return !isConfigSet(configValueSources, 'data') ? null : getConfigEnv(configValueSources, 'data');
155
+ return !isConfigSet(pageConfig, 'data') ? null : getConfigEnv(pageConfig, 'data');
161
156
  },
162
157
  },
163
158
  hooksTimeout: {
@@ -246,11 +241,11 @@ const configDefinitionsBuiltIn = {
246
241
  },
247
242
  };
248
243
  exports.configDefinitionsBuiltIn = configDefinitionsBuiltIn;
249
- function getConfigEnv(configValueSources, configName) {
250
- const configValueSource = getConfigValueSource(configValueSources, configName);
251
- if (!configValueSource)
244
+ function getConfigEnv(pageConfig, configName) {
245
+ const source = (0, getConfigValueSourcesRelevant_js_1.getConfigValueSourceRelevantAnyEnv)(configName, pageConfig);
246
+ if (!source)
252
247
  return null;
253
- const { configEnv } = configValueSource;
248
+ const { configEnv } = source;
254
249
  const env = {};
255
250
  if (configEnv.client)
256
251
  env.client = true;
@@ -258,18 +253,7 @@ function getConfigEnv(configValueSources, configName) {
258
253
  env.server = true;
259
254
  return env;
260
255
  }
261
- function isConfigSet(configValueSources, configName) {
262
- const source = getConfigValueSource(configValueSources, configName);
263
- return (!!source &&
264
- !(source.valueIsLoaded &&
265
- // Enable users to suppress inherited config by overriding it with `null`
266
- source.value === null));
267
- }
268
- function getConfigValueSource(configValueSources, configName) {
269
- const sources = configValueSources[configName];
270
- if (!sources)
271
- return null;
272
- const configValueSource = sources[0];
273
- (0, utils_js_1.assert)(configValueSource);
274
- return configValueSource;
256
+ function isConfigSet(pageConfig, configName) {
257
+ const source = (0, getConfigValueSourcesRelevant_js_1.getConfigValueSourceRelevantAnyEnv)(configName, pageConfig);
258
+ return !!source;
275
259
  }
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadPageEntry = loadPageEntry;
3
+ exports.loadAndParseVirtualFilePageEntry = loadAndParseVirtualFilePageEntry;
4
4
  const utils_js_1 = require("../utils.js");
5
5
  const parsePageConfigsSerialized_js_1 = require("./serialize/parsePageConfigsSerialized.js");
6
- async function loadPageEntry(pageConfig, isDev) {
6
+ async function loadAndParseVirtualFilePageEntry(pageConfig, isDev) {
7
7
  if ('isPageEntryLoaded' in pageConfig &&
8
8
  // We don't need to cache in dev, since Vite already caches the virtual module
9
9
  !isDev) {
@@ -1,4 +1,9 @@
1
1
  "use strict";
2
+ // TO-DO/soon: rename PageConfig names
3
+ // - Use `Internal` suffix, i.e. {Page,Global}ConfigInternal
4
+ // - While keeping {Page,Global}ConfigPublic or remove Public suffix and rename it to {Page,Global}Config ?
5
+ // - rename EagerLoaded EagerlyLoaded
6
+ // - remove `LazyLoaded` suffix
2
7
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
8
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
9
  };
@@ -28,7 +28,6 @@ async function execHookOnBeforeRoute(pageContext) {
28
28
  }
29
29
  (0, utils_js_1.objectAssign)(pageContextFromOnBeforeRouteHook, {
30
30
  _routingProvidedByOnBeforeRouteHook: true,
31
- _debugRouteMatches: 'CUSTOM_ROUTING',
32
31
  });
33
32
  return pageContextFromOnBeforeRouteHook;
34
33
  }
@@ -86,7 +86,6 @@ async function route(pageContext, skipOnBeforeRouteHook) {
86
86
  (0, resolvePrecedence_js_1.resolvePrecedence)(routeMatches);
87
87
  const winner = routeMatches[0] ?? null;
88
88
  (0, debug_js_1.debug)(`Route matches for URL ${picocolors_1.default.cyan(urlPathname)} (in precedence order):`, routeMatches);
89
- (0, utils_js_1.objectAssign)(pageContextFromRoute, { _debugRouteMatches: routeMatches });
90
89
  // For vite-plugin-vercel https://github.com/magne4000/vite-plugin-vercel/blob/main/packages/vike-integration/vike.ts#L173
91
90
  (0, utils_js_1.objectAssign)(pageContextFromRoute, { _routeMatch: winner });
92
91
  if (!winner) {
@@ -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.237-commit-e549c30';
5
+ exports.PROJECT_VERSION = '0.4.237-commit-fd8294f';
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.augmentType = augmentType;
3
+ exports.updateType = updateType;
4
4
  const assert_js_1 = require("./assert.js");
5
- /** Help TypeScript augment the type of objects. */
6
- function augmentType(thing, clone) {
5
+ /** Help TypeScript update the type of dynamically modified objects. */
6
+ function updateType(thing, clone) {
7
7
  // @ts-ignore
8
8
  (0, assert_js_1.assert)(thing === clone);
9
9
  }
@@ -16,5 +16,5 @@ declare function getPagesAndRoutes(): Promise<{
16
16
  allPageIds: string[];
17
17
  }>;
18
18
  declare function route(pageContext: Parameters<typeof routeInternal>[0]): Promise<{
19
- pageContextAddendum: import("../shared/route/index.js").PageContextFromRoute;
19
+ pageContextAddendum: import("../shared/route/index.js").PageContextAfterRoute;
20
20
  }>;
@@ -3,7 +3,7 @@ import { createPageContextObject, createPageContextShared } from '../../shared/c
3
3
  import { getPageContextUrlComputed } from '../../shared/getPageContextUrlComputed.js';
4
4
  import { getBaseServer } from './getBaseServer.js';
5
5
  import { getGlobalContextClientInternal } from './globalContext.js';
6
- import { assert, augmentType, isBaseServer, objectAssign } from './utils.js';
6
+ import { assert, updateType, isBaseServer, objectAssign } from './utils.js';
7
7
  async function createPageContextClientSide(urlOriginal) {
8
8
  const globalContext = await getGlobalContextClientInternal();
9
9
  const baseServer = getBaseServer();
@@ -22,6 +22,6 @@ async function createPageContextClientSide(urlOriginal) {
22
22
  const pageContextUrlComputed = getPageContextUrlComputed(pageContextCreated);
23
23
  objectAssign(pageContextCreated, pageContextUrlComputed);
24
24
  const pageContextAugmented = createPageContextShared(pageContextCreated, globalContext._vikeConfigPublicGlobal);
25
- augmentType(pageContextCreated, pageContextAugmented);
25
+ updateType(pageContextCreated, pageContextAugmented);
26
26
  return pageContextCreated;
27
27
  }
@@ -3,7 +3,7 @@ export { getRenderCount };
3
3
  export { disableClientRouting };
4
4
  export { firstRenderStartPromise };
5
5
  export { getPageContextClient };
6
- import { assert, isSameErrorMessage, objectAssign, redirectHard, getGlobalObject, hasProp, augmentType, genPromise, isCallable, catchInfiniteLoop, } from './utils.js';
6
+ import { assert, isSameErrorMessage, objectAssign, redirectHard, getGlobalObject, hasProp, updateType, genPromise, isCallable, catchInfiniteLoop, } from './utils.js';
7
7
  import { getPageContextFromClientHooks, getPageContextFromServerHooks, getPageContextFromHooks_isHydration, getPageContextFromHooks_serialized, setPageContextInitIsPassedToClient, } from './getPageContextFromHooks.js';
8
8
  import { createPageContextClientSide } from './createPageContextClientSide.js';
9
9
  import { addLinkPrefetchHandlers, addLinkPrefetchHandlers_unwatch, addLinkPrefetchHandlers_watch, getPageContextPrefetched, populatePageContextPrefetchCache, } from './prefetch.js';
@@ -159,7 +159,7 @@ async function renderPageClientSide(renderArgs) {
159
159
  await onError(res.err);
160
160
  return;
161
161
  }
162
- augmentType(pageContext, res.pageContext);
162
+ updateType(pageContext, res.pageContext);
163
163
  setPageContextCurrent(pageContext);
164
164
  // Set global hydrationCanBeAborted
165
165
  if (pageContext.exports.hydrationCanBeAborted) {
@@ -184,7 +184,7 @@ async function renderPageClientSide(renderArgs) {
184
184
  }
185
185
  if (isRenderOutdated())
186
186
  return;
187
- augmentType(pageContext, pageContextAugmented);
187
+ updateType(pageContext, pageContextAugmented);
188
188
  // Render page view
189
189
  await renderPageView(pageContext);
190
190
  }
@@ -225,7 +225,7 @@ async function renderPageClientSide(renderArgs) {
225
225
  }
226
226
  if (isRenderOutdated())
227
227
  return;
228
- augmentType(pageContext, pageContextFromClientHooks);
228
+ updateType(pageContext, pageContextFromClientHooks);
229
229
  await renderPageView(pageContext);
230
230
  }
231
231
  }
@@ -336,7 +336,7 @@ async function renderPageClientSide(renderArgs) {
336
336
  onError(res.err);
337
337
  return;
338
338
  }
339
- augmentType(pageContext, res.pageContext);
339
+ updateType(pageContext, res.pageContext);
340
340
  setPageContextCurrent(pageContext);
341
341
  let pageContextFromServerHooks;
342
342
  try {
@@ -364,7 +364,7 @@ async function renderPageClientSide(renderArgs) {
364
364
  }
365
365
  if (isRenderOutdated())
366
366
  return;
367
- augmentType(pageContext, pageContextFromClientHooks);
367
+ updateType(pageContext, pageContextFromClientHooks);
368
368
  await renderPageView(pageContext, args);
369
369
  }
370
370
  async function renderPageView(pageContext, isErrorPage) {
@@ -17,7 +17,7 @@ export * from '../../utils/slice.js';
17
17
  export * from '../../utils/throttle.js';
18
18
  export * from '../../utils/assertRoutingType.js';
19
19
  export * from '../../utils/onPageVisibilityChange.js';
20
- export * from '../../utils/augmentType.js';
20
+ export * from '../../utils/updateType.js';
21
21
  export * from '../../utils/PROJECT_VERSION.js';
22
22
  export * from '../../utils/genPromise.js';
23
23
  export * from '../../utils/catchInfiniteLoop.js';
@@ -21,7 +21,7 @@ export * from '../../utils/slice.js';
21
21
  export * from '../../utils/throttle.js';
22
22
  export * from '../../utils/assertRoutingType.js';
23
23
  export * from '../../utils/onPageVisibilityChange.js';
24
- export * from '../../utils/augmentType.js';
24
+ export * from '../../utils/updateType.js';
25
25
  export * from '../../utils/PROJECT_VERSION.js';
26
26
  export * from '../../utils/genPromise.js';
27
27
  export * from '../../utils/catchInfiniteLoop.js';
@@ -1,5 +1,5 @@
1
1
  export { createPageContextClientSide };
2
- import { assertUsage, augmentType, objectAssign } from './utils.js';
2
+ import { assertUsage, updateType, objectAssign } from './utils.js';
3
3
  import { getPageContextSerializedInHtml } from '../shared/getJsonSerializedInHtml.js';
4
4
  import { loadPageConfigsLazyClientSide, } from '../shared/loadPageConfigsLazyClientSide.js';
5
5
  import { getCurrentUrl } from '../shared/getCurrentUrl.js';
@@ -22,9 +22,9 @@ async function createPageContextClientSide() {
22
22
  });
23
23
  objectAssign(pageContextCreated, getPageContextSerializedInHtml());
24
24
  // Sets pageContext.config to global configs
25
- augmentType(pageContextCreated, createPageContextShared(pageContextCreated, globalContext._vikeConfigPublicGlobal));
25
+ updateType(pageContextCreated, createPageContextShared(pageContextCreated, globalContext._vikeConfigPublicGlobal));
26
26
  // Sets pageContext.config to local configs (overrides the pageContext.config set above)
27
- augmentType(pageContextCreated, await loadPageConfigsLazyClientSideAndExecHook(pageContextCreated));
27
+ updateType(pageContextCreated, await loadPageConfigsLazyClientSideAndExecHook(pageContextCreated));
28
28
  assertPristineUrl();
29
29
  return pageContextCreated;
30
30
  }
@@ -10,5 +10,5 @@ export * from '../../utils/parseUrl.js';
10
10
  export * from '../../utils/slice.js';
11
11
  export * from '../../utils/unique.js';
12
12
  export * from '../../utils/getPropAccessNotation.js';
13
- export * from '../../utils/augmentType.js';
13
+ export * from '../../utils/updateType.js';
14
14
  export * from '../../utils/changeEnumerable.js';
@@ -14,5 +14,5 @@ export * from '../../utils/parseUrl.js';
14
14
  export * from '../../utils/slice.js';
15
15
  export * from '../../utils/unique.js'; // Only used by Server Routing (not needed for Client Routing)
16
16
  export * from '../../utils/getPropAccessNotation.js';
17
- export * from '../../utils/augmentType.js';
17
+ export * from '../../utils/updateType.js';
18
18
  export * from '../../utils/changeEnumerable.js';
@@ -3,7 +3,7 @@ export { isErrorFetchingStaticAssets };
3
3
  import { getPageFilesClientSide } from '../../shared/getPageFiles.js';
4
4
  import { resolveVikeConfigPublicPageLazyLoaded } from '../../shared/page-configs/resolveVikeConfigPublic.js';
5
5
  import { findPageConfig } from '../../shared/page-configs/findPageConfig.js';
6
- import { loadPageEntry } from '../../shared/page-configs/loadPageEntry.js';
6
+ import { loadAndParseVirtualFilePageEntry } from '../../shared/page-configs/loadAndParseVirtualFilePageEntry.js';
7
7
  import { objectAssign } from '../runtime-server-routing/utils.js';
8
8
  const errStamp = '_isAssetsError';
9
9
  async function loadPageConfigsLazyClientSide(pageId, pageFilesAll, pageConfigs, pageConfigGlobal) {
@@ -16,7 +16,7 @@ async function loadPageConfigsLazyClientSide(pageId, pageFilesAll, pageConfigs,
16
16
  // prettier-ignore
17
17
  // biome-ignore format:
18
18
  const result = await Promise.all([
19
- pageConfig && loadPageEntry(pageConfig, isDev),
19
+ pageConfig && loadAndParseVirtualFilePageEntry(pageConfig, isDev),
20
20
  ...pageFilesClientSide.map((p) => p.loadFile?.()),
21
21
  ]);
22
22
  pageConfigLoaded = result[0];
@@ -1,45 +1,19 @@
1
1
  export { build };
2
2
  import { prepareViteApiCall } from './prepareViteApiCall.js';
3
- import { build as buildVite, version, createBuilder } from 'vite';
4
- import { isVikeCli } from '../cli/context.js';
5
- import { wasPrerenderRun } from '../prerender/context.js';
6
- import { assert, assertVersion } from './utils.js';
3
+ import { createBuilder } from 'vite';
7
4
  /**
8
5
  * Programmatically trigger `$ vike build`
9
6
  *
10
7
  * https://vike.dev/api#build
11
8
  */
12
9
  async function build(options = {}) {
13
- const { viteConfigFromUserEnhanced, vikeConfig } = await prepareViteApiCall(options, 'build');
10
+ const { viteConfigFromUserEnhanced } = await prepareViteApiCall(options, 'build');
14
11
  // Pass it to pluginAutoFullBuild()
15
12
  if (viteConfigFromUserEnhanced)
16
13
  viteConfigFromUserEnhanced._viteConfigFromUserEnhanced = viteConfigFromUserEnhanced;
17
- if (vikeConfig.config.vite6BuilderApp) {
18
- // This assertion isn't reliable: the user may still use a Vite version older than 6.0.0 — see https://github.com/vitejs/vite/pull/19355
19
- assertVersion('Vite', version, '6.0.0');
20
- const builder = await createBuilder(viteConfigFromUserEnhanced);
21
- // See Vite plugin vike:build:pluginBuildApp
22
- await builder.buildApp();
23
- }
24
- else {
25
- // This buildVite() call does everything:
26
- // 1. Build client-side
27
- // 2. Build server-side
28
- // > See: https://github.com/vikejs/vike/blob/c6c7533a56b3a16fc43ed644fc5c10c02d0ff375/vike/node/plugin/plugins/autoFullBuild.ts#L90
29
- // 3. Pre-render (if enabled)
30
- // > See: https://github.com/vikejs/vike/blob/c6c7533a56b3a16fc43ed644fc5c10c02d0ff375/vike/node/plugin/plugins/autoFullBuild.ts#L98
31
- // > We purposely don't start the pre-rendering in this `build()` function but in a Rollup hook instead.
32
- // > Rationale: https://github.com/vikejs/vike/issues/2123
33
- await buildVite(viteConfigFromUserEnhanced);
34
- // After pre-rendering, when using the Vike CLI, the process is forcefully exited at the end of the buildVite() call above.
35
- if (
36
- // When calling Vike's prerender() API pre-rendering is run without force exit
37
- ![false, 'prerender()'].includes(wasPrerenderRun()) &&
38
- // When calling Vike's build() API pre-rendering is auto run without force exit
39
- isVikeCli()) {
40
- assert(false);
41
- }
42
- }
14
+ const builder = await createBuilder(viteConfigFromUserEnhanced);
15
+ // See Vite plugin vike:build:pluginBuildApp
16
+ await builder.buildApp();
43
17
  return {
44
18
  /* We don't return `viteConfig` because `viteConfigFromUserEnhanced` is `InlineConfig` not `ResolvedConfig`
45
19
  viteConfig: viteConfigFromUserEnhanced,