monaco-languageclient icon indicating copy to clipboard operation
monaco-languageclient copied to clipboard

Warning against SSR frameworks should be added.

Open caner-cetin opened this issue 1 year ago • 1 comments

maybe there is a warning and I havent seen it, but server side rendering breaks everything completely. I have only tried with NextJS, Remix.

import '@codingame/monaco-vscode-python-default-extension';

required for syntax highlighting, accesses window when imported. To disable SSR when loading, next/dynamic is used in NextJS, and it does not even load the extension, Remix can use lazy from React, but it straight doesnt work as it isnt a top level import.

import { MonacoEditorReactComp } from '@typefox/monaco-editor-react';

accesses window when imported, so I cant tuck the component in <ClientOnly /> at Remix, and I cant add the import before <ClientOnly /> because outside of <ClientOnly /> there is no way to know if we are in SSR right now. Same applies for NextJS.

I can pile up tons of examples like this, almost every codingame library accesses window when imported. I have spent at least 8+ hours on trying to make everything work with Remix, but in the end it always ends up in messy hacks that doesnt even guarantee working.

sooo, I think, a small warning to the readme should be added like

"server side rendering might not work"

until a sane way to run with SSR is found and submitted in packages/examples.

ty

caner-cetin avatar Oct 13 '24 13:10 caner-cetin