Sandpack / nodebox-runtime

Nodebox is a runtime for executing Node.js modules in the browser.
https://sandpack.codesandbox.io/docs/advanced-usage/nodebox
Other
710 stars 37 forks source link

Feedback: Yarn #2

Open arcanis opened 1 year ago

arcanis commented 1 year ago

Really nice work! I threw together a quick demo of trying to run an unmodified build of Yarn within Nodebox; it almost works, which would be incredibly useful for writing tutorials for our website! Here are some of my findings:

blockers

workarounds

nits

DeMoorJasper commented 1 year ago

Thanks for testing nodebox and providing such a detailed issue/beautiful demo, this is incredibly valuable. I'll work my way through this list later today and hopefully have everything fixed by tonight, will keep you updated.

Update: the issues with shell.stderr/shell.stdout have been fixed, now all console/process output should be forwarded correctly, tested it on your demo and that part seems fixed.

DeMoorJasper commented 1 year ago

A small end of day update here, we now support brotli, implemented the skeleton of http/2 (will implement more of it next week), got past all the errors described in this issue and now seems like it needs worker_threads which was already planned for implementation next week to support nuxt

Regarding environment variables, you can define those when calling runCommand: https://github.com/codesandbox/nodebox-runtime/blob/main/packages/nodebox/api.md#shellruncommandbinary-args-options

Hoping to get this working next week, really excited to see your nice demo work perfectly

merceyz commented 1 year ago

It'd be nice to have an helper function doing the equivalent of new Promise((resolve) => shell.on(exit, resolve));

Wouldn't events.once cover that? https://nodejs.org/dist/latest-v19.x/docs/api/events.html#eventsonceemitter-name-options

arcanis commented 1 year ago

Thanks for the speedy improvements, Jasper!

Wouldn't events.once cover that?

I meant that "wait for a process to exit before spawning another" is a common enough need (especially given that shells don't currently support more than one process) that it might be worth a dedicated function to avoid having to manually bind the events (which works, but is more error prone and perhaps a little harder to discover).

arcanis commented 1 year ago

Quick note: I noticed there's been a regression that makes new URL('npm:1.2.3').pathname === "//1.2.3", instead of "1.2.3": https://codesandbox.io/p/sandbox/vanilla-nodebox-forked-uhqmt1

DeMoorJasper commented 1 year ago

Thanks for reporting that regression, just merged a fix for it, should be on production in a couple minutes

arcanis commented 1 year ago

Indeed! And I see you've started to implement worker support, very nice 👍

I think we're now hitting the problem in https://github.com/codesandbox/nodebox-runtime/issues/22#issuecomment-1457951172: eval: true as worker parameter is ignored, so the worker is invalid and the install hangs (it also seems like an invalid path / file doesn't throw an exception, hiding the issue).

arcanis commented 10 months ago

I got Yarn working, but the following warning messes with the output:

"OutgoingMessage#setTimeout" is not yet implemented. Please file an issue on GitHub.