fix: prevent failing in worker (#1478)

This commit is contained in:
Andrew Tatomyr
2024-03-14 13:52:25 +02:00
committed by GitHub
parent 27657e56c6
commit f2cc3f28be
2 changed files with 8 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
"@redocly/openapi-core": patch
---
Added a platform check so `@redocly/openapi-core` can support running inside a worker.

View File

@@ -1,5 +1,7 @@
export const isBrowser = export const isBrowser =
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore // @ts-ignore
typeof window !== 'undefined' || typeof process === 'undefined'; // main and worker thread typeof window !== 'undefined' ||
typeof process === 'undefined' ||
(process?.platform as any) === 'browser'; // main and worker thread
export const env = isBrowser ? {} : process.env || {}; export const env = isBrowser ? {} : process.env || {};