diff --git a/.eslintrc b/.eslintrc index e6dd07c..3ad659f 100644 --- a/.eslintrc +++ b/.eslintrc @@ -27,7 +27,8 @@ "globals": { "DEBUG": true, "process": true, - "Buffer": true + "Buffer": true, + "globalThis": true, }, "extends": "eslint:recommended", "parserOptions": { diff --git a/src/SourceMap.js b/src/SourceMap.js index e909671..a91b319 100644 --- a/src/SourceMap.js +++ b/src/SourceMap.js @@ -1,8 +1,8 @@ import { encode } from '@jridgewell/sourcemap-codec'; function getBtoa() { - if (typeof window !== 'undefined' && typeof window.btoa === 'function') { - return (str) => window.btoa(unescape(encodeURIComponent(str))); + if (typeof globalThis !== 'undefined' && typeof globalThis.btoa === 'function') { + return (str) => globalThis.btoa(unescape(encodeURIComponent(str))); } else if (typeof Buffer === 'function') { return (str) => Buffer.from(str, 'utf-8').toString('base64'); } else {