vike 0.4.247-commit-14351e3 → 0.4.247-commit-9b74d50
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/client/runtime-client-routing/history.d.ts +5 -2
- package/dist/client/runtime-client-routing/history.js +52 -29
- package/dist/client/runtime-client-routing/initOnPopState.js +5 -3
- package/dist/node/api/dev.d.ts +4 -1
- package/dist/node/api/dev.js +55 -3
- package/dist/node/api/utils.d.ts +3 -0
- package/dist/node/api/utils.js +3 -0
- package/dist/node/cli/entry.js +1 -17
- package/dist/node/vite/plugins/build/pluginModuleBanner.js +20 -8
- package/dist/node/vite/plugins/pluginCommon.d.ts +1 -0
- package/dist/node/vite/plugins/pluginCommon.js +2 -0
- package/dist/node/vite/plugins/pluginDev.js +11 -8
- package/dist/node/vite/plugins/pluginReplaceConstantsGlobalThis.d.ts +2 -0
- package/dist/node/vite/plugins/pluginReplaceConstantsGlobalThis.js +5 -4
- package/dist/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntry.js +3 -2
- package/dist/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +2 -1
- package/dist/node/vite/shared/loggerDev/errorWithCodeSnippet.d.ts +2 -1
- package/dist/node/vite/shared/loggerDev/errorWithCodeSnippet.js +5 -8
- package/dist/node/vite/shared/loggerDev.js +32 -43
- package/dist/node/vite/shared/loggerVite.d.ts +15 -2
- package/dist/node/vite/shared/loggerVite.js +108 -11
- package/dist/node/vite/shared/resolveVikeConfigInternal/transpileAndExecuteFile.d.ts +3 -2
- package/dist/node/vite/shared/resolveVikeConfigInternal/transpileAndExecuteFile.js +4 -2
- package/dist/node/vite/shared/resolveVikeConfigInternal.js +3 -3
- package/dist/server/{runtime/onLoad.js → onLoad.js} +8 -5
- package/dist/server/runtime/renderPageServer/addErrorHint.d.ts +1 -1
- package/dist/server/runtime/renderPageServer/addErrorHint.js +4 -8
- package/dist/server/runtime/renderPageServer.js +10 -3
- package/dist/server/utils.d.ts +1 -0
- package/dist/server/utils.js +2 -1
- package/dist/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/utils/PROJECT_VERSION.js +1 -1
- package/dist/utils/assert.js +8 -4
- package/dist/utils/colorVike.d.ts +2 -0
- package/dist/utils/colorVike.js +5 -0
- package/dist/utils/colors.d.ts +2 -0
- package/dist/utils/colors.js +5 -0
- package/dist/utils/debug.js +13 -9
- package/dist/utils/formatHintLog.d.ts +1 -1
- package/dist/utils/formatHintLog.js +6 -8
- package/dist/utils/getBetterError.d.ts +7 -1
- package/dist/utils/getBetterError.js +38 -10
- package/package.json +2 -2
- package/dist/node/vite/shared/loggerVite/removeSuperfluousViteLog.d.ts +0 -6
- package/dist/node/vite/shared/loggerVite/removeSuperfluousViteLog.js +0 -24
- /package/dist/server/{runtime/onLoad.d.ts → onLoad.d.ts} +0 -0
package/dist/utils/debug.js
CHANGED
|
@@ -9,11 +9,6 @@ import { getTerminalWidth } from './getTerminalWidth.js';
|
|
|
9
9
|
import pc from '@brillout/picocolors';
|
|
10
10
|
import { isArray } from './isArray.js';
|
|
11
11
|
import { isObject } from './isObject.js';
|
|
12
|
-
// Assert tree-shaking (ensure this module is loaded on the client-side only if debug is enabled).
|
|
13
|
-
assert(!globalThis.__VIKE__IS_CLIENT ||
|
|
14
|
-
globalThis.__VIKE__IS_DEBUG ||
|
|
15
|
-
// Vite doesn't do tree-shaking in dev (maybe it will with Rolldown?)
|
|
16
|
-
import.meta.env.DEV);
|
|
17
12
|
const flags = [
|
|
18
13
|
'vike',
|
|
19
14
|
'vike:crawl',
|
|
@@ -36,13 +31,18 @@ const flags = [
|
|
|
36
31
|
'vike:vite-rpc',
|
|
37
32
|
];
|
|
38
33
|
const flagsSkipWildcard = ['vike:log'];
|
|
34
|
+
// Assert tree-shaking (ensure this module is loaded on the client-side only if debug is enabled).
|
|
35
|
+
const isUsed = !globalThis.__VIKE__IS_CLIENT ||
|
|
36
|
+
globalThis.__VIKE__IS_DEBUG ||
|
|
37
|
+
// Vite doesn't do tree-shaking in dev (maybe it will with Rolldown?)
|
|
38
|
+
import.meta.env.DEV;
|
|
39
39
|
// We purposely read process.env.DEBUG early, in order to avoid users from the temptation to set process.env.DEBUG with JavaScript, since reading & writing process.env.DEBUG dynamically leads to inconsistencies such as https://github.com/vikejs/vike/issues/2239
|
|
40
|
-
const DEBUG = getDEBUG()
|
|
41
|
-
if (
|
|
42
|
-
|
|
43
|
-
assertFlagsActivated();
|
|
40
|
+
const DEBUG = (isUsed && getDEBUG()) || '';
|
|
41
|
+
if (isUsed)
|
|
42
|
+
assertFlagsActivated();
|
|
44
43
|
function createDebug(flag, optionsGlobal) {
|
|
45
44
|
assert(flags.includes(flag));
|
|
45
|
+
assert(isUsed);
|
|
46
46
|
const debugWithOptions = (optionsLocal) => {
|
|
47
47
|
return (...msgs) => {
|
|
48
48
|
const options = { ...optionsGlobal, ...optionsLocal };
|
|
@@ -57,6 +57,7 @@ function debug(flag, ...msgs) {
|
|
|
57
57
|
return debug_(flag, {}, ...msgs);
|
|
58
58
|
}
|
|
59
59
|
function debug_(flag, options, ...msgs) {
|
|
60
|
+
assert(isUsed);
|
|
60
61
|
if (!isDebug(flag))
|
|
61
62
|
return;
|
|
62
63
|
let [msgFirst, ...msgsRest] = msgs;
|
|
@@ -84,6 +85,7 @@ function debug_(flag, options, ...msgs) {
|
|
|
84
85
|
});
|
|
85
86
|
}
|
|
86
87
|
function isDebug(flag) {
|
|
88
|
+
assert(isUsed);
|
|
87
89
|
assert(flag === undefined || (flag && flags.includes(flag)));
|
|
88
90
|
const { flagsActivated, isAll, isGlobal } = getFlagsActivated();
|
|
89
91
|
if (flag) {
|
|
@@ -157,6 +159,7 @@ function replaceFunctionSerializer(_key, value) {
|
|
|
157
159
|
return value;
|
|
158
160
|
}
|
|
159
161
|
function assertFlagsActivated() {
|
|
162
|
+
assert(isUsed);
|
|
160
163
|
const { flagsActivated } = getFlagsActivated();
|
|
161
164
|
flagsActivated.forEach((flag) => {
|
|
162
165
|
assertUsage(flags.includes(flag), `Unknown DEBUG flag ${pc.cyan(flag)}. Valid flags:\n${flags.map((f) => ` ${pc.cyan(f)}`).join('\n')}`);
|
|
@@ -169,6 +172,7 @@ function getFlagsActivated() {
|
|
|
169
172
|
return { flagsActivated, isAll, isGlobal };
|
|
170
173
|
}
|
|
171
174
|
function getDEBUG() {
|
|
175
|
+
assert(isUsed);
|
|
172
176
|
let DEBUG;
|
|
173
177
|
// ssr.noExternal
|
|
174
178
|
/* // Full implementation:
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { formatHintLog };
|
|
2
|
-
declare function formatHintLog(msg:
|
|
2
|
+
declare function formatHintLog<Msg extends string>(msg: Msg): `| ${Msg} |`;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
+
export { formatHintLog };
|
|
1
2
|
import { assert } from './assert.js';
|
|
2
3
|
import { stripAnsi } from './colors.js';
|
|
3
|
-
export { formatHintLog };
|
|
4
4
|
function formatHintLog(msg) {
|
|
5
5
|
assert(msg.length > 0);
|
|
6
6
|
const msgLength = stripAnsi(msg).length;
|
|
7
7
|
const sep = '─'.repeat(msgLength);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
`└─${sep}─┘`,
|
|
14
|
-
].join('\n');
|
|
8
|
+
const top = `┌─${sep}─┐\n`;
|
|
9
|
+
const mid = `│ ${msg} │\n`;
|
|
10
|
+
const bot = `└─${sep}─┘`;
|
|
11
|
+
const msgWrapped = `${top}${mid}${bot}`;
|
|
12
|
+
return msgWrapped;
|
|
15
13
|
}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
export { getBetterError };
|
|
2
2
|
declare function getBetterError(err: unknown, modifications: {
|
|
3
|
-
message?: string
|
|
3
|
+
message?: string | {
|
|
4
|
+
prepend?: string;
|
|
5
|
+
append?: string;
|
|
6
|
+
};
|
|
4
7
|
stack?: string;
|
|
5
8
|
hideStack?: true;
|
|
6
9
|
}): {
|
|
7
10
|
message: string;
|
|
8
11
|
stack: string;
|
|
12
|
+
hideStack?: true;
|
|
13
|
+
} & {
|
|
14
|
+
getOriginalError: () => any;
|
|
9
15
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export { getBetterError };
|
|
2
|
-
// TO-DO/
|
|
3
|
-
// TODO: fix? Reprod: 7f4baa40ec95fa55319f85a38a50291460790683
|
|
2
|
+
// TO-DO/maybe: make it a library `@brillout/better-error`
|
|
4
3
|
import { isObject } from './isObject.js';
|
|
4
|
+
import { assertIsNotBrowser } from './assertIsNotBrowser.js';
|
|
5
|
+
import { objectAssign } from './objectAssign.js';
|
|
6
|
+
assertIsNotBrowser();
|
|
5
7
|
function getBetterError(err, modifications) {
|
|
6
8
|
let errBetter;
|
|
7
9
|
// Normalize
|
|
@@ -17,16 +19,42 @@ function getBetterError(err, modifications) {
|
|
|
17
19
|
warnMalformed(err);
|
|
18
20
|
errBetter.stack = new Error(errBetter.message).stack;
|
|
19
21
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
// Modifications: err.hideStack and err.stack
|
|
23
|
+
const { message: modsMessage, ...mods } = modifications;
|
|
24
|
+
Object.assign(errBetter, mods);
|
|
25
|
+
// Modifications: err.message
|
|
26
|
+
if (typeof modsMessage === 'string') {
|
|
27
|
+
// Modify err.message
|
|
28
|
+
const messagePrev = errBetter.message;
|
|
29
|
+
const messageNext = modsMessage;
|
|
30
|
+
errBetter.message = messageNext;
|
|
31
|
+
// Update err.stack
|
|
32
|
+
const messagePrevIdx = errBetter.stack.indexOf(messagePrev);
|
|
33
|
+
if (messagePrevIdx >= 0) {
|
|
34
|
+
// Completely replace the beginning of err.stack — removing prefix such as "SyntaxError: "
|
|
35
|
+
// - Following isn't always true: `err.stack.startsWith(err.message)` — because err.stack can start with "SyntaxError: " whereas err.message doesn't
|
|
36
|
+
const stack = errBetter.stack.slice(messagePrevIdx + messagePrev.length);
|
|
37
|
+
errBetter.stack = messageNext + stack;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
warnMalformed(err);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
if (modsMessage?.append) {
|
|
45
|
+
const messagePrev = errBetter.message;
|
|
46
|
+
const messageNext = errBetter.message + modsMessage.append;
|
|
47
|
+
errBetter.message = messageNext;
|
|
48
|
+
errBetter.stack = errBetter.stack.replace(messagePrev, messageNext);
|
|
49
|
+
}
|
|
50
|
+
if (modsMessage?.prepend) {
|
|
51
|
+
const { prepend } = modsMessage;
|
|
52
|
+
errBetter.message = prepend + errBetter.message;
|
|
53
|
+
errBetter.stack = prepend + errBetter.stack;
|
|
54
|
+
}
|
|
22
55
|
}
|
|
23
|
-
// Modifications
|
|
24
|
-
const errMessageOriginal = errBetter.message;
|
|
25
|
-
Object.assign(errBetter, modifications);
|
|
26
|
-
if (modifications.message)
|
|
27
|
-
errBetter.stack = errBetter.stack.replaceAll(errMessageOriginal, modifications.message);
|
|
28
56
|
// Enable users to retrieve the original error
|
|
29
|
-
|
|
57
|
+
objectAssign(errBetter, { getOriginalError: () => err?.getOriginalError?.() ?? err });
|
|
30
58
|
return errBetter;
|
|
31
59
|
}
|
|
32
60
|
// TO-DO/eventually: think about whether logging this warning is a good idea
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.247-commit-
|
|
3
|
+
"version": "0.4.247-commit-9b74d50",
|
|
4
4
|
"repository": "https://github.com/vikejs/vike",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": {
|
|
@@ -249,7 +249,7 @@
|
|
|
249
249
|
"react-streaming": "^0.4.13",
|
|
250
250
|
"rimraf": "^5.0.5",
|
|
251
251
|
"typescript": "^5.9.3",
|
|
252
|
-
"vite": "^7.
|
|
252
|
+
"vite": "^7.2.6"
|
|
253
253
|
},
|
|
254
254
|
"scripts": {
|
|
255
255
|
"dev": "tsc --watch",
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { removeSuperfluousViteLog };
|
|
2
|
-
export { removeSuperfluousViteLog_enable };
|
|
3
|
-
export { removeSuperfluousViteLog_disable };
|
|
4
|
-
declare function removeSuperfluousViteLog(msg: string): boolean;
|
|
5
|
-
declare function removeSuperfluousViteLog_enable(): void;
|
|
6
|
-
declare function removeSuperfluousViteLog_disable(): void;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export { removeSuperfluousViteLog };
|
|
2
|
-
export { removeSuperfluousViteLog_enable };
|
|
3
|
-
export { removeSuperfluousViteLog_disable };
|
|
4
|
-
import { assert, getGlobalObject } from '../../utils.js';
|
|
5
|
-
const globalObject = getGlobalObject('removeSuperfluousViteLog.ts', {
|
|
6
|
-
enabled: false,
|
|
7
|
-
});
|
|
8
|
-
const superfluousLog = 'Forced re-optimization of dependencies';
|
|
9
|
-
function removeSuperfluousViteLog(msg) {
|
|
10
|
-
if (!globalObject.enabled) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
if (msg.toLowerCase().includes('forced') && msg.toLowerCase().includes('optimization')) {
|
|
14
|
-
assert(msg === superfluousLog, msg); // assertion fails => Vite changed its message => update this function
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
function removeSuperfluousViteLog_enable() {
|
|
20
|
-
globalObject.enabled = true;
|
|
21
|
-
}
|
|
22
|
-
function removeSuperfluousViteLog_disable() {
|
|
23
|
-
globalObject.enabled = false;
|
|
24
|
-
}
|
|
File without changes
|