Skip to content
14 changes: 8 additions & 6 deletions lib/browser/polyfills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};