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

I can't use it with Docusaurus v2 #69

Open
seyoon20087 opened this issue Oct 2, 2021 · 2 comments
Open

I can't use it with Docusaurus v2 #69

seyoon20087 opened this issue Oct 2, 2021 · 2 comments
Labels
bug Something isn't working upstream Bug or enhancement in upstream package

Comments

@seyoon20087
Copy link

seyoon20087 commented Oct 2, 2021

Environment Info:

  • npm: 7.24.0
  • yarn: 3.0.2 (berry)

Hello,

When I try to compile my Docusaurus v2 site (based on React) with your dependency, I get this error:

$ yarn run build
[en] Creating an optimized production build...
[info] [webpackbar] Compiling Client
[info] [webpackbar] Compiling Server
[success] [webpackbar] Client: Compiled successfully in 23.90s
Docusaurus Node/SSR could not render static page with path "/" because of following error:
ReferenceError: document is not defined
    at enableDismissTrigger (main:5763:19)
    at Module.9522 (main:5858:1)
    at __webpack_require__ (main:60951:42)
    at main:1596:116
Pro tip: It looks like you are using code that should run on the client-side only.
To get around it, try using <BrowserOnly> (https://docusaurus.io/docs/docusaurus-core/#browseronly) or ExecutionEnvironment (https://docusaurus.io/docs/docusaurus-core/#executionenvironment).
It might also require to wrap your client code in useEffect hook and/or import a third-party library dynamically (if any).
[success] [webpackbar] Server: Compiled with some errors in 26.57s
Error: Server-side rendering fails due to the error above.
Unable to build website for locale "en".
Error: Failed to compile with errors.
    at /builds/seyoon20087/seyoon20087-github-io/node_modules/@docusaurus/core/lib/webpack/utils.js:203:24
    at /builds/seyoon20087/seyoon20087-github-io/node_modules/webpack/lib/MultiCompiler.js:554:14
    at processQueueWorker (/builds/seyoon20087/seyoon20087-github-io/node_modules/webpack/lib/MultiCompiler.js:491:6)
    at processTicksAndRejections (node:internal/process/task_queues:78:11)

The full log is available in this gist.

If this could be resolved, it would be very helpful to me.

@RyanBerliner
Copy link
Owner

Thank you for submitting your issue and linking to further logs. It looks like the important part of this error is here

ReferenceError: document is not defined
    at enableDismissTrigger (main:5763:19)
    at Module.9522 (main:5858:1)
    at __webpack_require__ (main:60951:42)
    at main:1596:116

This function enableDismissTrigger is in the core bootstrap library. So, I searched for SSR issues in bootstrap and came across twbs/bootstrap#34265. It appears the problem you are encountering is that bootstrap's bundle is not SSR compatible. This issue will likely need to be resolved upstream in bootstrap itself, though it might be possible to work around the issue in this package by being smart about when it initialize's bootstraps components. I'll play around with it soon, and keep this issue open until I've found a definitive answer. Until then, I'd recommend tracking twbs/bootstrap#34265 and showing interest in that feature.

@RyanBerliner RyanBerliner added bug Something isn't working upstream Bug or enhancement in upstream package labels Oct 2, 2021
@TCB13
Copy link

TCB13 commented Apr 13, 2023

This function enableDismissTrigger is in the core bootstrap library

Apparently there's also defineJQueryPlugin that calls onDOMContentLoaded causing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream Bug or enhancement in upstream package
Projects
None yet
Development

No branches or pull requests

3 participants