fix(ssr): skip canvas/WebGL components on the server
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
requestAnimationFrame/document are browser-only; Three.js trophies, particles, cursor, and loading screen now no-op during SSR. Add a Node rAF shim as a safety net.
This commit is contained in:
1 parent
0a30980105
commit
1583b7035f
14 files changed
+106
-8
No files matched your search
@@ -1,5 +1,17 @@
|
||||
import 'dotenv/config';
|
||||
import 'zone.js/node';
|
||||
|
||||
// Node has no rAF; polyfill before Angular SSR bootstraps (belt + suspenders
|
||||
// alongside browser-only guards in canvas components).
|
||||
if (typeof globalThis.requestAnimationFrame !== 'function') {
|
||||
globalThis.requestAnimationFrame = ((cb: FrameRequestCallback) =>
|
||||
setTimeout(() => cb(Date.now()), 16)) as unknown as typeof requestAnimationFrame;
|
||||
}
|
||||
if (typeof globalThis.cancelAnimationFrame !== 'function') {
|
||||
globalThis.cancelAnimationFrame = ((id: number) =>
|
||||
clearTimeout(id)) as unknown as typeof cancelAnimationFrame;
|
||||
}
|
||||
|
||||
import { APP_BASE_HREF } from '@angular/common';
|
||||
import { CommonEngine } from '@angular/ssr/node';
|
||||
import express from 'express';
|
||||
|
||||
Reference in new issue
Block a user