@@ -163,18 +163,28 @@ const setUpEdgeFunction = async ({ angularJson, constants, failBuild, usedEngine
163163 const browserDistFolder = resolve(serverDistFolder, 'browser');
164164
165165 if (typeof Deno !== 'undefined') {
166- // fs.readFile is not supported in Edge Functions, so this is a workaround for CSS inlining
167- // that will intercept readFile attempt and if it's a CSS file, return the content from the manifest
168- const originalReadFile = globalThis.Deno.readFile
169- globalThis.Deno.readFile = (...args) => {
170- if (args.length > 0 && typeof args[0] === 'string') {
171- const relPath = relative(browserDistFolder, args[0])
172- if (relPath in cssAssetsManifest) {
173- return Promise.resolve(Buffer.from(cssAssetsManifest[relPath], 'base64'))
166+ try {
167+ // fs.readFile is not supported in Edge Functions, so this is a workaround for CSS inlining
168+ // that will intercept readFile attempt and if it's a CSS file, return the content from the manifest
169+ const originalReadFile = globalThis.Deno.readFile
170+ globalThis.Deno.readFile = (...args) => {
171+ try {
172+ if (args.length > 0 && typeof args[0] === 'string') {
173+ const relPath = relative(browserDistFolder, args[0])
174+ if (relPath in cssAssetsManifest) {
175+ return Promise.resolve(Buffer.from(cssAssetsManifest[relPath], 'base64'))
176+ }
177+ }
178+ } catch {
179+ // reading file is needed for inlining CSS, but failing to do so is
180+ // not causing fatal error so we just ignore it here
174181 }
182+
183+ return originalReadFile.apply(globalThis.Deno, args)
175184 }
176-
177- return originalReadFile.apply(globalThis.Deno, args)
185+ } catch {
186+ // reading file is needed for inlining CSS, but failing to do so is
187+ // not causing fatal error so we just ignore it here
178188 }
179189 }
180190
0 commit comments