Closed sai-cb closed 6 months ago
globalThis is only compatible with Chrome 71 or above, lower versions are not compatible。
It is recommended to make it compatible
const getGlobal = function () {
if (typeof self !== "undefined") {
return self;
}
if (typeof window !== "undefined") {
return window;
}
if (typeof global !== "undefined") {
return global;
}
throw new Error("unable to locate global object");
};
This library can be imported under node.js for SSR projects (even though it is not actually used).
Because perfume.js is referring to "window" which does not exist under node.js, this is currently causing a crash.
This PR is addressing that issue by using globalThis (which refers to window in browsers, and global in node).