Library not working on a monorepo
andirsun opened this issue · 3 comments
andirsun commented
I am using this library in a mono repository that contains these project:
- Figma plugin
- Next js Project
The library works great for figma project but when I try to run Next js project I am facing this error (probably is a server side enviroment).
error - ReferenceError: window is not defined
at Object.<anonymous> (/Users/andirsun/projects/streamline/streamline-mono/node_modules/mixpanel-figma/mixpanel-patched.js:8:16)
...
...
...
So the error is happening here
// File mixpanel-patched.js
...
var window$1 = window;
...
andirsun commented
The mixpanel team fixed this error with this lines
// since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
var window$1;
if (typeof(window) === 'undefined') {
var loc = {
hostname: ''
};
window$1 = {
navigator: { userAgent: '' },
document: {
location: loc,
referrer: ''
},
screen: { width: 0, height: 0 },
location: loc
};
} else {
window$1 = window;
}
We have to upgrade this part of your patched library.
I pushed a PR with this Fix #5