-
-
Notifications
You must be signed in to change notification settings - Fork 215
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
Example of Transcrypt, HyperApp, and SSR #597
Comments
In extension, I released a React demo yesterday, https://github.com/retsimx/TranscryptReact |
@pauleveritt @retsimx Note that to be in the next version of the distro, things would have to work with Transcrypt 3.7 and CPython 3.7, which I believe shouldn't pose too much problems. Kind regards |
@JdeH I'm interested in a conversation with you about server-side rendering. My perception: Transcrypt is for writing code that targets execution in JS, not both Python and JS. I'd like to first find out if dual-mode is interesting. If so, it brings up more questions. |
Hi, OK, a quick reaction, in anticipation of a more extensive conversation. I'd like to think that quite some code can be made to run both with Transcrypt and with CPython. On the other hand Transcrypt will never have full CPython semantics, as it would get too slow and complicated. There are projects like PyPyJs, that do, but at a cost. From the Transcrypt docs:
When run from the command line, it still introduces itself with Small Sane Subset compiler, although currently I am happy to say that's a severe understatement, TS compiles the bulk of Python. In short: I think dual-mode is certainly interesting! |
(long, sorry) Since you're interested, I'll continue by picking two specific places that I'm interested in.
Python web projects have a lot of complexity in templates, which are a pseudo-language without full CPython semantics. But they solve an old/wrong problem: giving "HTML Designers" a separate universe. As such, Python code quality tools (linters, black, mypy, coverage, etc.) can't help. Modern frontends have un-split this divide into "components" which unify logic, state, presentation, and even styling. I worked quite a bit on a component model for Jinja2 AST. Then realized, it was flawed. We need "templating" that works with the VDOM on the client, Python on the server, same template code. And preferably something where mypy can peek into the "template". Jinja2's AST isn't VDOM-oriented. Hence my interest in converting the
As others discussed, seamlessly plugging into Parcel and webpack lets frontend developers keep the file watching, on-the-fly transpire, browser reload, and HMR. It's crazy productive, if your target is the browser or NodeJS SSR. As a Pyramid guy, I'm interested in Python SSR. My GatsbyJS project has 500 MB in node_modules. It's insane. How much could get from SSR in Python, with zero NodeJS anywhere around? I think it's worth exploring:
Getting a webpack-devserver style setup for Python with Transpile is going to be some work. But it's do-able. |
I made a repo with some Sphinx docs as a step-by-step example of Transcrypt combined with HyperApp and Bottle to do server-side rendering:
https://github.com/pauleveritt/transcrypt_hyperapp_hydrate
Docs at:
https://transcrypt-hyperapp-and-ssr.readthedocs.io/en/latest/
This was intriguing to work on. Unlike other Transcrypt examples, this needed a codebase that could work in Python (first render) and JS (browser-side re-renders.) HyperApp is a great choice for this, since it is so tiny. Not only can you skip bundling altogether, you could reasonably port pieces of it to Python, so that the templating is not double-implemented. (I didn't get that far.)
Anyway, if you'd like, I could re-do this as a PR in your docs. I'd love to collaborate on a first-class story for SSR.
The text was updated successfully, but these errors were encountered: