v8go
quickjs-emscripten
v8go | quickjs-emscripten | |
---|---|---|
10 | 23 | |
3,183 | 1,279 | |
- | - | |
0.0 | 9.1 | |
2 months ago | 27 days ago | |
Go | TypeScript | |
BSD 3-clause "New" or "Revised" License | GNU General Public License v3.0 or later |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
v8go
-
SSR React in Go
Firstly, I used rogchap/v8go to execute JavaScript in a Go environment. I listed other options below.
-
I built a local Laravel dev environment that doesn't require PHP at all
Now the only issue I see is that someone who can't be bothered to install PHP and composer will probably not want to install node and npm either. If you could somehow run WASM inside an executable file (maybe something written in Go with https://github.com/rogchap/v8go ? Or an Electron App ?), all you'd need to do is download the executable file on any computer and double click it to start serving a Laravel project.
-
Show HN: A Full-Stack Web Framework Written in Go
I only browsed for a wee bit, so take this with some salt, but it _looks_ like the framework is running a JS VM isolate alongside the Go server struct[1], which gets called with whatever script file is being rendered. Since it looks like the render files are, at least in the case of Svelte, individually compiled JS files that are SSR rendered via the V8 isolate, I _believe_ you're correct that there is no CSR (though there might still be JS-hydrated code if the Svelte component included something involving an interactive component).
I think the idea is to ingest a JS "template" and spit out the rendered HTML+JS, kind of like traditional SSR templates, but it could be possible to shoe-horn in an entire client-side router that gets initialized as a DOM object somewhere.
[1] https://github.com/rogchap/v8go
- QuickJS JavaScript Engine – Fabrice Bellard
-
Using Javascript plugins in Go
https://github.com/rogchap/v8go is a viable option these days as well.
- Execute JavaScript from Go - JS functions with Go callbacks, update JS objects from Go & more
- V8go v0.5.0 Execute JavaScript from Go
- v8go: JavaScript in Go - v0.5.0 released 🎉 Global Objects, Function Templates, Go callbacks and loads more!
-
Plenti — a Svelte SSG for people that don’t like web maintenance bullsh#t
Plenti is a simple open source Static Site Generator (SSG) with a Go backend and Svelte frontend. Jim picked Golang because it is simple, quick and has the ability to generate a binary that can be run on any machine; and Svelte, well, for one, “Svelte is so hot right now” and also because of the power it gives developers to write simple HTML and CSS to create websites. Merging these two technologies was not an easy task, but with V8Go binding the two together, it’s a marriage that works.
- Execute JavaScript from Go
quickjs-emscripten
-
Execute JavaScript in a WebAssembly QuickJS Sandbox
The foundation of my package is built upon the excellent work done by the quickjs-emscripten project (https://github.com/justjake/quickjs-emscripten). They've done the crucial work of compiling QuickJS to WebAssembly, enabling its use in web and Node.js environments. What I've created is a high-level abstraction layer around this WebAssembly implementation, designed with developer experience in mind.
The underlying quickjs-emscripten library has APIs for exposing host functions, calling guest functions, custom module loaders, etc: https://github.com/justjake/quickjs-emscripten?tab=readme-ov...
- New QuickJS Release
-
Extism Makes WebAssembly Easy
The thing I want to achieve with WebAssembly is still proving a lot harder than I had anticipated.
I want to be able to take strings of untrusted code provided by users and execute them in a safe sandbox.
I have all sorts of things I want this for - think custom templates for a web application, custom workflow automation scripts (Zapier-style), running transformations against JSON data.
When you're dealing with untrusted code you need a really robust sandbox. WebAssembly really should be that sandbox.
I'd like to support Python, JavaScript and maybe other languages too. I want to take a user-provided string of code in one of those languages and execute that in a sandbox with a strict limit on both memory usage and time taken (so I can't be crashed by a "while True" loop). If memory or time limit are exceeded, I want to get an exception which I can catch and return an error message to the user.
I've been exploring options for this for quite a while now. The furthest I've got was running Pyodide inside of Deno: https://til.simonwillison.net/deno/pyodide-sandbox
Surprisingly I've not found a good pattern for running a JavaScript interpreter in a WASM sandbox yet. https://github.com/justjake/quickjs-emscripten looks promising but I've not found the right recipe to call it from server-side Python or Deno yet.
Can Extism help with this? I'm confident I'm not the only person who's looking for a solution here!
-
Node on Web. Use Nodejs freely in your browser with Linux infrastructure.
"Safely execute untrusted Javascript in your Javascript, and execute synchronous code that uses async functions" quickjs-emscripten, NPM
-
Sandboxing JavaScript Code
This maybe, as a start?
https://github.com/justjake/quickjs-emscripten
-
Hacker News top posts: Nov 20, 2022
QuickJS Running in WebAssembly\ (17 comments)
-
QuickJS Running in WebAssembly
The library was inspired by Figma’s blog posts about their plug-in system: https://github.com/justjake/quickjs-emscripten#background
-
Show HN: Run unsafe user generated JavaScript in the browser
If you need to call into user-generated Javascript synchronously or have greater control over the sandbox environment, you can use WebAssembly to run a Javascript interpreter: https://github.com/justjake/quickjs-emscripten#quickjs-emscr...
QuickJS in WebAssembly is much slower than your browser's native Javascript runtime, but possibly faster than async calls using postMessage. As an added bonus, it can make async functions in the host appear to be synchronous inside the sandbox using asyncify: https://emscripten.org/docs/porting/asyncify.html.
What are some alternatives?
goja - ECMAScript/JavaScript engine in pure Go
wasmtime - A fast and secure runtime for WebAssembly
deno - A modern runtime for JavaScript and TypeScript.
wasmer - 🚀 The leading Wasm Runtime supporting WASIX, WASI and Emscripten
quickjs - Public repository of the QuickJS Javascript Engine.
wizer - The WebAssembly Pre-Initializer
bud - The Full-Stack Web Framework for Go
rr - Record and Replay Framework
txiki.js - A tiny JavaScript runtime
mach - zig game engine & graphics toolkit
plenti - Static Site Generator with Go backend and Svelte frontend
iPlug2 - C++ Audio Plug-in Framework for desktop, mobile and web