vike 0.4.258 → 0.4.259-commit-146b243

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.
@@ -649,7 +649,7 @@ async function loadPageConfigsLazyClientSideAndExecHook(pageContext, isFirstRend
649
649
  await execHook('onCreatePageContext', pageContext, getPageContextPublicClient);
650
650
  }
651
651
  catch (err_) {
652
- err = err;
652
+ err = err_;
653
653
  hasErr = true;
654
654
  }
655
655
  if (isRenderOutdated())
@@ -11,6 +11,7 @@ import crypto from 'node:crypto';
11
11
  import { getAssetsDir } from '../../shared/getAssetsDir.js';
12
12
  import { assertModuleId, getFilePathToShowToUserModule } from '../../shared/getFilePath.js';
13
13
  import '../../assertEnvVite.js';
14
+ import { isVersionMatch } from '../../../../utils/assertVersion.js';
14
15
  function pluginDistFileNames() {
15
16
  return [
16
17
  {
@@ -41,65 +42,8 @@ function pluginDistFileNames() {
41
42
  // - If rollupOutput.assetFileNames is a function then use a wrapper function to apply the assertUsage()
42
43
  assertUsage(rollupOutput.assetFileNames.isTheOneSetByVike, "Setting Vite's configuration build.rollupOptions.output.assetFileNames is currently forbidden. Reach out if you need to use it.");
43
44
  }
44
- {
45
- const manualChunksOriginal = rollupOutput.manualChunks;
46
- rollupOutput.manualChunks = function (id, ...args) {
47
- if (manualChunksOriginal) {
48
- if (isCallable(manualChunksOriginal)) {
49
- const result = manualChunksOriginal.call(this, id, ...args);
50
- if (result !== undefined)
51
- return result;
52
- }
53
- else {
54
- assertUsage(false, "The Vite's configuration build.rollupOptions.output.manualChunks must be a function. Reach out if you need to set it to another value.");
55
- }
56
- }
57
- // Disable CSS bundling to workaround https://github.com/vikejs/vike/issues/1815
58
- // TO-DO/eventually: let's bundle CSS again once Rolldown replaces Rollup
59
- if (id.endsWith('.css')) {
60
- const userRootDir = config.root;
61
- if (id.startsWith(userRootDir)) {
62
- assertPosixPath(id);
63
- assertModuleId(id);
64
- let name;
65
- const isNodeModules = id.match(/node_modules\/([^\/]+)\/(?!.*node_modules)/);
66
- if (isNodeModules) {
67
- name = isNodeModules[1];
68
- }
69
- else {
70
- const filePath = getFilePathToShowToUserModule(id, config);
71
- name = filePath;
72
- name = name.split('.').slice(0, -1).join('.'); // remove file extension
73
- name = name.split('/').filter(Boolean).join('_');
74
- }
75
- // Make fileHash the same between local development and CI
76
- const idStable = path.posix.relative(userRootDir, id);
77
- // Don't remove `?` queries because each `id` should belong to a unique bundle.
78
- const hash = getIdHash(idStable);
79
- return `${name}-${hash}`;
80
- }
81
- else {
82
- let name;
83
- const isVirtualModule = id.match(/virtual:([^:]+):/);
84
- if (isVirtualModule) {
85
- name = isVirtualModule[1];
86
- assert(name);
87
- }
88
- else if (
89
- // https://github.com/vikejs/vike/issues/1818#issuecomment-2298478321
90
- id.startsWith('/__uno')) {
91
- name = 'uno';
92
- }
93
- else {
94
- name = 'style';
95
- }
96
- const hash = getIdHash(id);
97
- return `${name}-${hash}`;
98
- }
99
- }
100
- };
101
- }
102
45
  });
46
+ disableCSSBundling(config);
103
47
  },
104
48
  },
105
49
  },
@@ -243,6 +187,115 @@ function workaroundGlob(name) {
243
187
  name = name.replace(/\.page$/, '-page');
244
188
  return name;
245
189
  }
