vike 0.4.259-commit-cf2a786 → 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.
- package/dist/node/vite/plugins/pluginDev/optimizeDeps.js +43 -18
- package/dist/node/vite/plugins/pluginVirtualFiles/generateVirtualFilePageEntry.js +5 -7
- package/dist/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/utils/PROJECT_VERSION.js +1 -1
- package/dist/utils/assert.d.ts +2 -0
- package/dist/utils/assert.js +8 -8
- package/package.json +1 -1
|
@@ -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
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
-
|
|
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
|
-
// -
|
|
217
|
-
//
|
|
218
|
-
//
|
|
219
|
-
//
|
|
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
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { generateVirtualFilePageEntry };
|
|
2
|
-
import { assert, getProjectError } from '../../../../utils/assert.js';
|
|
2
|
+
import { assert, getDebugInfoStr, getProjectError } from '../../../../utils/assert.js';
|
|
3
3
|
import { parseVirtualFileId, generateVirtualFileId } from '../../../../shared-server-node/virtualFileId.js';
|
|
4
4
|
import { getVikeConfigInternal } from '../../shared/resolveVikeConfigInternal.js';
|
|
5
5
|
import { extractAssetsAddQuery } from '../../../../shared-server-node/extractAssetsQuery.js';
|
|
@@ -26,12 +26,10 @@ async function generateVirtualFilePageEntry(id, isDev) {
|
|
|
26
26
|
assert(pageConfig);
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
throw getProjectError('Outdated request');
|
|
34
|
-
//*/
|
|
29
|
+
if (!pageConfig) {
|
|
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
|
+
throw getProjectError(`Outdated request. Try again. ${getDebugInfoStr({ id, pageId })}`);
|
|
32
|
+
}
|
|
35
33
|
}
|
|
36
34
|
const code = getCode(pageConfig, isForClientSide, pageId, resolveIncludeAssetsImportedByServer(vikeConfig.config), isDev);
|
|
37
35
|
debug(id, isForClientSide ? 'CLIENT-SIDE' : 'SERVER-SIDE', code);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.259-commit-
|
|
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-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.259-commit-58f1d2c';
|
package/dist/utils/assert.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { assertUsage };
|
|
|
3
3
|
export { assertWarning };
|
|
4
4
|
export { assertInfo };
|
|
5
5
|
export { getProjectError };
|
|
6
|
+
export { getDebugInfoStr };
|
|
6
7
|
export { isVikeBug };
|
|
7
8
|
export { setAssertOnBeforeLog };
|
|
8
9
|
export { setAssertOnBeforeErr };
|
|
@@ -10,6 +11,7 @@ export { setAssertAlwaysShowStackTrace };
|
|
|
10
11
|
export { setAssertAddAssertTagsDev };
|
|
11
12
|
import type { AddAssertTagsDev } from '../node/vite/shared/loggerDev.js';
|
|
12
13
|
declare function assert(condition: unknown, debugInfo?: unknown): asserts condition;
|
|
14
|
+
declare function getDebugInfoStr(debugInfo: unknown): string | null;
|
|
13
15
|
declare function assertUsage(condition: unknown, errMsg: string, { showStackTrace, exitOnError }?: {
|
|
14
16
|
showStackTrace?: true;
|
|
15
17
|
exitOnError?: boolean;
|
package/dist/utils/assert.js
CHANGED
|
@@ -3,6 +3,7 @@ export { assertUsage };
|
|
|
3
3
|
export { assertWarning };
|
|
4
4
|
export { assertInfo };
|
|
5
5
|
export { getProjectError };
|
|
6
|
+
export { getDebugInfoStr };
|
|
6
7
|
export { isVikeBug };
|
|
7
8
|
export { setAssertOnBeforeLog };
|
|
8
9
|
export { setAssertOnBeforeErr };
|
|
@@ -24,17 +25,10 @@ const tagTypeBug = 'Bug';
|
|
|
24
25
|
function assert(condition, debugInfo) {
|
|
25
26
|
if (condition)
|
|
26
27
|
return;
|
|
27
|
-
const debugStr = (() => {
|
|
28
|
-
if (!debugInfo) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
const debugInfoSerialized = typeof debugInfo === 'string' ? debugInfo : JSON.stringify(debugInfo);
|
|
32
|
-
return pc.dim(`Debug for maintainers (you can ignore this): ${debugInfoSerialized}`);
|
|
33
|
-
})();
|
|
34
28
|
const link = pc.underline('https://github.com/vikejs/vike/issues/new?template=bug.yml');
|
|
35
29
|
let errMsg = [
|
|
36
30
|
`You stumbled upon a Vike bug. Go to ${link} and copy-paste this error. A maintainer will fix the bug (usually within 24 hours).`,
|
|
37
|
-
|
|
31
|
+
getDebugInfoStr(debugInfo),
|
|
38
32
|
]
|
|
39
33
|
.filter(Boolean)
|
|
40
34
|
.join(' ');
|
|
@@ -44,6 +38,12 @@ function assert(condition, debugInfo) {
|
|
|
44
38
|
globalObject.onBeforeErr?.(internalError);
|
|
45
39
|
throw internalError;
|
|
46
40
|
}
|
|
41
|
+
function getDebugInfoStr(debugInfo) {
|
|
42
|
+
if (!debugInfo)
|
|
43
|
+
return null;
|
|
44
|
+
const debugInfoSerialized = typeof debugInfo === 'string' ? debugInfo : JSON.stringify(debugInfo);
|
|
45
|
+
return pc.dim(`Debug for maintainers (you can ignore this): ${debugInfoSerialized}`);
|
|
46
|
+
}
|
|
47
47
|
function assertUsage(condition, errMsg, { showStackTrace, exitOnError } = {}) {
|
|
48
48
|
if (condition)
|
|
49
49
|
return;
|