Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling static import into serverside code #3640

Open
stevejpurves opened this issue Nov 23, 2022 · 4 comments
Open

Enabling static import into serverside code #3640

stevejpurves opened this issue Nov 23, 2022 · 4 comments

Comments

@stevejpurves
Copy link
Contributor

stevejpurves commented Nov 23, 2022

Problem

It is currently not possible to statically import ipywidgets into a platform like remix.run or next.js because of module side effects. The objective is not to enable SSR using jupyter widgets, but instead to reduce the friction of using them in frameworks that do SSR.

This is related to open issues in JupyterLab and Lumino here:

Proposed Solution

Bring in the change suggested in this comment:

const ElementProto: any = Element.prototype; // : typeof Element = (typeof Element !== 'undefined' && Element.prototype) || {};

and work though any implications of that.

@maartenbreddels
Copy link
Member

The objective. is not the enable SSR using jupyter widgets

Our of curiosity, do you know what that would entail? I'm not sure of all SSR techniques, my guess is that using React, it's simply a different renderer right? But if we do DOM manipulation, that would be more challenging.

@stevejpurves
Copy link
Contributor Author

@maartenbreddels yes, exactly. You're still rendering in React (or some framework) but are essentially rendering to a string. For react, I think it's basically the same renderer but only a single render pass occurs on the server (no side effects), then string is then sent to the client for "hydration" and smooth hydration is the trickier part.

For ipywidgets, maybe the valuable case for SSR would be something akin to serialized widget state and how the HTMLManager allows this to be "hydrated" on a standalone page without a kernel? -- if he initial html can be generated without the DOM proper.

@maartenbreddels
Copy link
Member

Yes, thanks for confirming that. We are thinking about some form of SSR for https://github.com/widgetti/solara/ but we're not sure of the form yet. I was wondering if there may be SS dom implementations, but it seems most SSR methods avoid the DOM I guess.

@stevejpurves
Copy link
Contributor Author

yes, the SSR i'm used to is about optimizing that initial page load and then deferring to post-hydration client side code to add interactivity.

Perhaps there is a special case around ipywidgets though, where something like jsdom can enable a static rendering of widgets (like the web examples & HTMLManager does for embedded state+view) to create that initial experience of having a bunch of widgets rendered and visible, then the trick would be how to transition from that html, to some level of immediate interactivity in on the page, like sliders working, jslnk working...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants