SSR Fails if module uses top-level await or imports module using top-level await #9468
Closed
2 of 7 tasks
Labels
bug
An error in the Docusaurus core causing instability or issues with its execution
closed: duplicate
This issue or pull request already exists in another issue or pull request
Have you read the Contributing Guidelines on issues?
Prerequisites
npm run clear
oryarn clear
command.rm -rf node_modules yarn.lock package-lock.json
and re-installing packages.Description
Usage of top-level await in a component rendered as part of a docusaurus page leads to server-side rendering errors (but works on client side).
This was first encountered when importing an ES module using top-level await, but the same behavior can be replicated by adding a top-level await statement to the default
pages/index.tsx
. We get a separate error if we try to mark the example app as an ES module, but bypassing that, we get this same issue from importing the component. It looks like webpack may apply transformations automatically when encountering top level await. https://webpack.js.org/configuration/experiments/#experimentstoplevelawaitReproducible demo
https://github.com/NickGerleman/docusaurus-await-repro
Steps to reproduce
pages/index.tsx
in a new Docusaurus V3 appyarn build --dev
Expected behavior
Build succeeds
Actual behavior
Your environment
Docusaurus version: 3.0.0-rc.1
Node version: v18.16.1
Self-service
The text was updated successfully, but these errors were encountered: