vike-react 0.6.13 → 0.6.14
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.
|
@@ -8,6 +8,7 @@ import { applyHeadSettings } from './applyHeadSettings.js';
|
|
|
8
8
|
import { resolveReactOptions } from './resolveReactOptions.js';
|
|
9
9
|
import { getGlobalObject } from '../utils/getGlobalObject.js';
|
|
10
10
|
import { isObject } from '../utils/isObject.js';
|
|
11
|
+
import { getBetterErrorLight } from '../utils/getBetterErrorLight.js';
|
|
11
12
|
const globalObject = getGlobalObject('onRenderClient.tsx', {});
|
|
12
13
|
async function onRenderClient(pageContext) {
|
|
13
14
|
pageContext._headAlreadySet = pageContext.isHydration;
|
|
@@ -70,7 +71,7 @@ function applyHead(pageContext) {
|
|
|
70
71
|
// Global callback, attached once upon hydration.
|
|
71
72
|
function onUncaughtErrorGlobal(args, userOptions) {
|
|
72
73
|
const [errorOriginal, errorInfo] = args;
|
|
73
|
-
const errorEnhanced =
|
|
74
|
+
const errorEnhanced = getErrorWithComponentStack(errorOriginal, errorInfo);
|
|
74
75
|
console.error(errorEnhanced);
|
|
75
76
|
// Used by Vike:
|
|
76
77
|
// https://github.com/vikejs/vike/blob/8ce2cbda756892f0ff083256291515b5a45fe319/packages/vike/client/runtime-client-routing/renderPageClientSide.ts#L838-L844
|
|
@@ -79,7 +80,7 @@ function onUncaughtErrorGlobal(args, userOptions) {
|
|
|
79
80
|
globalObject.onUncaughtErrorLocal?.(errorEnhanced);
|
|
80
81
|
userOptions?.onUncaughtError?.call(this, errorEnhanced, errorInfo);
|
|
81
82
|
}
|
|
82
|
-
function
|
|
83
|
+
function getErrorWithComponentStack(errorOriginal, errorInfo) {
|
|
83
84
|
if (!errorInfo?.componentStack || !isObject(errorOriginal))
|
|
84
85
|
return errorOriginal;
|
|
85
86
|
const errorStackLines = String(errorOriginal.stack).split('\n');
|
|
@@ -108,18 +109,6 @@ function getErrorEnhanced(errorOriginal, errorInfo) {
|
|
|
108
109
|
...componentStackLines,
|
|
109
110
|
...errorStackLinesEnd,
|
|
110
111
|
].join('\n');
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
// https://gist.github.com/brillout/066293a687ab7cf695e62ad867bc6a9c
|
|
114
|
-
Object.defineProperty(errorEnhanced, 'getOriginalError', {
|
|
115
|
-
value: () => errorOriginal,
|
|
116
|
-
enumerable: true,
|
|
117
|
-
});
|
|
118
|
-
/* Not needed. Let's skip this to save client-side KBs.
|
|
119
|
-
Object.defineProperty(errorOriginal, 'getEnhancedError', {
|
|
120
|
-
value: () => errorEnhanced,
|
|
121
|
-
enumerable: true,
|
|
122
|
-
})
|
|
123
|
-
//*/
|
|
124
|
-
return errorEnhanced;
|
|
112
|
+
const errorBetter = getBetterErrorLight(errorOriginal, { stack: stackEnhanced });
|
|
113
|
+
return errorBetter;
|
|
125
114
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { getBetterErrorLight };
|
|
2
|
+
// Same as getBetterError() with less features (thus less KBs) for the client-side
|
|
3
|
+
// Copies:
|
|
4
|
+
// - https://github.com/vikejs/vike/blob/a54b7618d80409c6df4b597489ddbb7739f3e86f/packages/vike/utils/getBetterError.ts
|
|
5
|
+
// - https://github.com/brillout/react-streaming/blob/b8565c1257c63a665bda31b9be42112e458859d1/src/utils/getBetterError.ts
|
|
6
|
+
function getBetterErrorLight(err, modifications) {
|
|
7
|
+
const errBetter = structuredClone(err);
|
|
8
|
+
Object.assign(errBetter, modifications);
|
|
9
|
+
// Enable users to retrieve the original error
|
|
10
|
+
Object.assign(errBetter, { getOriginalError: () => err?.getOriginalError?.() ?? err });
|
|
11
|
+
return errBetter;
|
|
12
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike-react",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.14",
|
|
4
4
|
"repository": "https://github.com/vikejs/vike-react",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"./__internal/integration/Loading": "./dist/integration/Loading.js"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"react-streaming": "^0.4.
|
|
30
|
+
"react-streaming": "^0.4.14"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"react": ">=19",
|
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@biomejs/biome": "^1.9.4",
|
|
39
|
-
"@brillout/release-me": "^0.4.
|
|
39
|
+
"@brillout/release-me": "^0.4.9",
|
|
40
40
|
"@types/node": "^24.0.8",
|
|
41
41
|
"@types/react": "^19.1.13",
|
|
42
42
|
"@types/react-dom": "^19.1.9",
|
|
43
|
-
"react": "^19.2.
|
|
44
|
-
"react-dom": "^19.2.
|
|
43
|
+
"react": "^19.2.1",
|
|
44
|
+
"react-dom": "^19.2.1",
|
|
45
45
|
"rimraf": "^5.0.5",
|
|
46
46
|
"typescript": "^5.9.2",
|
|
47
47
|
"vike": "^0.4.242",
|