Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document is not defined #2534

Closed
MarkLyck opened this issue Jun 2, 2020 · 2 comments
Closed

Document is not defined #2534

MarkLyck opened this issue Jun 2, 2020 · 2 comments
Assignees

Comments

@MarkLyck
Copy link

MarkLyck commented Jun 2, 2020

  • G2 Version:4.0.2
  • Platform: any
  • Mini Showcase(like screenshots):

Screen Shot 2020-06-02 at 5 05 01 PM

The Antvis G2 library fails when building it in Rollup, or if the package is simply imported in a setup like next.js, Gatsby, Meteor that does both server-side and client-side rendering.

As a user I would not expect G2 to try to render anything if no DOM is available.
As a user I would not expect G2 to fail if it's imported in a server-side environment, (simply do nothing or log a warning, but there should be no errors).

Please please add a simple safeguard check at the entry point of G2 that prevents the library from failing if it's read in a server-side environment.

Something like this:

if (!process.browser) {
  return undefined
}

This ticket is related to #296, but not asking for a workaround, requesting this to be fixed permanently for everyone allowing BizCharts to be bundled and at least not break when imported serverside.

This ticket is NOT about adding server-side rendering support! Please don't confuse this with a request to make G2 work serverside.

It just shouldn't break the build if document isn't available.

@adhope
Copy link

adhope commented Oct 13, 2020

ran into same,is there a solution?

@hustcc
Copy link
Member

hustcc commented Oct 14, 2020

just keep not throw on ssr?

@hustcc hustcc self-assigned this Dec 16, 2020
@hustcc hustcc added the browser label Jan 19, 2021
@hustcc hustcc closed this as completed Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants