TypeFox / monaco-languageclient

Repo hosts npm packages for monaco-languageclient, vscode-ws-jsonrpc, monaco-editor-wrapper, @typefox/monaco-editor-react and monaco-languageclient-examples
https://www.npmjs.com/package/monaco-languageclient
MIT License
1.06k stars 177 forks source link

Warning against SSR frameworks should be added. #764

Open caner-cetin opened 1 week ago

caner-cetin commented 1 week ago

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

CGNonofr commented 1 week ago

A notice can't hurt.

I'm not really familliar with SSR but I wouldn't expect a library with so many possible user interactions to be SSR-compatible though

kaisalmen commented 2 days ago

@CGNonofr and @caner-cetin any idea how this should be done/implemented? Of course, we can state it in the README.md: Should there be some warning at build or runtime (if that is even possible)