docusaurus: Failed to deploy: Reference error self is not defined
๐ Bug Report
I get a ReferenceError in Webpack while running yarn build to deploy the Hermes website.
I think itโs due to monaco-editor-webpack-plugin but Iโm not sure.
Have you read the Contributing Guidelines on issues?
Yes
To Reproduce
Note: I setup a branch that has the required hermes.js files weโre only adding to the gh-pages branch during deploys.
- Clone my branch here: https://github.com/rickhanlonii/hermes/tree/rh-deploy-hermes
cd websiteyarn build- Observe error
Expected behavior
- Build completes, site deploys
Actual Behavior
Your Environment
- Docusaurus version used: 2.0.0-alpha.43
- Environment name and version (e.g. Chrome 78.0.3904.108, Node.js 10.17.0): Node 12.9.1
- Operating system and version (desktop or mobile): macOS
Reproducible Demo
https://github.com/rickhanlonii/hermes/tree/rh-deploy-hermes
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 24 (10 by maintainers)
I have a similar issue when importing the Redoc React Component (https://github.com/Redocly/redoc#usage-as-a-react-component). The error only occurs when Iโm actually importing the component.
My workaround was
That said, is there any way to bypass or disable the SSR bundle? That may not be the right way to ask that question, but I just want a client bundle that I can deploy.
Thanks @lex111, I verified that that fixed the issue and deployed the site. PR is here https://github.com/facebook/hermes/pull/204
For D2, is there a way we can surface these errors with an explanation of how to fix? If I got an error that told me the issue was that I broke server side rendering I may have been able to fix this myself.
@mharsat Itโs usually happen because of SSR related issues. You can bypass that by loading those only for client side.
I did something like that: https://github.com/dotansimha/graphql-code-generator/blob/master/website/src/components/live-demo/Editor.js#L1-L4
@yangshun
<Suspense>andReact.lazyfail to buildSolved my issue as well - re: Redoc barfing.
Thanks everybody!
@jonnynabors the workaround is along the lines of what I would recommend. Refer to https://github.com/facebook/hermes/pull/204/files for the recommended solution of using
<Suspense>andReact.lazyto lazily import the modules.Nope. But we could consider adding that although we rather try to solve the problems that emerge along the way.
Iโm having the same issue, but with
navigator. The error is:startworks fine, it only happens withbuild. I guess one of the deps in not compatible with SSR? but the error is not helpful ๐ฆUpdate: In my issue, it was CodeMirror, and I added a conditional loading:
If you are experiencing this issue with the latest v2, try to comment / replace with a dummy some of your components and see if it help, then try to find the cause for it.