ecomfe/echarts-liquidfill

nextjs 下报 ReferenceError: self is not defined

nshen opened this issue · 3 comments

nshen commented
ReferenceError: self is not defined
    at Object.<anonymous> (/home/nn/github/nextV/node_modules/echarts-liquidfill/dist/echarts-liquidfill.js:10:4)
"echarts": "5.1.0",
"echarts-for-react": "^3.0.1",
"echarts-gl": "^2.0.8",
"echarts-liquidfill": "3.1.0",

The same thing is happening to me, but with other libs! I do not yet know how to fix that error.

nshen commented

hi @mysticaltech this is due to ssr ssg relative things, I solved by dynamic import it

// fix ssr error
if (isClient()) {
  // @ts-ignore
  import('echarts-liquidfill');
}
/**
 * nextjs-utils
 */
export function isClient(): boolean {
  return typeof window !== 'undefined';
}

Thanks for the info, my problem is that I do not even know where the issue comes from as tracing is not showing anywhere! Also not using this very library the issue belongs to.

ksnip_20211201-164101