@timber-js/app 0.1.5 → 0.1.6
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/rsc-entry/index.ts"],"names":[],"mappings":"AA2EA;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAE/F;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/rsc-entry/index.ts"],"names":[],"mappings":"AA2EA;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAE/F;AAkpBD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;8BA9hBpD,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC;AAgiBhD,wBAAiE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@timber-js/app",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Vite-native React framework for Cloudflare Workers — correct HTTP semantics, real status codes, pages that work without JavaScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -147,6 +147,18 @@ function extractErrorHint(message: string): string | null {
|
|
|
147
147
|
return 'A component resolved to undefined/null — check default exports and import paths';
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
+
// "Invalid hook call" — hooks called outside React's render context.
|
|
151
|
+
// In RSC, this typically means a 'use client' component was executed as a
|
|
152
|
+
// server component instead of being serialized as a client reference.
|
|
153
|
+
if (message.includes('Invalid hook call')) {
|
|
154
|
+
return (
|
|
155
|
+
'A hook was called outside of a React component render. ' +
|
|
156
|
+
'If this is a \'use client\' component, ensure the directive is at the very top of the file ' +
|
|
157
|
+
'(before any imports) and that @vitejs/plugin-rsc is loaded correctly. ' +
|
|
158
|
+
'Barrel re-exports from non-\'use client\' files do not propagate the directive.'
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
150
162
|
return null;
|
|
151
163
|
}
|
|
152
164
|
|
|
@@ -409,6 +409,30 @@ async function renderRoute(
|
|
|
409
409
|
status: error.status,
|
|
410
410
|
});
|
|
411
411
|
}
|
|
412
|
+
// Dev diagnostic: detect "Invalid hook call" errors which indicate
|
|
413
|
+
// a 'use client' component is being executed during RSC rendering
|
|
414
|
+
// instead of being serialized as a client reference. This happens when
|
|
415
|
+
// the RSC plugin's transform doesn't detect the directive — e.g., the
|
|
416
|
+
// directive isn't at the very top of the file, or the component is
|
|
417
|
+
// re-exported through a barrel file without 'use client'.
|
|
418
|
+
// See LOCAL-297.
|
|
419
|
+
if (
|
|
420
|
+
process.env.NODE_ENV !== 'production' &&
|
|
421
|
+
error instanceof Error &&
|
|
422
|
+
error.message.includes('Invalid hook call')
|
|
423
|
+
) {
|
|
424
|
+
console.error(
|
|
425
|
+
'[timber] A React hook was called during RSC rendering. This usually means a ' +
|
|
426
|
+
"'use client' component is being executed as a server component instead of " +
|
|
427
|
+
'being serialized as a client reference.\n\n' +
|
|
428
|
+
'Common causes:\n' +
|
|
429
|
+
" 1. The 'use client' directive is not the FIRST statement in the file (before any imports)\n" +
|
|
430
|
+
" 2. The component is re-exported through a barrel file (index.ts) that lacks 'use client'\n" +
|
|
431
|
+
' 3. @vitejs/plugin-rsc is not loaded or is misconfigured\n\n' +
|
|
432
|
+
`Request: ${_req.method} ${new URL(_req.url).pathname}`
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
|
|
412
436
|
// Track unhandled errors for pre-flush handling (500 status)
|
|
413
437
|
if (!renderError) {
|
|
414
438
|
renderError = { error, status: 500 };
|