#Nodepod: Open-source Node.js runtime for the browser

45 messages · Page 1 of 1 (latest)

viscid pawn
#

I’ve been working on a runtime to execute Node.js environments entirely within a web page. It’s similar to WebContainers but lightweight, framework-agnostic, and fully open-source (MIT + Commons Clause).

I originally built this for my AI platform (Scelar) to eliminate cloud infrastructure costs by moving compute to the client, but we decided to open-source the underlying engine.

The screenshot below shows Qwik running natively in the browser inside a web-IDE (Web IDE made to look like the Zed Code editor) I built to test the runtime.

We are open sourcing it in a sort of 'beta' state.

Playground (Zed-Like Web-IDE): https://wzed.scelar.com
Repo (Stars appreciated): https://github.com/ScelarOrg/Nodepod
Technical Blog Post: https://scelar.com/blog/introducing-nodepod

long geyser
#

I will check it out 😄

viscid pawn
#

I appreciate that! It's still an early build right now so don't expect too much, but I plan on fixing every issue I find and making it a actual complete nodejs enviroment.

long geyser
#

That’s my main concern

#

Ah i see you mention vite already in the blog post

viscid pawn
#

Yeah, there's some polyfills to make certain native nodejs packages work, but alot of packages work out of the box, also rolldown is auto-replaced with rollup because rolldown is rust based and just won't work in a browser environment (rollup does tho)

long geyser
#

For example oxc-parser

#

I guess it would be wasm for those cases?

viscid pawn
#

Yeah, but Ill do some testing to make sure qwik is completely compatible. If not, I'll make sure it will be.

long geyser
#

qwik is a vite plugin that uses napi

#

but most frameworks that have a compiler run into a similar setup

#

for example vue, angular (as of last week)

#

there are probably others I don't know of 😅

#

Let me know if I should make an issue on github for this cat_salute

viscid pawn
#

Yeah that would really appreciated 👍

long geyser
viscid pawn
#

Thank you! ill start looking into it.

viscid pawn
#

Ive been researching napi-rs a little and ive been testing some stuff, its still experimental but i was able to achieve the same result Webcontainers/stackblitz was 'https://stackblitz.com/github/hi-ogawa/reproductions/tree/main/oxc-wasi-vite'.

In the stackblitz link they're showcasing running oxc-parser in the browser, i was able to use the same demo code as they have (the files in the their playground) and achieve the same result, with about a ~30% increase in performance/speed. (i did not run concrete tests, but i did run it a few times and it ran substantially faster then on stackblitz's webcontainers, but that might just be their playgrounds latency.)

#

napi-rs plugins will work in Nodepod if they have a wasm variant

long geyser
viscid pawn
long geyser
viscid pawn
#

That's truly amazing to hear. Do expect errors or unusual behavior tho, it's not perfect yet. But any issue that's reported will be fixed. Atm using qwikcity it will error out and ask you to install a wasm version of sharp, when done it will run fine. Still trying to find out how I can make a package like sharp automatically decide it needs to use the wasm version.

long geyser
#

It can't really be removed as people rely on the image transformations, but we will eventually improve it haha

viscid pawn
#

Interesting, well it's not a 'real' issue since you will be simply prompted to install the wasm version, and once done it works fine. So it's not really a problem, again, I will however try to find a solution on the auto-resolving to wasm build. Which will remove the prompting for sharp-wasm completely.

long geyser
long geyser
#

@viscid pawn curious on if you saw the recent announcement for vfs in node. Seems they have a polyfill (hopefully can be used in browser 🤞 ). I don't need it but might be needed elsewhere

#

Also heads up I have started playing with nodepod a little bit, my assumption is that it will break where rolldown diverges from rollup, but will make sure of that 😄

In which case an opt-in rolldown wasm bundle might be needed

viscid pawn
#

Yeah somebody else asked me to implement that some time back, I did some research on it, don't think it will be possible tho, since that vfs implemention is built on cpp bindings and to make it even worse it's also connected to other nodejs internals, so yeah it's just not meant to be used in the browser, our current implementation is simpler, more compatible and just better in general.

This was about 2 weeks ago, so they might've changed how it works, but I still don't think they would go as far as to make it web-compatible (because, why would they?)

viscid pawn
# long geyser Also heads up I have started playing with nodepod a little bit, my assumption is...

That's cool, uhm just letting you know, due to the latest vite 8 release, our rolldown polyfill is not compatible with it. This prompted me to improve the napi-rs support, so I'm currently experimenting with proper wasm loading, os-level workers for inside the browser, and some other things. I expected everything to work out of the box with the wasi polyfill I added a week back, but i may have been wrong about that 🤔 .

#

Trying to make it so we don't need the actual rolldown polyfill. They do have a wasm variant ( I think it was specifically made for webcontainers) we can access that by tricking the code into thinking we are inside a webcontainer. But the loading of the wasm isn't properly working yet.

long geyser
viscid pawn
#

Quick update on the vite 8/rolldown situation, after lots of experimenting and messing around, i finally got it working! the native rolldown wasm binary now runs fully inside nodepod. no more rolldown polyfill needed. turns out the wasm binary's resolver and file loading couldn't access our virtual filesystem through wasi, so i had to wire up js fallbacks for resolve and load, plus fix how napi-rs worker threads spawn in the browser. the oxc typescript transformer runs natively through wasi now too, reads tsconfig and everything. took a bit of back and forth but vite 8 dev server boots up and serves pages with the real rolldown pipeline

#

Im still doing some checks and stuff, but itl be up on github sometime this weekend (i hope)

viscid pawn
#

note: previously we also had polyfills enabled for tailwindcss and tailwind oxide, they both now also seem to work inside the browser without being stubbed, faked, mocked, or polyfilled, just pure wasi loading.

viscid pawn
#

The update has been a little bit delayed due to health issues, will try to push it this week

long geyser
viscid pawn
#

Hey, really sorry for the long silence, things got way busier than I expected. Good news though: I got back into nodepod this week, fixed a bunch of issues, and rewrote the WASI/WASM implementations.
Previously we could only run Vite + vanilla TS/HTML, but now we should support pretty much everything. The implementation is still in beta, but out of the box it's already handling a lot of WASI/WASM scenarios cleanly. Pushing it up today or tomorrow. (i hope)

viscid pawn
#

Because we have rolldown support now, some frameworks like vue now by default work in vite 8. (Love that lol)