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

Error using calcite components in Gatsby site during server-side rendering #7493

Closed
3 tasks done
noahmulfinger opened this issue Aug 9, 2023 · 3 comments
Closed
3 tasks done
Assignees
Labels
4 - verified Issues that have been released and confirmed resolved. ArcGIS Developer Experience Issues logged by ArcGIS Developer Experience team members. bug Bug reports for broken functionality. Issues should include a reproduction of the bug. calcite-components Issues specific to the @esri/calcite-components package. calcite-components-react Issues specific to the @esri/calcite-components-react package. estimate - 1 Very small fix or change (potentially a single line), doesn't require updates to tests. impact - p1 - need for current milestone User set priority impact status of p1 - need for current milestone p - high Issue should be addressed in the current milestone, impacts component or core functionality

Comments

@noahmulfinger
Copy link
Contributor

Check existing issues

Actual Behavior

When using calcite components 1.5.X on a page in a Gatsby site, the page throws an error during server-side rendering error "navigator" is not available during Server-Side Rendering. The stack trace takes me to the interactive.ts file where it is using navigator to check the user agent string:

const isFirefox = /firefox/i.test(getUserAgentString());
type ParentElement<T extends HTMLElement = HTMLElement> = T | null;
const interactiveElementToParent: WeakMap<InteractiveHTMLElement, ParentElement> | null = isFirefox
? new WeakMap()
: null;

Expected Behavior

I would expect a server-side rendered page in a Gatsby site (or other static site generator) to be able to render the components without throwing a build error.

Reproduction Sample

See devtopia documentation repo

Reproduction Steps

  1. Go to the documentation repo and check out the branch kit12303/update-150
  2. Run npm run build:afd
  3. After the build gets to the HTML rendering step, it will throw an error.

Reproduction Version

1.5.1

Relevant Info

No response

Regression?

1.4.3

Priority impact

p1 - need for current milestone

Impact

Blocks the developer documentation from being deployed for the 1.5 release.

Calcite package

  • @esri/calcite-components
  • @esri/calcite-components-react

Esri team

ArcGIS Developer Experience

@noahmulfinger noahmulfinger added bug Bug reports for broken functionality. Issues should include a reproduction of the bug. 0 - new New issues that need assignment. needs triage Planning workflow - pending design/dev review. labels Aug 9, 2023
@github-actions github-actions bot added impact - p1 - need for current milestone User set priority impact status of p1 - need for current milestone calcite-components Issues specific to the @esri/calcite-components package. calcite-components-react Issues specific to the @esri/calcite-components-react package. ArcGIS Developer Experience Issues logged by ArcGIS Developer Experience team members. labels Aug 9, 2023
@jcfranco jcfranco self-assigned this Aug 9, 2023
@jcfranco jcfranco added 2 - in development Issues that are actively being worked on. p - high Issue should be addressed in the current milestone, impacts component or core functionality estimate - 1 Very small fix or change (potentially a single line), doesn't require updates to tests. needs triage Planning workflow - pending design/dev review. and removed 0 - new New issues that need assignment. needs triage Planning workflow - pending design/dev review. labels Aug 9, 2023
@geospatialem geospatialem added this to the 1.5.2 patch - Bugs only milestone Aug 9, 2023
@geospatialem geospatialem removed the needs triage Planning workflow - pending design/dev review. label Aug 9, 2023
@jcfranco
Copy link
Member

After some additional research, I think the crux of this makes it a duplicate of #7486.

The commit that caused the Gatsby SSR build to start failing was 1.5.0-next.9. From the range of commits between 1.5.0-next.8 and 1.5.0-next.9, the change to enable includeImportCustomElements seemed like the most likely culprit. Thanks to @benelan's sleuthing, he confirmed that that feature was adding static imports from the components (where Stencil's isBrowser build flag is always true) output target to be pulled in early in the build process and causing errors about accessing client APIs that aren't available during SSR.

@jcfranco jcfranco added 3 - installed Issues that have been merged to master branch and are ready for final confirmation. and removed 2 - in development Issues that are actively being worked on. labels Aug 15, 2023
@github-actions github-actions bot assigned geospatialem and unassigned jcfranco Aug 15, 2023
@github-actions
Copy link
Contributor

Installed and assigned for verification.

@geospatialem geospatialem added 4 - verified Issues that have been released and confirmed resolved. and removed 3 - installed Issues that have been merged to master branch and are ready for final confirmation. labels Aug 15, 2023
@geospatialem
Copy link
Member

Verified in 1.6.0 with the documentation repo's kit12303/test branch at commit c60a528c0cd56818349301e4a6042f0871260621, only modifying the CC and CCR versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4 - verified Issues that have been released and confirmed resolved. ArcGIS Developer Experience Issues logged by ArcGIS Developer Experience team members. bug Bug reports for broken functionality. Issues should include a reproduction of the bug. calcite-components Issues specific to the @esri/calcite-components package. calcite-components-react Issues specific to the @esri/calcite-components-react package. estimate - 1 Very small fix or change (potentially a single line), doesn't require updates to tests. impact - p1 - need for current milestone User set priority impact status of p1 - need for current milestone p - high Issue should be addressed in the current milestone, impacts component or core functionality
Projects
None yet
Development

No branches or pull requests

3 participants