190
+ // Workaround for Vite CSS duplication bug: https://github.com/vikejs/vike/issues/1815
191
+ function disableCSSBundling(config) {
192
+ if (isVite8OrAbove(config)) {
193
+ for (const output of getRolldownOutputs(config)) {
194
+ assert(output);
195
+ const { codeSplitting } = output;
196
+ // `codeSplitting: false` => single-bundle mode; respect the user's choice.
197
+ if (codeSplitting === false)
198
+ continue;
199
+ // `codeSplitting` set as an object => Rolldown ignores `manualChunks`, so inject a group into `codeSplitting.groups` instead.
200
+ if (codeSplitting && typeof codeSplitting === 'object') {
201
+ if (codeSplittingHasWorkaround.has(codeSplitting))
202
+ continue;
203
+ codeSplittingHasWorkaround.add(codeSplitting);
204
+ codeSplitting.groups ?? (codeSplitting.groups = []);
205
+ codeSplitting.groups.push({
206
+ test: /\.css$/,
207
+ name: (moduleId) => getCssChunkName(moduleId, config) ?? null,
208
+ /*
209
+ // Default priority — user-defined groups with the same priority appear earlier in the array and win the match.
210
+ // https://rolldown.rs/options/output-advanced-chunks
211
+ priority: 0
212
+ */
213
+ });
214
+ continue;
215
+ }
216
+ // `codeSplitting` unset / `true` => wrap `manualChunks` (Rolldown auto-converts it to a group).
217
+ // - Rolldown supports `manualChunks` whenever `codeSplitting` isn't an object (despite what the migration guide implies).
218
+ wrapManualChunks(output, config, 'rolldownOptions');
219
+ }
220
+ }
221
+ else {
222
+ for (const output of getRollupOutputs(config)) {
223
+ assert(output);
224
+ wrapManualChunks(output, config, 'rollupOptions');
225
+ }
226
+ }
227
+ }
228
+ const codeSplittingHasWorkaround = new WeakSet();
229
+ function wrapManualChunks(output, config, optsName) {
230
+ const manualChunksOriginal = output.manualChunks;
231
+ // Sometimes applied twice => skip if we already wrapped — same rationale as `isTheOneSetByVike` for assetFileNames above.
232
+ if (manualChunksOriginal?.isTheOneSetByVike)
233
+ return;
234
+ output.manualChunks = function (id, ...args) {
235
+ if (manualChunksOriginal) {
236
+ if (isCallable(manualChunksOriginal)) {
237
+ const result = manualChunksOriginal.call(this, id,
238
+ // @ts-ignore
239
+ ...args);
240
+ if (result !== undefined)
241
+ return result;
242
+ }
243
+ else {
244
+ assertUsage(false, `The Vite's configuration build.${optsName}.output.manualChunks must be a function. Reach out if you need to set it to another value.`);
245
+ }
246
+ }
247
+ return getCssChunkName(id, config);
248
+ };
249
+ output.manualChunks.isTheOneSetByVike = true;
250
+ }
251
+ function getCssChunkName(id, config) {
252
+ if (!id.endsWith('.css'))
253
+ return undefined;
254
+ const userRootDir = config.root;
255
+ if (id.startsWith(userRootDir)) {
256
+ assertPosixPath(id);
257
+ assertModuleId(id);
258
+ let name;
259
+ const isNodeModules = id.match(/node_modules\/([^\/]+)\/(?!.*node_modules)/);
260
+ if (isNodeModules) {
261
+ name = isNodeModules[1];
262
+ }
263
+ else {
264
+ const filePath = getFilePathToShowToUserModule(id, config);
265
+ name = filePath;
266
+ name = name.split('.').slice(0, -1).join('.'); // remove file extension
267
+ name = name.split('/').filter(Boolean).join('_');
268
+ }
269
+ // Make fileHash the same between local development and CI
270
+ const idStable = path.posix.relative(userRootDir, id);
271
+ // Don't remove `?` queries because each `id` should belong to a unique bundle.
272
+ const hash = getIdHash(idStable);
273
+ return `${name}-${hash}`;
274
+ }
275
+ else {
276
+ let name;
277
+ const isVirtualModule = id.match(/virtual:([^:]+):/);
278
+ if (isVirtualModule) {
279
+ name = isVirtualModule[1];
280
+ assert(name);
281
+ }
282
+ else if (
283
+ // https://github.com/vikejs/vike/issues/1818#issuecomment-2298478321
284
+ id.startsWith('/__uno')) {
285
+ name = 'uno';
286
+ }
287
+ else {
288
+ name = 'style';
289
+ }
290
+ const hash = getIdHash(id);
291
+ return `${name}-${hash}`;
292
+ }
293
+ }
294
+ function isVite8OrAbove(config) {
295
+ const viteVersion = config._viteVersionResolved;
296
+ assert(viteVersion);
297
+ return isVersionMatch(viteVersion, ['8.0.0']);
298
+ }
246
299
  function getRollupOutputs(config) {
247
300
  var _a, _b;
248
301
  // @ts-expect-error is read-only
@@ -255,3 +308,18 @@ function getRollupOutputs(config) {
255
308
  }
256
309
  return output;
257
310
  }
