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,28 +1,47 @@
1
1
  export { getConfigValueSourcesRelevant };
2
+ export { getConfigValueSourceRelevantAnyEnv };
2
3
  export { isRuntimeEnvMatch };
3
- import { assert } from '../../utils.js';
4
+ export { isConfigSourceValueNull };
5
+ import { assert, assertIsNotBrowser } from '../../utils.js';
6
+ assertIsNotBrowser();
4
7
  function getConfigValueSourcesRelevant(configName, runtimeEnv, pageConfig) {
5
8
  const configDef = pageConfig.configDefinitions[configName];
6
9
  assert(configDef);
7
10
  let sourcesRelevant = pageConfig.configValueSources[configName];
8
11
  if (!sourcesRelevant)
9
12
  return [];
10
- if (!configDef.cumulative) {
13
+ // Ignore configs with value `undefined`
14
+ sourcesRelevant = sourcesRelevant.filter((source) => !isConfigSourceValueUndefined(source));
15
+ // Environment filtering
16
+ sourcesRelevant = sourcesRelevant.filter((source) => isRuntimeEnvMatch(source.configEnv, runtimeEnv));
17
+ // Overriding - non-cumulative configs
18
+ if (!configDef.cumulative && sourcesRelevant.length > 1) {
11
19
  const source = sourcesRelevant[0];
12
- if (source) {
13
- sourcesRelevant = [source];
14
- }
15
- else {
16
- assert(sourcesRelevant.length === 0);
17
- }
20
+ assert(source);
21
+ sourcesRelevant = [source];
18
22
  }
19
- else {
20
- // isOverridden() must be called before isRuntimeEnvMatch() is called (otherwise isOverridden() will return a wrong value)
21
- sourcesRelevant = sourcesRelevant.filter((source) => !isOverridden(source, configName, pageConfig));
23
+ // Overriding - cumulative configs
24
+ if (configDef.cumulative && sourcesRelevant.length > 0) {
25
+ sourcesRelevant = applyFilenameSuffix(sourcesRelevant);
22
26
  }
23
- sourcesRelevant = sourcesRelevant.filter((source) => isRuntimeEnvMatch(source.configEnv, runtimeEnv));
24
27
  return sourcesRelevant;
25
28
  }
29
+ function getConfigValueSourceRelevantAnyEnv(configName, pageConfig) {
30
+ const configDef = pageConfig.configDefinitions[configName];
31
+ assert(configDef);
32
+ assert(!configDef.cumulative); // So far, this function is only used by non-cumulative configs
33
+ let sourcesRelevant = pageConfig.configValueSources[configName];
34
+ if (!sourcesRelevant)
35
+ return null;
36
+ // Ignore configs with value `undefined`
37
+ sourcesRelevant = sourcesRelevant.filter((source) => !isConfigSourceValueUndefined(source));
38
+ const source = sourcesRelevant[0];
39
+ if (!source)
40
+ return null;
41
+ if (isConfigSourceValueNull(source))
42
+ return null;
43
+ return source;
44
+ }
26
45
  function isRuntimeEnvMatch(configEnv, runtimeEnv) {
27
46
  if ('isForConfig' in runtimeEnv)
28
47
  return !!configEnv.config;
@@ -52,14 +71,25 @@ function isRuntimeEnvMatch(configEnv, runtimeEnv) {
52
71
  }
53
72
  return true;
54
73
  }
55
- function isOverridden(source, configName, pageConfig) {
56
- const configDef = pageConfig.configDefinitions[configName];
57
- assert(configDef);
58
- if (configDef.cumulative)
59
- return false;
60
- const sources = pageConfig.configValueSources[configName];
61
- assert(sources);
62
- const idx = sources.indexOf(source);
63
- assert(idx >= 0);
64
- return idx > 0;
74
+ // Setting a config to `undefined` should be equivalent to not setting it at all
75
+ function isConfigSourceValueUndefined(source) {
76
+ if (!source.valueIsLoaded)
77
+ return null;
78
+ return source.value === undefined;
79
+ }
80
+ // 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).
81
+ function isConfigSourceValueNull(source) {
82
+ if (!source.valueIsLoaded)
83
+ return null;
84
+ return source.value === null;
85
+ }
86
+ function applyFilenameSuffix(sourcesRelevant) {
87
+ const getFileName = (source) => source.plusFile?.filePath.fileName ?? '';
88
+ // Apply `clear`: truncate at first clear file
89
+ const clearIndex = sourcesRelevant.findIndex((source) => getFileName(source).includes('.clear.'));
90
+ if (clearIndex !== -1)
91
+ sourcesRelevant = sourcesRelevant.slice(0, clearIndex + 1);
92
+ // Apply `default`: exclude defaults if any non-defaults exist, otherwise keep only first default
93
+ const nonDefaults = sourcesRelevant.filter((source) => !getFileName(source).includes('.default.'));
94
+ return nonDefaults.length > 0 ? nonDefaults : sourcesRelevant.slice(0, 1);
65
95
  }
@@ -7,7 +7,7 @@ import { isViteServerSide, isViteServerSide_withoutEnv } from './isViteServerSid
7
7
  const debug = createDebugger('vike:outDir');
8
8
  function getOutDirs(configGlobal, viteEnv) {
9
9
  debug('getOutDirs()', new Error().stack);
10
- const outDir = getOutDirFromResolvedConfig(configGlobal);
10
+ const outDir = getOutDirFromResolvedConfig(configGlobal, viteEnv);
11
11
  assertOutDirResolved(outDir, configGlobal, viteEnv);
12
12
  const outDirs = getOutDirsAll(outDir, configGlobal.root);
13
13
  assertNormalization(outDirs.outDirRoot);
@@ -114,7 +114,8 @@ function assertOutDirResolved(outDir, configGlobal, viteEnv) {
114
114
  assert('/client'.length === '/server'.length);
115
115
  const outDirCorrected = outDir.slice(0, -1 * '/client'.length);
116
116
  const wrongUsage = `You've set Vite's config.build.outDir to ${pc.cyan(outDir)} but you should set it to ${pc.cyan(outDirCorrected)} instead.`;
117
- if (isViteServerSide_withoutEnv(configGlobal, viteEnv)) {
117
+ const isServerSide = isViteServerSide_withoutEnv(configGlobal, viteEnv);
118
+ if (isServerSide) {
118
119
  assertUsage(outDir.endsWith('/server'), wrongUsage);
119
120
  }
120
121
  else {
@@ -128,8 +129,8 @@ function getOutDirFromViteUserConfig(config) {
128
129
  outDir = normalizeOutDir(outDir);
129
130
  return outDir;
130
131
  }
131
- function getOutDirFromResolvedConfig(config) {
132
- let outDir = config.build.outDir;
132
+ function getOutDirFromResolvedConfig(config, viteEnv) {
133
+ let outDir = viteEnv?.config.build?.outDir ?? config.build.outDir;
133
134
  assert(outDir);
134
135
  outDir = normalizeOutDir(outDir);
135
136
  return outDir;
@@ -9,8 +9,8 @@ type ViteEnv = {
9
9
  name?: string;
10
10
  config: EnvironmentOptions | Environment['config'];
11
11
  };
12
- declare function isViteServerSide_withoutEnv(configGlobal: ResolvedConfig | UserConfig, viteEnv?: ViteEnv): boolean;
13
12
  declare function isViteServerSide(configGlobal: ResolvedConfig | UserConfig, viteEnv: ViteEnv): boolean;
13
+ declare function isViteServerSide_withoutEnv(configGlobal: ResolvedConfig | UserConfig, viteEnv?: ViteEnv | undefined): boolean;
14
14
  declare function isViteClientSide(configGlobal: ResolvedConfig, viteEnv: ViteEnv): boolean;
15
15
  declare function isViteServerSide_onlySsrEnv(configGlobal: ResolvedConfig, viteEnv: ViteEnv): boolean;
16
16
  declare function isViteServerSide_extraSafe(config: ResolvedConfig, options: {
@@ -4,16 +4,16 @@ export { isViteServerSide_withoutEnv };
4
4
  export { isViteServerSide_onlySsrEnv };
5
5
  export { isViteServerSide_extraSafe };
6
6
  import { assert } from '../../../utils/assert.js';
7
- function isViteServerSide_withoutEnv(configGlobal, viteEnv) {
7
+ function isViteServerSide_impl(configGlobal, viteEnv) {
8
8
  assert(!('consumer' in configGlobal)); // make sure configGlobal isn't viteEnv.config
9
9
  const isServerSide1 = !viteEnv?.config.consumer ? null : viteEnv.config.consumer !== 'client';
10
- const isServerSide2 = !viteEnv?.name ? null : viteEnv.name !== 'client'; // I can't think of a use case for creating another client-side environment
11
- const isServerSide3 = !viteEnv ? null : !!viteEnv.config.build?.ssr;
12
- const isServerSide4 = !!configGlobal.build?.ssr;
10
+ const isServerSide2 = !viteEnv?.config.build ? null : getBuildSsrValue(viteEnv.config.build.ssr);
11
+ const isServerSide3 = !configGlobal.build ? null : getBuildSsrValue(configGlobal.build.ssr);
12
+ const isServerSide4 = viteEnv?.name === 'ssr' ? true : viteEnv?.name === 'client' ? false : null;
13
13
  const debug = {
14
- envIsUndefined: !viteEnv,
15
- envName: viteEnv?.name ?? null,
16
- envConsumer: viteEnv?.config.consumer ?? null,
14
+ viteEnvIsUndefined: !viteEnv,
15
+ viteEnvName: viteEnv?.name ?? null,
16
+ viteEnvConsumer: viteEnv?.config.consumer ?? null,
17
17
  configEnvBuildSsr: viteEnv?.config.build?.ssr ?? null,
18
18
  configGlobalBuildSsr: configGlobal.build?.ssr ?? null,
19
19
  isServerSide1,
@@ -22,25 +22,36 @@ function isViteServerSide_withoutEnv(configGlobal, viteEnv) {
22
22
  isServerSide4,
23
23
  };
24
24
  if (isServerSide1 !== null) {
25
- assert(isServerSide1 === isServerSide2 || isServerSide2 === null, debug);
25
+ // assert(isServerSide1 === isServerSide4 || isServerSide4 === null, debug)
26
26
  /* This assertion can fail, seems to be a Vite bug?
27
- assert(isServerSide1 === isServerSide3, debug)
27
+ assert(isServerSide1 === isServerSide2, debug)
28
28
  */
29
29
  return isServerSide1;
30
30
  }
31
31
  if (isServerSide2 !== null) {
32
- /* This assertion can fail, seems to be a Vite bug?
33
- assert(isServerSide2 === isServerSide3, debug)
34
- */
32
+ // assert(isServerSide2 === isServerSide4 || isServerSide4 === null, debug)
35
33
  return isServerSide2;
36
34
  }
37
35
  if (isServerSide3 !== null) {
36
+ // assert(isServerSide3 === isServerSide4 || isServerSide4 === null, debug)
38
37
  return isServerSide3;
39
38
  }
40
- return isServerSide4;
39
+ if (isServerSide4 !== null) {
40
+ return isServerSide4;
41
+ }
42
+ assert(!viteEnv);
43
+ return !!configGlobal.build?.ssr;
44
+ }
45
+ function getBuildSsrValue(buildSsr) {
46
+ if (buildSsr === undefined)
47
+ return null;
48
+ return !!buildSsr;
41
49
  }
42
50
  function isViteServerSide(configGlobal, viteEnv) {
43
- return isViteServerSide_withoutEnv(configGlobal, viteEnv);
51
+ return isViteServerSide_impl(configGlobal, viteEnv);
52
+ }
53
+ function isViteServerSide_withoutEnv(configGlobal, viteEnv) {
54
+ return isViteServerSide_impl(configGlobal, viteEnv);
44
55
  }
45
56
  function isViteClientSide(configGlobal, viteEnv) {
46
57
  return !isViteServerSide(configGlobal, viteEnv);
@@ -51,20 +62,36 @@ function isViteServerSide_onlySsrEnv(configGlobal, viteEnv) {
51
62
  }
52
63
  // 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.
53
64
  function isViteServerSide_extraSafe(config, options, viteEnv) {
65
+ const isServerSide = isViteServerSide(config, viteEnv);
66
+ const debug = {
67
+ configCommand: config.command,
68
+ configBuildSsr: config.build.ssr,
69
+ optionsIsUndefined: options === undefined,
70
+ optionsSsr: options?.ssr,
71
+ isServerSide,
72
+ };
73
+ if (true) {
74
+ const res = options?.ssr;
75
+ if (typeof res === 'boolean') {
76
+ assert(res === isServerSide, debug);
77
+ return res;
78
+ }
79
+ return isServerSide;
80
+ }
54
81
  if (config.command === 'build') {
55
82
  const res = config.build.ssr;
56
- assert(typeof res === 'boolean');
57
- assert(res === options?.ssr || options?.ssr === undefined);
58
- assert(res === isViteServerSide(config, viteEnv));
83
+ assert(typeof res === 'boolean', debug);
84
+ assert(res === options?.ssr || options?.ssr === undefined, debug);
85
+ assert(res === isServerSide, debug);
59
86
  return res;
60
87
  }
61
88
  else {
62
89
  const res = options?.ssr;
63
- assert(typeof res === 'boolean');
90
+ assert(typeof res === 'boolean', debug);
64
91
  /* This assertion can fail, seems to be a Vite bug? It's very unexpected.
65
92
  if (typeof config.build.ssr === 'boolean') assert(res === config.build.ssr)
66
93
  */
67
- assert(res === isViteServerSide(config, viteEnv));
94
+ assert(res === isServerSide, debug);
68
95
  return res;
69
96
  }
70
97
  }
@@ -4,9 +4,10 @@ export type { ConfigDefinitions };
4
4
  export type { ConfigDefinitionsInternal };
5
5
  export type { ConfigDefinitionInternal };
6
6
  export type { ConfigEffect };
7
- import type { ConfigEnvInternal, ConfigEnv, DefinedAtFilePath, PageConfigBuildTime } from '../../../../types/PageConfig.js';
7
+ import type { ConfigEnvInternal, ConfigEnv, DefinedAtFilePath } from '../../../../types/PageConfig.js';
8
8
  import type { Config, ConfigNameBuiltIn, ConfigNameGlobal } from '../../../../types/Config.js';
9
9
  import { type ConfigDefinedAt } from '../../../../shared/page-configs/getConfigDefinedAt.js';
10
+ import type { PageConfigBuildTimeBeforeComputed } from '../resolveVikeConfigInternal.js';
10
11
  /** The meta definition of a config.
11
12
  *
12
13
  * https://vike.dev/meta
@@ -75,7 +76,7 @@ type ConfigEffect = (config: {
75
76
  }) => Config | undefined;
76
77
  /** For Vike internal use */
77
78
  type ConfigDefinitionInternal = Omit<ConfigDefinition_, 'env'> & {
78
- _computed?: (pageConfig: Omit<PageConfigBuildTime, 'configValuesComputed'>) => unknown;
79
+ _computed?: (pageConfig: PageConfigBuildTimeBeforeComputed) => unknown;
79
80
  _valueIsFilePath?: true;
80
81
  _userEffectDefinedAtFilePath?: DefinedAtFilePath;
81
82
  env: ConfigEnvInternal;
@@ -1,7 +1,7 @@
1
1
  export { configDefinitionsBuiltIn };
2
2
  import { assert, assertUsage } from '../../utils.js';
3
3
  import { getConfigDefinedAt } from '../../../../shared/page-configs/getConfigDefinedAt.js';
4
- import { getConfigValueSourcesRelevant } from '../../plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js';
4
+ import { getConfigValueSourceRelevantAnyEnv, getConfigValueSourcesRelevant, isConfigSourceValueNull, } from '../../plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js';
5
5
  const configDefinitionsBuiltIn = {
6
6
  onRenderHtml: {
7
7
  env: { server: true },
@@ -108,7 +108,9 @@ const configDefinitionsBuiltIn = {
108
108
  }, pageConfig))
109
109
  .flat(1)
110
110
  // Server-only
111
- .filter((source) => !source.configEnv.client);
111
+ .filter((source) => !source.configEnv.client)
112
+ // Config value isn't `null`
113
+ .filter((source) => !isConfigSourceValueNull(source));
112
114
  return sources.length > 0;
113
115
  },
114
116
  },
@@ -120,22 +122,19 @@ const configDefinitionsBuiltIn = {
120
122
  env: { server: true, client: true },
121
123
  eager: true,
122
124
  _computed: (pageConfig) => {
123
- const { configValueSources } = pageConfig;
124
125
  {
125
- const source = getConfigValueSource(configValueSources, 'clientHooks');
126
+ const source = getConfigValueSourceRelevantAnyEnv('clientHooks', pageConfig);
126
127
  if (source) {
127
128
  assert(source.valueIsLoaded);
128
- if (source.value !== null) {
129
- const { value } = source;
130
- const definedAt = getConfigDefinedAt('Config', 'clientHooks', source.definedAt);
131
- assertUsage(typeof value === 'boolean', `${definedAt} should be a boolean`);
132
- return value;
133
- }
129
+ const { value, definedAt } = source;
130
+ const configDefinedAt = getConfigDefinedAt('Config', 'clientHooks', definedAt);
131
+ assertUsage(typeof value === 'boolean', `${configDefinedAt} should be a boolean`);
132
+ return value;
134
133
  }
135
134
  }
136
- return (isConfigSet(configValueSources, 'onRenderClient') &&
137
- isConfigSet(configValueSources, 'Page') &&
138
- !!getConfigEnv(configValueSources, 'Page')?.client);
135
+ return (isConfigSet(pageConfig, 'onRenderClient') &&
136
+ isConfigSet(pageConfig, 'Page') &&
137
+ !!getConfigEnv(pageConfig, 'Page')?.client);
139
138
  },
140
139
  },
141
140
  // TO-DO/soon/cumulative-hooks: remove and replace with new computed prop `clientOnlyHooks: string[]` (see other TO-DO/soon/cumulative-hooks entries)
@@ -143,10 +142,7 @@ const configDefinitionsBuiltIn = {
143
142
  env: { client: true },
144
143
  eager: true,
145
144
  _computed: (pageConfig) => {
146
- const { configValueSources } = pageConfig;
147
- return !isConfigSet(configValueSources, 'onBeforeRender')
148
- ? null
149
- : getConfigEnv(configValueSources, 'onBeforeRender');
145
+ return !isConfigSet(pageConfig, 'onBeforeRender') ? null : getConfigEnv(pageConfig, 'onBeforeRender');
150
146
  },
151
147
  },
152
148
  // TO-DO/soon/cumulative-hooks: remove and replace with new computed prop `clientOnlyHooks: string[]` (see other TO-DO/soon/cumulative-hooks entries)
@@ -154,8 +150,7 @@ const configDefinitionsBuiltIn = {
154
150
  env: { client: true },
155
151
  eager: true,
156
152
  _computed: (pageConfig) => {
157
- const { configValueSources } = pageConfig;
158
- return !isConfigSet(configValueSources, 'data') ? null : getConfigEnv(configValueSources, 'data');
153
+ return !isConfigSet(pageConfig, 'data') ? null : getConfigEnv(pageConfig, 'data');
159
154
  },
160
155
  },
161
156
  hooksTimeout: {
@@ -243,11 +238,11 @@ const configDefinitionsBuiltIn = {
243
238
  cumulative: true,
244
239
  },
245
240
  };
246
- function getConfigEnv(configValueSources, configName) {
247
- const configValueSource = getConfigValueSource(configValueSources, configName);
248
- if (!configValueSource)
241
+ function getConfigEnv(pageConfig, configName) {
242
+ const source = getConfigValueSourceRelevantAnyEnv(configName, pageConfig);
243
+ if (!source)
249
244
  return null;
250
- const { configEnv } = configValueSource;
245
+ const { configEnv } = source;
251
246
  const env = {};
252
247
  if (configEnv.client)
253
248
  env.client = true;
@@ -255,18 +250,7 @@ function getConfigEnv(configValueSources, configName) {
255
250
  env.server = true;
256
251
  return env;
257
252
  }
258
- function isConfigSet(configValueSources, configName) {
259
- const source = getConfigValueSource(configValueSources, configName);
260
- return (!!source &&
261
- !(source.valueIsLoaded &&
262
- // Enable users to suppress inherited config by overriding it with `null`
263
- source.value === null));
264
- }
265
- function getConfigValueSource(configValueSources, configName) {
266
- const sources = configValueSources[configName];
267
- if (!sources)
268
- return null;
269
- const configValueSource = sources[0];
270
- assert(configValueSource);
271
- return configValueSource;
253
+ function isConfigSet(pageConfig, configName) {
254
+ const source = getConfigValueSourceRelevantAnyEnv(configName, pageConfig);
255
+ return !!source;
272
256
  }
@@ -8,6 +8,7 @@ export { getConfVal };
8
8
  export { getConfigDefinitionOptional };
9
9
  export { getVikeConfigFromCliOrEnv };
10
10
  export type { VikeConfigInternal };
11
+ export type { PageConfigBuildTimeBeforeComputed };
11
12
  export { getVikeConfig };
12
13
  export type { VikeConfig };
13
14
  import type { PageConfigGlobalBuildTime, PageConfigBuildTime } from '../../../types/PageConfig.js';
@@ -57,6 +58,7 @@ declare function getVikeConfigFromCliOrEnv(): {
57
58
  configFromCliOptions: import("../../cli/parseCli.js").CliOptions | null;
58
59
  configFromEnvVar: Record<string, unknown> | null;
59
60
  };
61
+ type PageConfigBuildTimeBeforeComputed = Omit<PageConfigBuildTime, 'configValuesComputed'>;
60
62
  declare function getConfigDefinitionOptional(configDefinitions: ConfigDefinitionsInternal, configName: string): ConfigDefinitionInternal | null;
61
63
  declare function getConfVal(plusFile: PlusFile, configName: string): null | {
62
64
  value: unknown;
@@ -0,0 +1,3 @@
1
+ export { loadAndParseVirtualFilePageEntry };
2
+ import type { PageConfigRuntime, PageConfigRuntimeLoaded } from '../../types/PageConfig.js';
3
+ declare function loadAndParseVirtualFilePageEntry(pageConfig: PageConfigRuntime, isDev: boolean): Promise<PageConfigRuntimeLoaded>;
@@ -1,7 +1,7 @@
1
- export { loadPageEntry };
1
+ export { loadAndParseVirtualFilePageEntry };
2
2
  import { assert, objectAssign } from '../utils.js';
3
3
  import { parseConfigValuesSerialized } from './serialize/parsePageConfigsSerialized.js';
4
- async function loadPageEntry(pageConfig, isDev) {
4
+ async function loadAndParseVirtualFilePageEntry(pageConfig, isDev) {
5
5
  if ('isPageEntryLoaded' in pageConfig &&
6
6
  // We don't need to cache in dev, since Vite already caches the virtual module
7
7
  !isDev) {
@@ -1,3 +1,8 @@
1
+ // TO-DO/soon: rename PageConfig names
2
+ // - Use `Internal` suffix, i.e. {Page,Global}ConfigInternal
3
+ // - While keeping {Page,Global}ConfigPublic or remove Public suffix and rename it to {Page,Global}Config ?
4
+ // - rename EagerLoaded EagerlyLoaded
5
+ // - remove `LazyLoaded` suffix
1
6
  // TO-DO/soon/same-api: use public API internally?
2
7
  // TO-DO/soon/flat-pageContext: rename definedAt => definedBy
3
8
  export { resolveVikeConfigPublicGlobal };
@@ -1,7 +1,7 @@
1
1
  export { execHookOnBeforeRoute };
2
- import type { PageContextForRoute, PageContextFromRoute } from './index.js';
3
- declare function execHookOnBeforeRoute(pageContext: PageContextForRoute): Promise<null | ({
2
+ import type { PageContextBeforeRoute, PageContextAfterRoute } from './index.js';
3
+ declare function execHookOnBeforeRoute(pageContext: PageContextBeforeRoute): Promise<null | ({
4
4
  _routingProvidedByOnBeforeRouteHook: true;
5
- } & PageContextFromRoute) | {
5
+ } & PageContextAfterRoute) | {
6
6
  _routingProvidedByOnBeforeRouteHook: false;
7
7
  }>;
@@ -23,7 +23,6 @@ async function execHookOnBeforeRoute(pageContext) {
23
23
  }
24
24
  objectAssign(pageContextFromOnBeforeRouteHook, {
25
25
  _routingProvidedByOnBeforeRouteHook: true,
26
- _debugRouteMatches: 'CUSTOM_ROUTING',
27
26
  });
28
27
  return pageContextFromOnBeforeRouteHook;
29
28
  }
@@ -1,19 +1,18 @@
1
1
  export { route };
2
- export type { PageContextForRoute };
3
- export type { PageContextFromRoute };
2
+ export type { PageContextBeforeRoute };
3
+ export type { PageContextAfterRoute };
4
4
  export type { PageRoutes };
5
5
  export type { RouteMatches };
6
6
  import { type PageContextUrlInternal, type PageContextUrlSource } from '../getPageContextUrlComputed.js';
7
7
  import type { PageRoutes, RouteType } from './loadPageRoutes.js';
8
8
  import type { GlobalContextInternal } from '../createGlobalContextShared.js';
9
- type PageContextForRoute = PageContextUrlInternal & {
9
+ type PageContextBeforeRoute = PageContextUrlInternal & {
10
10
  _globalContext: GlobalContextInternal;
11
11
  } & PageContextUrlSource;
12
- type PageContextFromRoute = {
12
+ type PageContextAfterRoute = {
13
13
  pageId: string | null;
14
14
  routeParams: Record<string, string>;
15
15
  _routingProvidedByOnBeforeRouteHook?: boolean;
16
- _debugRouteMatches: RouteMatches;
17
16
  };
18
17
  type RouteMatch = {
19
18
  pageId: string;
@@ -23,4 +22,4 @@ type RouteMatch = {
23
22
  routeParams: Record<string, string>;
24
23
  };
25
24
  type RouteMatches = 'CUSTOM_ROUTING' | RouteMatch[];
26
- declare function route(pageContext: PageContextForRoute, skipOnBeforeRouteHook?: true): Promise<PageContextFromRoute>;
25
+ declare function route(pageContext: PageContextBeforeRoute, skipOnBeforeRouteHook?: true): Promise<PageContextAfterRoute>;
@@ -81,7 +81,6 @@ async function route(pageContext, skipOnBeforeRouteHook) {
81
81
  resolvePrecedence(routeMatches);
82
82
  const winner = routeMatches[0] ?? null;
83
83
  debug(`Route matches for URL ${pc.cyan(urlPathname)} (in precedence order):`, routeMatches);
84
- objectAssign(pageContextFromRoute, { _debugRouteMatches: routeMatches });
85
84
  // For vite-plugin-vercel https://github.com/magne4000/vite-plugin-vercel/blob/main/packages/vike-integration/vike.ts#L173
86
85
  objectAssign(pageContextFromRoute, { _routeMatch: winner });
87
86
  if (!winner) {
@@ -404,11 +404,9 @@ type ConfigBuiltIn = {
404
404
  /** @deprecated See https://vike.dev/disableAutoFullBuild */
405
405
  disableAutoFullBuild?: boolean | 'prerender';
406
406
  /**
407
- * Use builder.buildApp() to orchestrate the build process.
408
- *
409
- * @experimental
407
+ * @deprecated It's value is now always true.
410
408
  */
411
- vite6BuilderApp?: boolean;
409
+ vite6BuilderApp?: true;
412
410
  /** The Base URL of your server.
413
411
  *
414
412
  * https://vike.dev/base-url
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.237-commit-e549c30";
1
+ export declare const PROJECT_VERSION: "0.4.237-commit-fd8294f";
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.237-commit-e549c30';
2
+ export const PROJECT_VERSION = '0.4.237-commit-fd8294f';
@@ -0,0 +1,3 @@
1
+ export { updateType };
2
+ /** Help TypeScript update the type of dynamically modified objects. */
3
+ declare function updateType<Thing, Clone>(thing: Thing, clone: Clone): asserts thing is Thing & Clone;
@@ -0,0 +1,7 @@
1
+ export { updateType };
2
+ import { assert } from './assert.js';
3
+ /** Help TypeScript update the type of dynamically modified objects. */
4
+ function updateType(thing, clone) {
5
+ // @ts-ignore
6
+ assert(thing === clone);
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.237-commit-e549c30",
3
+ "version": "0.4.237-commit-fd8294f",
4
4
  "repository": "https://github.com/vikejs/vike",
5
5
  "exports": {
6
6
  "./server": {
@@ -129,10 +129,10 @@
129
129
  },
130
130
  "dependencies": {
131
131
  "@brillout/import": "^0.2.6",
132
- "@brillout/json-serializer": "^0.5.17",
132
+ "@brillout/json-serializer": "^0.5.20",
133
133
  "@brillout/picocolors": "^1.0.26",
134
134
  "@brillout/require-shim": "^0.1.2",
135
- "@brillout/vite-plugin-server-entry": "^0.7.12",
135
+ "@brillout/vite-plugin-server-entry": "^0.7.13",
136
136
  "acorn": "^8.0.0",
137
137
  "cac": "^6.0.0",
138
138
  "es-module-lexer": "^1.0.0",
@@ -263,7 +263,7 @@
263
263
  "react-streaming": "^0.4.3",
264
264
  "rimraf": "^5.0.5",
265
265
  "typescript": "^5.8.3",
266
- "vite": "^7.0.6"
266
+ "vite": "^7.1.3"
267
267
  },
268
268
  "scripts": {
269
269
  "dev": "tsc --watch",
@@ -1,52 +0,0 @@
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.debugPageFiles = debugPageFiles;
7
- const picocolors_1 = __importDefault(require("@brillout/picocolors"));
8
- const utils_js_1 = require("../utils.js");
9
- function debugPageFiles({ pageContext, isHtmlOnly, isClientRouting, pageFilesLoaded, pageFilesServerSide, pageFilesClientSide, clientEntries, clientDependencies, }) {
10
- const debug = (0, utils_js_1.createDebugger)('vike:pageFiles', { serialization: { emptyArray: 'None' } });
11
- const padding = ' - ';
12
- debug('All page files:', printPageFiles(pageContext._globalContext._pageFilesAll, true));
13
- debug(`URL:`, pageContext.urlOriginal);
14
- debug.options({ serialization: { emptyArray: 'No match' } })(`Routing:`, printRouteMatches(pageContext._debugRouteMatches));
15
- debug(`pageId:`, pageContext.pageId);
16
- debug('Page type:', isHtmlOnly ? 'HTML-only' : 'SSR/SPA');
17
- debug(`Routing type:`, !isHtmlOnly && isClientRouting ? 'Client Routing' : 'Server Routing');
18
- debug('Server-side page files:', printPageFiles(pageFilesLoaded));
19
- (0, utils_js_1.assert)(samePageFiles(pageFilesLoaded, pageFilesServerSide));
20
- debug('Client-side page files:', printPageFiles(pageFilesClientSide));
21
- debug('Client-side entries:', clientEntries);
22
- debug('Client-side dependencies:', clientDependencies);
23
- return;
24
- function printRouteMatches(debugRouteMatches) {
25
- if (debugRouteMatches === 'ROUTING_ERROR') {
26
- return 'Routing Failed';
27
- }
28
- if (debugRouteMatches === 'CUSTOM_ROUTING') {
29
- return 'Custom Routing';
30
- }
31
- return debugRouteMatches;
32
- }
33
- function printPageFiles(pageFiles, genericPageFilesLast = false) {
34
- if (pageFiles.length === 0) {
35
- return 'None';
36
- }
37
- return ('\n' +
38
- pageFiles
39
- .sort((p1, p2) => p1.filePath.localeCompare(p2.filePath))
40
- .sort((0, utils_js_1.makeFirst)((p) => (p.isRendererPageFile ? !genericPageFilesLast : null)))
41
- .sort((0, utils_js_1.makeFirst)((p) => (p.isDefaultPageFile ? !genericPageFilesLast : null)))
42
- .map((p) => p.filePath)
43
- .map((s) => s.split('_default.page.').join(`${picocolors_1.default.blue('_default')}.page.`))
44
- .map((s) => s.split('/renderer/').join(`/${picocolors_1.default.red('renderer')}/`))
45
- .map((s) => padding + s)
46
- .join('\n'));
47
- }
48
- }
49
- function samePageFiles(pageFiles1, pageFiles2) {
50
- return (pageFiles1.every((p1) => pageFiles2.some((p2) => p2.filePath === p1.filePath)) &&
51
- pageFiles2.every((p2) => pageFiles1.some((p1) => p1.filePath === p2.filePath)));
52
- }
@@ -1,23 +0,0 @@
1
- export { debugPageFiles };
2
- export type { PageContextDebugRouteMatches };
3
- import type { RouteMatches } from '../../../shared/route/index.js';
4
- import type { ClientDependency } from '../../../shared/getPageFiles/analyzePageClientSide/ClientDependency.js';
5
- import type { PageFile } from '../../../shared/getPageFiles.js';
6
- import type { GlobalContextServerInternal } from '../globalContext.js';
7
- type PageContextDebugRouteMatches = {
8
- _debugRouteMatches: 'ROUTING_ERROR' | RouteMatches;
9
- };
10
- declare function debugPageFiles({ pageContext, isHtmlOnly, isClientRouting, pageFilesLoaded, pageFilesServerSide, pageFilesClientSide, clientEntries, clientDependencies, }: {
11
- pageContext: {
12
- urlOriginal: string;
13
- pageId: string;
14
- _globalContext: GlobalContextServerInternal;
15
- } & PageContextDebugRouteMatches;
16
- isHtmlOnly: boolean;
17
- isClientRouting: boolean;
18
- pageFilesLoaded: PageFile[];
19
- pageFilesClientSide: PageFile[];
20
- pageFilesServerSide: PageFile[];
21
- clientEntries: string[];
22
- clientDependencies: ClientDependency[];
23
- }): void;