Skip to content

AnalyticalTable: Build fails during build page pre-render generation in NextJS apps after upgrading webcomponents-react package version #8095

@Svetoslav99

Description

@Svetoslav99

Describe the bug

When we tried to upgrade from version 2.15.0 -> latest webcomponents-react package, we were hit with this issue during build execution of our NextJS pages router app.

I saw that on empty template project, it works with no issues, but the moment you add AnalyticalTable component, it starts to fail.

Error in the console during "npm run build" execution:

Generating static pages using 9 workers (0/3)  [=== ]ReferenceError: document is not defined
    at ignore-listed frames
Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
ReferenceError: document is not defined
    at ignore-listed frames
Export encountered an error on /, exiting the build.
⨯ Next.js build worker exited with code: 1 and signal: null

I suppose that there is a missing if-guard somewhere in AnalyticalTable which uses the browser 'document', that should not be executed during pre-rendering on the node environment. I hope it is an easy fix. And since it was working until now, after I saw the changelog, I guess its an error since 2.16.0 onwards.

For the moment this blocks us from actually upgrading the version until it gets fixed.

Isolated Example

no example, its straight forward and the stackblitz template is vite based)

Reproduction steps

  1. "npx degit UI5/webcomponents-react/templates/nextjs-pages#main my-project" to download your template for NextJS pages router project
  2. cd my-project
  3. npm i
  4. npm run build (observe how the build will finalize with no issues)
  5. Add small configured AnalyticalTable component in /pages/index.tsx (you can use some examples from your docs for dummy data AnalyticalTable that you know should work).
  6. re-run "npm run build"
  7. Observe how the build now fails with the described error.

Expected Behaviour

The build should finish successfully.

Screenshots or Videos

Image

UI5 Web Components for React Version

2.18.1

UI5 Web Components Version

2.18.1

Browser

Chrome

Operating System

macOS

Additional Context

No response

Relevant log output

Generating static pages using 9 workers (0/3)  [=== ]ReferenceError: document is not defined
    at ignore-listed frames
Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
ReferenceError: document is not defined
    at ignore-listed frames
Export encountered an error on /, exiting the build.
⨯ Next.js build worker exited with code: 1 and signal: null

Organization

No response

Declaration

  • I’m not disclosing any internal or sensitive information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions