vike 0.4.259-commit-f2bab48 → 0.4.259-commit-58f1d2c

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.
@@ -3,6 +3,7 @@ export { resolveOptimizeDeps };
3
3
  import { findPageFiles } from '../../shared/findPageFiles.js';
4
4
  import { assert } from '../../../../utils/assert.js';
5
5
  import { createDebug } from '../../../../utils/debug.js';
6
+ import { deepEqual } from '../../../../utils/deepEqual.js';
6
7
  import { isArray } from '../../../../utils/isArray.js';
7
8
  import { isFilePathAbsoluteFilesystem } from '../../../../utils/isFilePathAbsoluteFilesystem.js';
8
9
  import { assertImportIsNpmPackage, getNpmPackageName } from '../../../../utils/parseNpmPackage.js';
@@ -70,9 +71,9 @@ const optimizeDeps = {
70
71
  // - Make server environments inherit from ssr.optimizeDeps (it isn't the case by default)
71
72
  async function resolveOptimizeDeps(config) {
72
73
  const vikeConfig = await getVikeConfigInternal();
73
- const { _pageConfigs: pageConfigs } = vikeConfig;
74
+ const { _pageConfigs: pageConfigs, _pageConfigGlobal: pageConfigGlobal } = vikeConfig;
74
75
  // Retrieve user's + files (i.e. Vike entries)
75
- const { entriesClient, entriesServer, includeClient, includeServer } = await getPageDeps(config, pageConfigs);
76
+ const { entriesClient, entriesServer, includeClient, includeServer } = await getPageDeps(config, pageConfigs, pageConfigGlobal);
76
77
  // Add late discovered dependencies, if they exist
77
78
  LATE_DISCOVERED.forEach((dep) => {
78
79
  const userRootDir = config.root;
@@ -114,18 +115,19 @@ async function resolveOptimizeDeps(config) {
114
115
  env.optimizeDeps.entries = remove(env.optimizeDeps.entries ?? []);
115
116
  }
116
117
  // Debug
117
- if (debug.isActivated)
118
- debug('optimizeDeps', {
119
- 'config.optimizeDeps.entries': config.optimizeDeps.entries,
120
- 'config.optimizeDeps.include': config.optimizeDeps.include,
121
- 'config.optimizeDeps.exclude': config.optimizeDeps.exclude,
122
- // @ts-ignore Vite doesn't seem to support ssr.optimizeDeps.entries (vite@7.0.6, July 2025)
123
- 'config.ssr.optimizeDeps.entries': config.ssr.optimizeDeps.entries,
124
- 'config.ssr.optimizeDeps.include': config.ssr.optimizeDeps.include,
125
- 'config.ssr.optimizeDeps.exclude': config.ssr.optimizeDeps.exclude,
126
- });
118
+ if (debug.isActivated) {
119
+ const envs = {};
120
+ for (const envName in config.environments) {
121
+ const env = config.environments[envName];
122
+ envs[`config.environments.${envName}.optimizeDeps.entries`] = env.optimizeDeps.entries;
123
+ envs[`config.environments.${envName}.optimizeDeps.include`] = env.optimizeDeps.include;
124
+ envs[`config.environments.${envName}.optimizeDeps.exclude`] = env.optimizeDeps.exclude;
125
+ }
126
+ debug('optimizeDeps', envs);
127
+ assertEnvsInSyncWithLegacy(config);
128
+ }
127
129
  }
128
- async function getPageDeps(config, pageConfigs) {
130
+ async function getPageDeps(config, pageConfigs, pageConfigGlobal) {
129
131
  let entriesClient = [];
130
132
  let entriesServer = [];
131
133
  let includeClient = [];
@@ -181,7 +183,8 @@ async function getPageDeps(config, pageConfigs) {
181
183
  {
182
184
  ;
183
185
  [true, false].forEach((isForClientSide) => {
184
- pageConfigs.forEach((pageConfig) => {
186
+ ;
187
+ [...pageConfigs, pageConfigGlobal].forEach((pageConfig) => {
185
188
  Object.entries(pageConfig.configValueSources).forEach(([configName]) => {
186
189
  const runtimeEnv = {
187
190
  isForClientSide,
@@ -213,10 +216,15 @@ async function getPageDeps(config, pageConfigs) {
213
216
  });
214
217
  }
215
218
  // Add virtual files.
216
- // - This doesn't work: Vite's dep optimizer doesn't seem to be able to crawl virtual files.
217
- // - Should we make it work? E.g. by creating a temporary file at node_modules/.vike/virtualFiles.js
218
- // - Or should we remove it? And make sure getPageDeps() also works for aliased import paths
219
- // - If we do, then we need to adjust include/entries (maybe by making include === entries -> will Vite complain?)
219
+ // - Vite 8+ (Rolldown-based dep scanner) crawls virtual IDs natively its scanner routes
220
+ // through `environment.pluginContainer.resolveId()`, so Vike's resolveId/load handlers
221
+ // run during the scan and the virtual file's transitive deps are seen.
222
+ // - Vite ≤7 (esbuild-based dep scanner) cannot crawl virtual IDs those virtuals' deps
223
+ // surface lazily and trigger "✨ new dependencies optimized" reload cycles. As a
224
+ // workaround we could materialize each virtual to a real file under
225
+ // `node_modules/.vike/optimizeDeps-virtuals/`; an implementation lives in the reverted
226
+ // commit https://github.com/vikejs/vike/commit/b068009c3 (re-apply if Vite ≤7 support
227
+ // matters).
220
228
  {
221
229
  const { hasClientRouting, hasServerRouting, clientEntries } = analyzeClientEntries(pageConfigs, config);
222
230
  Object.values(clientEntries).forEach(({ entryTarget, entryFilePath }) => {
@@ -265,3 +273,20 @@ function remove(input) {
265
273
  list = list.filter((e) => !ALWAYS_REMOVE.includes(e));
266
274
  return list;
267
275
  }
276
+ // Sanity-check that the legacy `config.optimizeDeps` and `config.ssr.optimizeDeps` slots
277
+ // stay in sync with the corresponding environment values — so logging only the env values
278
+ // (above) isn't hiding anything.
279
+ function assertEnvsInSyncWithLegacy(config) {
280
+ const client = config.environments.client?.optimizeDeps;
281
+ assert(client);
282
+ assert(deepEqual(config.optimizeDeps.entries, client.entries));
283
+ assert(deepEqual(config.optimizeDeps.include, client.include));
284
+ assert(deepEqual(config.optimizeDeps.exclude, client.exclude));
285
+ const ssr = config.environments.ssr?.optimizeDeps;
286
+ assert(ssr);
287
+ /* Vite doesn't seem to support config.ssr.optimizeDeps.entries (vite@7.0.6, July 2025)
288
+ assert(deepEqual(config.ssr.optimizeDeps.entries, ssr.entries))
289
+ */
290
+ assert(deepEqual(config.ssr.optimizeDeps.include, ssr.include));
291
+ assert(deepEqual(config.ssr.optimizeDeps.exclude, ssr.exclude));
292
+ }
@@ -27,7 +27,7 @@ async function generateVirtualFilePageEntry(id, isDev) {
27
27
  }
28
28
  else {
29
29
  if (!pageConfig) {
30
- // Happens very seldomly and can't reproduce reliably. Some kind of HMR race condition? It still happens as of June 2026 with Cloudflare Workers in developement — but it isn't blocking, reloading the page fixes the issue.
30
+ // Happens very seldom and can't reproduce reliably. Some kind of HMR race condition? It still happens as of June 2026 with Cloudflare Workers in development — but it isn't blocking, reloading the page fixes the issue.
31
31
  throw getProjectError(`Outdated request. Try again. ${getDebugInfoStr({ id, pageId })}`);
32
32
  }
33
33
  }
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.259-commit-f2bab48";
1
+ export declare const PROJECT_VERSION: "0.4.259-commit-58f1d2c";
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.259-commit-f2bab48';
2
+ export const PROJECT_VERSION = '0.4.259-commit-58f1d2c';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.259-commit-f2bab48",
3
+ "version": "0.4.259-commit-58f1d2c",
4
4
  "repository": "https://github.com/vikejs/vike",
5
5
  "exports": {
6
6
  "./server": {