@@ -58,14 +58,23 @@ const setUpEdgeFunction = async ({ angularJson, projectName, netlifyConfig, cons
58
58
59
59
globalThis.process = process
60
60
globalThis.global = globalThis
61
+ globalThis.DenoEvent = globalThis.Event // storing this for fixup-event.mjs
62
+ `
63
+
64
+ // angular's polyfills override the global `Event` with a custom implementation.
65
+ // Deno local doesn't like that and will throw in local dev while dispatching `new Event("load")`.
66
+ // So we reverse angular's override, and go back to Deno's implementation.
67
+ const fixupEvent = `
68
+ globalThis.Event = globalThis.DenoEvent
61
69
`
62
70
63
71
const ssrFunction = `
64
72
import "./polyfill.mjs";
65
73
import { Buffer } from "node:buffer";
66
74
import { renderApplication } from "${ toPosix ( relative ( edgeFunctionDir , serverDistRoot ) ) } /render-utils.server.mjs";
67
75
import bootstrap from "${ toPosix ( relative ( edgeFunctionDir , serverDistRoot ) ) } /main.server.mjs";
68
-
76
+ import "./fixup-event.mjs";
77
+
69
78
const document = Buffer.from(${ JSON . stringify (
70
79
Buffer . from ( html , 'utf-8' ) . toString ( 'base64' ) ,
71
80
) } , 'base64').toString("utf-8");
@@ -88,6 +97,7 @@ const setUpEdgeFunction = async ({ angularJson, projectName, netlifyConfig, cons
88
97
`
89
98
90
99
await writeFile ( join ( edgeFunctionDir , 'polyfill.mjs' ) , polyfills )
100
+ await writeFile ( join ( edgeFunctionDir , 'fixup-event.mjs' ) , fixupEvent )
91
101
await writeFile ( join ( edgeFunctionDir , 'angular-ssr.mjs' ) , ssrFunction )
92
102
}
93
103
0 commit comments