diff --git a/lib/browser/polyfills.ts b/lib/browser/polyfills.ts index b24fa343d..3a2e6b82c 100644 --- a/lib/browser/polyfills.ts +++ b/lib/browser/polyfills.ts @@ -2,16 +2,18 @@ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ - import buffer from 'buffer'; import process from 'process'; // Workaround to get mqtt-js working with Webpack 5 -if (window) { - (window as any).Buffer = buffer.Buffer; - (window as any).process = process; - // NodeJS global shim workaround for Angular - (window as any).global = window; +if (typeof self !== 'undefined') { + (self as any).Buffer = buffer.Buffer; + (self as any).process = process; + + if (self.window) { + // NodeJS global shim workaround for Angular + (self.window as any).global = window + } } export {};