docusaurus: š Prerendering fails when dependency includes `new URL('empty.js', import.meta.url);`
š Feature:
Some mechanism to avoid loading modules which are incompatible with prerendering
Have you read the Contributing Guidelines on issues?
Yes
Motivation
Iām working on adding a āplaygroundā page to the https://relay.dev docs, and that requires pulling in a Wasm module generated by wasm-pack. This module is incompatible with prerendering in multiple ways:
- References globals which are only available on Web.
- References import.meta.url.
I tried making this module import a lazy import (using import(moduleName)
) and conditionally only importing it if ExecutionEnvironment.canUseDOM
) is true, but it still seems to parse the module and error.
Pitch
It would be useful if there was some way to conditionally import the module in such a way that it would not be parsed/validated/run when doing prerendering. (Ideally this could be done without forcing the import to become a runtime import).
If thatās not feasible, another option would be a way to specify (via config?) that a given route should not be prerendered at all.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17
Will take a look tomorrow.
Can you tell me which error you had exactly?
Can you show me a successful integration of your playground in another React App that I could try to port to Docusaurus?
Webpack 5 definitively process new URL() as part of its new asset system
Le lun. 7 juin 2021 à 22:10, Jordan Eldredge @.***> a écrit :
Sorry but I still canāt understand where the files should be created exactly.
A repro would really help, you can also open a PR modifying the docusaurus site itself.
At least please provide absolute paths, not just the filenames.
Le mer. 9 juin 2021 à 22:38, Jordan Eldredge @.***> a écrit :