Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Porting to javascript #451

Unanswered
polRk asked this question in General
Oct 3, 2023 · 3 comments · 5 replies
Discussion options

Is it possible to port your library to javascript?
Is it possible to port your library to WASM and use in NodeJS / Browser?

You must be logged in to vote

Replies: 3 comments 5 replies

Comment options

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

You must be logged in to vote
3 replies
Comment options

Yes. Here is an example: https://expr.medv.io/playground

How can i compile and run expression? Like in golang but in nodejs/browser

Comment options

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

Comment options

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)))
Comment options

@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)

You must be logged in to vote
0 replies
Comment options

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

You must be logged in to vote
2 replies
Comment options

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 🤔

Comment options

Yes, Argo playground will be super cool. We could also discuss a way to support YAML syntax with builtin Expr syntax as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Converted from issue

This discussion was converted from issue #450 on October 03, 2023 19:17.

AltStyle によって変換されたページ (->オリジナル) /