-
-
Notifications
You must be signed in to change notification settings - Fork 463
-
Is it possible to port your library to javascript?
Is it possible to port your library to WASM and use in NodeJS / Browser?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 3 comments 5 replies
-
Is it possible to port your library to javascript?
Yes.
Is it possible to port your library to WASM and use in NodeJS / Browser?
Yes. Here is an example: https://expr.medv.io/playground
Beta Was this translation helpful? Give feedback.
All reactions
-
❤️ 1 -
👀 1
-
Yes. Here is an example: https://expr.medv.io/playground
How can i compile and run expression? Like in golang but in nodejs/browser
Beta Was this translation helpful? Give feedback.
All reactions
-
Yes. Here is an example: https://expr.medv.io/playground
How can i compile and run expression? Like in golang but in nodejs/browser
O, i see Result field
Beta Was this translation helpful? Give feedback.
All reactions
-
I found this
const n = new Go; WebAssembly.instantiateStreaming(fetch(new URL(e(4126),e.b).href), n.importObject).then((t=>n.run(t.instance)))
Beta Was this translation helpful? Give feedback.
All reactions
-
👀 1
-
@antonmedv is the intent to keep the WASM build under the paid Expr Editor only?
I was looking to potentially run expr in Argo UI's front-end for client-side validation in argoproj/argo-workflows#13493 (comment), for which a WASM build would make sense.
Although I don't know how large of a JS dep it would be, so maybe not worthwhile if it's too big (as the Argo UI has a lot of large deps as is) and may just limit to regex for a first pass
#669 (comment) also mentions running a WASM build on Cloudflare Workers.
More generally speaking, I could see a WASM build as useful for multi-language support for expr expressions. CEL is starting to get support in multiple languages too (e.g. protovalidate is built on top of CEL for validation in multiple languages)
Beta Was this translation helpful? Give feedback.
All reactions
-
is the intent to keep the WASM build under the paid Expr Editor only?
Building Expr as WASM is available for everyone. Expr Editor is editor, and actually it not even requires WASM, the whole lint/autocomplete can be done on the server.
I was looking to potentially run expr in Argo UI's front-end for client-side validation in argoproj/argo-workflows#13493 (comment), for which a WASM build would make sense.
It is totally doable to build Expr with custom Argo env as WASM and use it on client side. I will write some documentation on how to do that.
if it's too big
WASM build size mostly dominated by Go build results. In playground I got 1.9MB (gzipped) WASM size. (Note it is not possible to build reflect package with tinygo at the moment, as some reflect.Func bugs in tinygo).
Right now it is possible to use Expr anywhere WASM is supported via building with Go. I'm now planning to implement Expr in two additional languages: JS and Rust (expr.js and expr.rs).
PS About Expr Editor for Argo, we can also discuss term for editor component for Argo UI.
Please contact me via mail at anton@medv.io
Beta Was this translation helpful? Give feedback.
All reactions
-
👀 1
-
Building Expr as WASM is available for everyone.
For sure, what I meant was an official WASM binary release. Since if Argo were to use a WASM build, it'd be a public build repo.
WASM build size mostly dominated by Go build results. In playground I got 1.9MB (gzipped) WASM size.
Thanks for the details! Dang, I figured it might be large from the Go runtime, but that's def too big at the moment (see also argoproj/argo-workflows#12059).
Right now it is possible to use Expr anywhere WASM is supported via building with Go. I'm now planning to implement Expr in two additional languages: JS and Rust (expr.js and expr.rs).
Yea I know it's hard to maintain ports (same thing lots of libraries struggle with), so a WASM build seems a lot more sustainable/maintainable long-term. My hope would be that Go WASM gets more optimal over time; though I suppose Go itself isn't known for the smallest binaries either 😅
PS About Expr Editor for Argo, we can also discuss term for editor component for Argo UI.
Please contact me via mail at anton@medv.io
I wasn't thinking about that actually, just thought that might be why there isn't an official WASM release. Although now that I re-check the releases page, there isn't a regular binary release either. Which makes sense in the Go ecosystem since you just reference GitHub repos directly, vs JS ecosystem, which commonly hosts builds on NPM
It could be interesting for Argo to host an expr playground on its docs site with Argo's env built-in 🤔
Beta Was this translation helpful? Give feedback.
All reactions
-
Yes, Argo playground will be super cool. We could also discuss a way to support YAML syntax with builtin Expr syntax as well.
Beta Was this translation helpful? Give feedback.