311
+ function getRolldownOutputs(config) {
312
+ var _a, _b;
313
+ // @ts-expect-error is read-only
314
+ config.build ?? (config.build = {});
315
+ // @ts-ignore
316
+ (_a = config.build).rolldownOptions ?? (_a.rolldownOptions = {});
317
+ // @ts-ignore
318
+ (_b = config.build.rolldownOptions).output ?? (_b.output = {});
319
+ // @ts-ignore
320
+ const { output } = config.build.rolldownOptions;
321
+ if (!isArray(output)) {
322
+ return [output];
323
+ }
324
+ return output;
325
+ }
@@ -3,7 +3,7 @@ export { getConfigValueSourceRelevantAnyEnv };
3
3
  export { isRuntimeEnvMatch };
4
4
  export { isConfigSourceValueNull };
5
5
  export type { RuntimeEnv };
6
- import type { ConfigEnvInternal, ConfigValueSource, PageConfigBuildTime, PageConfigGlobalBuildTime } from '../../../../types/PageConfig.js';
6
+ import type { ConfigEnv, ConfigValueSource, PageConfigBuildTime, PageConfigGlobalBuildTime } from '../../../../types/PageConfig.js';
7
7
  import '../../assertEnvVite.js';
8
8
  type RuntimeEnv = {
9
9
  isForClientSide: boolean;
@@ -15,5 +15,5 @@ type RuntimeEnv = {
15
15
  type PageConfigPartial = Pick<PageConfigBuildTime | PageConfigGlobalBuildTime, 'configValueSources' | 'configDefinitions'>;
16
16
  declare function getConfigValueSourcesRelevant(configName: string, runtimeEnv: RuntimeEnv, pageConfig: PageConfigPartial): ConfigValueSource[];
17
17
  declare function getConfigValueSourceRelevantAnyEnv(configName: string, pageConfig: PageConfigPartial): null | ConfigValueSource;
18
- declare function isRuntimeEnvMatch(configEnv: ConfigEnvInternal, runtimeEnv: RuntimeEnv): boolean;
18
+ declare function isRuntimeEnvMatch(configEnv: ConfigEnv, runtimeEnv: RuntimeEnv): boolean;
19
19
  declare function isConfigSourceValueNull(source: ConfigValueSource): boolean | null;
@@ -29,6 +29,7 @@ import { getBetterError } from '../../../utils/getBetterError.js';
29
29
  import { getRequestId_withAsyncHook } from '../../../server/runtime/asyncHook.js';
30
30
  import { getRequestTag } from '../../../server/runtime/renderPageServer.js';
31
31
  import '../assertEnvVite.js';
32
+ import { isDeno } from '../../../utils/isDeno.js';
32
33
  assertIsNotProductionRuntime();
33
34
  setLogRuntimeDev(logErrorServerDev, logRuntimeInfoDev);
34
35
  setAssertOnBeforeErr((err) => {
@@ -138,7 +139,9 @@ function logDev(msg, logType, tagSource, tagTool, doNotAddTags) {
138
139
  }
139
140
  function getTagSource(requestId = null) {
140
141
  const requestIdFromStore = getRequestId_withAsyncHook();
141
- if (requestIdFromStore !== null) {
142
+ if (requestIdFromStore !== null &&
143
+ // Workaround for Deno bug: https://github.com/vikejs/vike/issues/3240
144
+ !isDeno()) {
142
145
  if (requestId === null) {
143
146
  requestId = requestIdFromStore;
144
147
  }
@@ -4,8 +4,8 @@ export type { ConfigDefinitions };
4
4
  export type { ConfigDefinitionsInternal };
5
5
  export type { ConfigDefinitionInternal };
6
6
  export type { ConfigEffect };
7
- import type { ConfigEnvInternal, ConfigEnv, DefinedAtFilePath } from '../../../../types/PageConfig.js';
8
- import type { Config, ConfigNameBuiltIn, ConfigNameGlobal } from '../../../../types/Config.js';
7
+ import type { ConfigEnv, DefinedAtFilePath } from '../../../../types/PageConfig.js';
8
+ import type { Config, ConfigNameBuiltIn, ConfigNameBuiltInGlobal } from '../../../../types/Config.js';
9
9
  import { type ConfigDefinedAt } from '../../../../shared-server-client/page-configs/getConfigDefinedAt.js';
10
10
  import type { PageConfigBuildTimeBeforeComputed } from '../resolveVikeConfigInternal.js';
11
11
  import '../../assertEnvVite.js';
@@ -13,8 +13,7 @@ import '../../assertEnvVite.js';
13
13
  *
14
14
  * https://vike.dev/meta
15
15
  */
16
- type ConfigDefinition = ConfigDefinition_ | ConfigDefinitionDefinedByPeerDependency;
17
- type ConfigDefinition_ = {
16
+ type ConfigDefinition = {
18
17
  /** In what environment(s) the config value is loaded.
19
18
  *
20
19
  * https://vike.dev/meta
@@ -57,7 +56,14 @@ type ConfigDefinition_ = {
57
56
  }) => boolean);
58
57
  /** Whether changes to the configuration should trigger a Vite restart. */
59
58
  vite?: boolean;
60
- };
59
+ /** @experimental */
60
+ _computed?: (pageConfig: PageConfigBuildTimeBeforeComputed) => unknown;
61
+ /** @experimental */
62
+ _valueIsFilePath?: true;
63
+ /** @experimental */
64
+ _userEffectDefinedAtFilePath?: DefinedAtFilePath;
65
+ isDefinedByPeerDependency?: undefined;
66
+ } | ConfigDefinitionDefinedByPeerDependency;
61
67
  type ConfigDefinitionDefinedByPeerDependency = {
62
68
  /**
63
69
  * Omit the "unknown config" error without defining the config — useful for optional peer dependencies: for example, vike-server sets +stream.require which is defined by vike-{react,vue,solid} but some users don't use vike-{react,vue,solid}
@@ -70,27 +76,21 @@ type ConfigDefinitionDefinedByPeerDependency = {
70
76
  * https://vike.dev/meta
71
77
  */
72
78
  type ConfigEffect = (config: {
73
- /** The config value.
79
+ /** The config's value.
74
80
  *
75
81
  * https://vike.dev/meta
76
82
  */
77
83
  configValue: unknown;
78
- /** Where the config value is defined.
84
+ /** Where the config's value is defined.
79
85
  *
80
86
  * https://vike.dev/meta
81
87
  */
82
88
  configDefinedAt: ConfigDefinedAt;
83
89
  }) => Config | undefined;
84
- /** For Vike internal use */
85
- type ConfigDefinitionInternal = Omit<ConfigDefinition_, 'env'> & {
86
- _computed?: (pageConfig: PageConfigBuildTimeBeforeComputed) => unknown;
87
- _valueIsFilePath?: true;
88
- _userEffectDefinedAtFilePath?: DefinedAtFilePath;
89
- env: ConfigEnvInternal;
90
- };
90
+ type ConfigDefinitionInternal = Exclude<ConfigDefinition, ConfigDefinitionDefinedByPeerDependency>;
91
91
  type ConfigDefinitions = Record<string, // configName
92
92
  ConfigDefinition>;
93
93
  type ConfigDefinitionsInternal = Record<string, // configName
94
94
  ConfigDefinitionInternal>;
95
- type ConfigDefinitionsBuiltIn = Record<ConfigNameBuiltIn | ConfigNameGlobal, ConfigDefinitionInternal>;
95
+ type ConfigDefinitionsBuiltIn = Record<ConfigNameBuiltIn | ConfigNameBuiltInGlobal, ConfigDefinitionInternal>;
96
96
  declare const metaBuiltIn: ConfigDefinitionsBuiltIn;
@@ -11,8 +11,8 @@ export { getConfigDefinitionOptional };
11
11
  export { getVikeConfigFromCliOrEnv };
12
12
  export type { VikeConfigInternal };
13
13
  export type { PageConfigBuildTimeBeforeComputed };
14
- import type { PageConfigGlobalBuildTime, PageConfigBuildTime } from '../../../types/PageConfig.js';
15
- import { type ConfigDefinitionsInternal, type ConfigDefinitionInternal } from './resolveVikeConfigInternal/metaBuiltIn.js';
14
+ import type { PageConfigGlobalBuildTime, ConfigEnv, PageConfigBuildTime, DefinedAtFilePath } from '../../../types/PageConfig.js';
15
+ import { type ConfigDefinitionsInternal } from './resolveVikeConfigInternal/metaBuiltIn.js';
16
16
  import { type GlobalConfigPublic } from '../../../shared-server-client/page-configs/resolveVikeConfigPublic.js';
17
17
  import { type PlusFile } from './resolveVikeConfigInternal/getPlusFilesByLocationId.js';
18
18
  import type { PrerenderContextPublic } from '../../prerender/runPrerender.js';
@@ -63,7 +63,20 @@ declare function getVikeConfigFromCliOrEnv(): {
63
63
  configFromEnvVar: Record<string, unknown> | null;
64
64
  };
65
65
  type PageConfigBuildTimeBeforeComputed = Omit<PageConfigBuildTime, 'configValuesComputed'>;
66
- declare function getConfigDefinitionOptional(configDefinitions: ConfigDefinitionsInternal, configName: string): ConfigDefinitionInternal | null;
66
+ declare function getConfigDefinitionOptional(configDefinitions: ConfigDefinitionsInternal, configName: string): {
67
+ env: ConfigEnv;
68
+ cumulative?: boolean;
69
+ effect?: import("./resolveVikeConfigInternal/metaBuiltIn.js").ConfigEffect;
70
+ eager?: boolean;
71
+ global?: boolean | ((value: unknown, moreInfo: {
72
+ isGlobalLocation: boolean;
73
+ }) => boolean);
74
+ vite?: boolean;
75
+ _computed?: (pageConfig: PageConfigBuildTimeBeforeComputed) => unknown;
76
+ _valueIsFilePath?: true;
77
+ _userEffectDefinedAtFilePath?: DefinedAtFilePath;
78
+ isDefinedByPeerDependency?: undefined;
79
+ } | null;
67
80
  declare function getConfVal(plusFile: PlusFile, configName: string): null | {
68
81
  value: unknown;
69
82
  valueIsLoaded: true;
@@ -254,8 +254,7 @@ async function resolveConfigDefinitions(plusFilesByLocationId, userRootDir, esbu
254
254
  // We use `plusFilesByLocationId` in order to allow non-global Vike extensions to create global configs, and to set the value of global configs such as `+vite` (enabling Vike extensions to add Vite plugins).
255
255
  plusFilesByLocationIdOrdered, (configDef) => !!configDef.global);
256
256
  await loadCustomConfigBuildTimeFiles(plusFilesByLocationId, configDefinitionsGlobal, userRootDir, esbuildCache);
257
- const configDefinitionsAll = getConfigDefinitions(Object.values(plusFilesByLocationId).flat());
258
- const configNamesKnownAll = Object.keys(configDefinitionsAll);
257
+ const configNamesKnownAll = getConfigNames(Object.values(plusFilesByLocationId).flat());
259
258
  const configNamesKnownGlobal = Object.keys(configDefinitionsGlobal);
260
259
  assert(configNamesKnownGlobal.every((configName) => configNamesKnownAll.includes(configName)));
261
260
  const configDefinitionsLocal = {};
@@ -265,9 +264,13 @@ async function resolveConfigDefinitions(plusFilesByLocationId, userRootDir, esbu
265
264
  .map(([, plusFiles]) => plusFiles)
266
265
  .flat()
267
266
  .sort((plusFile1, plusFile2) => sortAfterInheritanceOrderPage(plusFile1, plusFile2, locationIdPage, null));
268
- const configDefinitions = getConfigDefinitions(plusFilesRelevant, (configDef) => configDef.global !== true);
267
+ const { configDefinitions, peerDependencyConfigNames } = collectConfigDefinitions(plusFilesRelevant, (configDef) => configDef.global !== true);
269
268
  await loadCustomConfigBuildTimeFiles(plusFiles, configDefinitions, userRootDir, esbuildCache);
270
- const configNamesKnownLocal = unique([...Object.keys(configDefinitions), ...configNamesKnownGlobal]);
269
+ const configNamesKnownLocal = unique([
270
+ ...Object.keys(configDefinitions),
271
+ ...peerDependencyConfigNames,
272
+ ...configNamesKnownGlobal,
273
+ ]);
271
274
  assert(configNamesKnownLocal.every((configName) => configNamesKnownAll.includes(configName)));
272
275
  configDefinitionsLocal[locationIdPage] = {
273
276
  configDefinitions,
@@ -279,7 +282,6 @@ async function resolveConfigDefinitions(plusFilesByLocationId, userRootDir, esbu
279
282
  const configDefinitionsResolved = {
280
283
  configDefinitionsGlobal,
281
284
  configDefinitionsLocal,
282
- configDefinitionsAll,
283
285
  configNamesKnownAll,
284
286
  configNamesKnownGlobal,
285
287
  };
@@ -772,8 +774,16 @@ function getConfigNamesSetByPlusFile(plusFile) {
772
774
  return Object.keys(plusFile.fileExportsByConfigName);
773
775
  }
774
776
  }
777
+ function getConfigNames(plusFilesRelevant, filter) {
778
+ const { configDefinitions, peerDependencyConfigNames } = collectConfigDefinitions(plusFilesRelevant, filter);
779
+ return [...Object.keys(configDefinitions), ...peerDependencyConfigNames];
780
+ }
775
781
  function getConfigDefinitions(plusFilesRelevant, filter) {
782
+ return collectConfigDefinitions(plusFilesRelevant, filter).configDefinitions;
783
+ }
784
+ function collectConfigDefinitions(plusFilesRelevant, filter) {
776
785
  let configDefinitions = { ...metaBuiltIn };
786
+ const peerDependencyConfigNames = new Set();
777
787
  // Add user-land meta configs
778
788
  plusFilesRelevant
779
789
  .slice()
@@ -799,14 +809,9 @@ function getConfigDefinitions(plusFilesRelevant, filter) {
799
809
  });
800
810
  objectEntries(meta).forEach(([configName, configDefinitionUserLand]) => {
801
811
  if ('isDefinedByPeerDependency' in configDefinitionUserLand) {
802
- /* vike-server@1.0.24 wrongfully sets `stream: { env: { config: true }, isDefinedByPeerDependency: true }`
803
- assert(deepEqual(Object.keys(configDefinitionUserLand), ['isDefinedByPeerDependency']))
804
- //*/
805
- if (!configDefinitions[configName]) {
806
- configDefinitions[configName] = {
807
- env: { client: false, server: false, config: false },
808
- };
809
- }
812
+ assert(deepEqual(Object.keys(configDefinitionUserLand), ['isDefinedByPeerDependency']));
813
+ if (!configDefinitions[configName])
814
+ peerDependencyConfigNames.add(configName);
810
815
  return;
811
816
  }
812
817
  // User can override an existing config definition
@@ -814,12 +819,13 @@ function getConfigDefinitions(plusFilesRelevant, filter) {
814
819
  ...configDefinitions[configName],
815
820
  ...configDefinitionUserLand,
816
821
  };
822
+ peerDependencyConfigNames.delete(configName);
817
823
  });
818
824
  });
819
825
  if (filter) {
820
826
  configDefinitions = Object.fromEntries(Object.entries(configDefinitions).filter(([_configName, configDef]) => filter(configDef)));
821
827
  }
822
- return configDefinitions;
828
+ return { configDefinitions, peerDependencyConfigNames };
823
829
  }
824
830
  function assertMetaUsage(metaVal, metaConfigDefinedAt) {
825
831
  if (!isObject(metaVal)) {
@@ -454,9 +454,12 @@ async function createGlobalContext(virtualFileExportsGlobalEntry) {
454
454
  debug('createGlobalContext() - done [sync]');
455
455
  // We define an early globalContext version synchronously, so that getGlobalContextSync() can be called early.
456
456
  // - Required by vike-vercel
457
- assert(globalObject.globalContext);
457
+ const globalContextIsSetEarly = !!globalObject.globalContext;
458
+ assertWarning(globalContextIsSetEarly, "globalContext isn't set early", { onlyOnce: false });
458
459
  const globalContext = await globalContextPromise;
459
460
  debug('createGlobalContext() - done [async]');
461
+ assert(globalContextIsSetEarly); // We deliberately assert after the `await` (otherwise it swallows promise rejections such as an assert() failing synchronously inside `async createGlobalContextShared()`).
462
+ assert(globalObject.globalContext);
460
463
  assertV1Design(
461
464
  // pageConfigs is PageConfigRuntime[] but assertV1Design() requires PageConfigBuildTime[]
462
465
  globalContext._pageConfigs.length > 0, globalContext._pageFilesAll);
@@ -2,7 +2,7 @@ export { serializeConfigValues };
2
2
  export { getConfigValuesBase };
3
3
  export { isJsonValue };
4
4
  export type { FilesEnv };
5
- import type { ConfigEnvInternal, ConfigValueSource, DefinedAt, PageConfigBuildTime, PageConfigGlobalBuildTime } from '../../../types/PageConfig.js';
5
+ import type { ConfigEnv, ConfigValueSource, DefinedAt, PageConfigBuildTime, PageConfigGlobalBuildTime } from '../../../types/PageConfig.js';
6
6
  import { type RuntimeEnv } from '../../../node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js';
7
7
  declare function serializeConfigValues(pageConfig: PageConfigBuildTime | PageConfigGlobalBuildTime, importStatements: string[], filesEnv: FilesEnv, runtimeEnv: RuntimeEnv, tabspace: string, isEager: boolean | null): string[];
8
8
  declare function isJsonValue(value: unknown): boolean;
@@ -13,7 +13,7 @@ type ConfigValuesBase = ({
13
13
  definedAtData: null;
14
14
  };
15
15
  value: unknown;
16
- configEnv: ConfigEnvInternal;
16
+ configEnv: ConfigEnv;
17
17
  configName: string;
18
18
  } | {
19
19
  configValueBase: {
@@ -31,6 +31,6 @@ type ConfigValuesBase = ({
31
31
  configName: string;
32
32
  })[];
33
33
  type FilesEnv = Map<string, {
34
- configEnv: ConfigEnvInternal;
34
+ configEnv: ConfigEnv;
35
35
  configName: string;
36
36
  }[]>;
@@ -2,7 +2,7 @@ export type { Config };
2
2
  export type { ConfigBuiltIn };
3
3
  export type { ConfigBuiltInResolved };
4
4
  export type { ConfigNameBuiltIn };
5
- export type { ConfigNameGlobal };
5
+ export type { ConfigNameBuiltInGlobal };
6
6
  export type { ConfigMeta };
7
7
  export type { HookName };
8
8
  export type { HookNameOld };
@@ -56,7 +56,7 @@ type HookNamePage = 'onHydrationEnd' | 'onBeforePrerenderStart' | 'onBeforeRende
56
56
  type HookNameGlobal = 'onBeforeRoute' | 'onPrerenderStart' | 'onCreatePageContext' | 'onCreateGlobalContext' | 'onError' | 'onHookCall';
57
57
  type HookNameOldDesign = 'render' | 'prerender' | 'onBeforePrerender';
58
58
  type ConfigNameBuiltIn = Exclude<keyof ConfigBuiltIn, keyof VikeVitePluginOptions | 'onBeforeRoute' | 'onPrerenderStart' | 'vite' | 'redirects'> | 'prerender' | 'hasServerOnlyHook' | 'isClientRuntimeLoaded' | 'onBeforeRenderEnv' | 'dataEnv' | 'guardEnv' | 'hooksTimeout' | 'clientHooks' | 'middleware' | 'server' | 'vercel';
59
- type ConfigNameGlobal = 'onPrerenderStart' | 'onBeforeRoute' | 'prerender' | 'disableAutoFullBuild' | 'includeAssetsImportedByServer' | 'baseAssets' | 'baseServer' | 'redirects' | 'trailingSlash' | 'disableUrlNormalization' | 'vite';
59
+ type ConfigNameBuiltInGlobal = 'onPrerenderStart' | 'onBeforeRoute' | 'prerender' | 'disableAutoFullBuild' | 'includeAssetsImportedByServer' | 'baseAssets' | 'baseServer' | 'redirects' | 'trailingSlash' | 'disableUrlNormalization' | 'vite';
60
60
  type Config = ConfigBuiltIn & Vike.Config;
61
61
  /** @deprecated This type is deprecated, see:
62
62
  * - https://vike.dev/migration/hook-types
@@ -4,7 +4,6 @@ export type { PageConfigBuildTime };
4
4
  export type { PageConfigCommon };
5
5
  export type { PageConfigRoute };
6
6
  export type { ConfigEnv };
7
- export type { ConfigEnvInternal };
8
7
  export type { PageConfigGlobalRuntime };
9
8
  export type { PageConfigGlobalBuildTime };
10
9
  export type { ConfigValue };
@@ -79,21 +78,24 @@ type VirtualFileExportsPageEntry = {
79
78
  *
80
79
  * https://vike.dev/meta
81
80
  */
82
- type ConfigEnv = {
81
+ type ConfigEnv = ({
82
+ /** Load value on the client-side */
83
83
  client?: boolean;
84
+ } | {
85
+ /** @experimental */
86
+ client?: 'if-client-routing';
87
+ }) & {
88
+ /** Load value on the server-side */
84
89
  server?: boolean;
90
+ /** Load value for config files */
85
91
  config?: boolean;
86
- };
87
- /** For Vike internal use */
88
- type ConfigEnvInternal = Omit<ConfigEnv, 'client'> & {
89
- client?: boolean | 'if-client-routing';
90
- /** Load value only in production, or only in development. */
92
+ /** Load value only in production (`true`), or only in development (`false`), or always (`undefined`). */
91
93
  production?: boolean;
92
94
  };
93
95
  type ConfigValueSources = Record<string, // configName
94
96
  ConfigValueSource[]>;
95
97
  type ConfigValueSource = {
96
- configEnv: ConfigEnvInternal;
98
+ configEnv: ConfigEnv;
97
99
  definedAt: DefinedAtFilePath | DefinedBy;
98
100
  plusFile: PlusFile | null;
99
101
  locationId: LocationId;
@@ -114,7 +116,7 @@ type DefinedAtFilePath = DefinedAtFile & FilePath & {
114
116
  };
115
117
  type ConfigValuesComputed = Record<string, // configName
116
118
  {
117
- configEnv: ConfigEnvInternal;
119
+ configEnv: ConfigEnv;
118
120
  value: unknown;
119
121
  }>;
120
122
  type ConfigValues = Record<string, // configName
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.258";
1
+ export declare const PROJECT_VERSION: "0.4.259-commit-146b243";
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.258';
2
+ export const PROJECT_VERSION = '0.4.259-commit-146b243';
@@ -0,0 +1 @@
1
+ export declare function isDeno(): boolean;
@@ -0,0 +1,3 @@
1
+ export function isDeno() {
2
+ return typeof Deno !== 'undefined' && typeof Deno.version === 'object' && typeof Deno.version.deno === 'string';
3
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.258",
3
+ "version": "0.4.259-commit-146b243",
4
4
  "repository": "https://github.com/vikejs/vike",
5
5
  "exports": {
6
6
  "./server": {
@@ -129,11 +129,11 @@
129
129
  "@babel/core": "^7.28.5",
130
130
  "@babel/types": "^7.28.5",
131
131
  "@brillout/import": "^0.2.6",
132
- "@brillout/json-serializer": "^0.5.22",
132
+ "@brillout/json-serializer": "^0.5.23",
133
133
  "@brillout/picocolors": "^1.0.30",
134
134
  "@brillout/vite-plugin-server-entry": "0.7.18",
135
135
  "@universal-deploy/store": "^0.2.1",
136
- "@universal-deploy/vite": "^0.1.7",
136
+ "@universal-deploy/vite": "^0.1.9",
137
137
  "@universal-middleware/core": "^0.4.17",
138
138
  "@universal-middleware/node": "^0.1.0",
139
139
  "cac": "^6.0.0",
@@ -143,7 +143,7 @@
143
143
  "json5": "^2.0.0",
144
144
  "magic-string": "^0.30.17",
145
145
  "picomatch": "^4.0.4",
146
- "semver": "^7.7.4",
146
+ "semver": "^7.8.0",
147
147
  "sirv": "^3.0.2",
148
148
  "source-map-support": "^0.5.0",
149
149
  "tinyglobby": "^0.2.16",
@@ -262,7 +262,7 @@
262
262
  "./fetch.js"
263
263
  ],
264
264
  "devDependencies": {
265
- "@brillout/release-me": "^0.4.13",
265
+ "@brillout/release-me": "^0.4.15",
266
266
  "@types/babel__core": "^7.20.5",
267
267
  "@types/estree": "^1.0.5",
268
268
  "@types/node": "^20.10.5",
@@ -271,6 +271,7 @@
271
271
  "@types/source-map-support": "^0.5.10",
272
272
  "react-streaming": "^0.4.17",
273
273
  "rimraf": "^6.1.3",
274
+ "rolldown": "1.0.0-rc.17",
274
275
  "typescript": "^5.9.3",
275
276
  "vite": "^7.2.6"
276
277
  },