-
Notifications
You must be signed in to change notification settings - Fork 298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
is there an NPM wrapper? #86
Comments
Original reply by @mpvl in cuelang/cue#86 (comment) No, but there is an excellent Go to JS transpiler (GopherJS). I tried it a while back and it works great for CUE. So if anyone wants to define a JS API, I'll be happy to get people started and include a separate repo in this org. What kind of functionality were you thinking of? |
Original reply by @dcsan in cuelang/cue#86 (comment) i just want to start with basic read/write to replace some yaml and json files... |
Original reply by @rudolph9 in cuelang/cue#86 (comment) @mpvl would you mind adding me to a repo for a js API rin this org? I have need for this my self. I actually did a quick test of this my self this morning. I following this tutorial:
Here is a little gist with everything needed if anyone else is interested https://gist.github.com/rudolph9/dd5e3dbcbf762abdb3f662e39dacfa7f |
Original reply by @mpvl in cuelang/cue#86 (comment) This is fine with me. Two questions:
|
Original reply by @rudolph9 in cuelang/cue#86 (comment)
Github
I think that works but only other thing I would consider is perhaps there will multiple js repos that result in an npm package. The impl I'm building will be a wasm wrapper, perhaps in the future there will be an cue FFI compatible with nodejs, and perhaps in the future too the golang compiler may target javascript and we would want a package for that too?? Pragmatically speaking though, |
Original reply by @rudolph9 in cuelang/cue#86 (comment) @mpvl Speaking of CI, have you requested beta access to github actions for the cuelang org? Haven't worked with them extensively but look convenient and might be helpful. |
Original reply by @rudolph9 in cuelang/cue#86 (comment) @mpvl I created the |
Original reply by @mpvl in cuelang/cue#86 (comment) @rudolph9 that seems useful indeed, especially wider OS coverage. I added cuelang. We'll see. |
Original reply by @mpvl in cuelang/cue#86 (comment) I didn't, but created |
Original reply by @mpvl in cuelang/cue#86 (comment) @rudolph9 Then maybe lang-wasm? BTW, while you're at it, another very useful wrapper would be cue/format.Node. Would come in handy for, say, an in-browser CUE demo. :) |
Original reply by @rudolph9 in cuelang/cue#86 (comment)
@mpvl I invited that user and will be able to make you owner once you accept the invite. |
Original reply by @rudolph9 in cuelang/cue#86 (comment)
Can we call it
👍 |
Original reply by @mpvl in cuelang/cue#86 (comment)
Created it and added you as collaborator. |
Original reply by @marcus-sa in cuelang/cue#86 (comment) I'd be really interested in this aswell. |
Original reply by @myitcv in cuelang/cue#86 (comment) cc @mvdan who has experience of this sort of thing in https://github.com/mvdan/sh |
Original reply by @marcus-sa in cuelang/cue#86 (comment) As a workaround for now, I'm currently thinking about either:
|
Original reply by @rudolph9 in cuelang/cue#86 (comment) I did a little investigating on this today to explore using gopherjs to compile directly to javascript but unfortunately it seems it don't fully support go mod files yet and is choking on the cockroachdb/ada dependency
|
Original reply by @myitcv in cuelang/cue#86 (comment) @rudolph9 my fork of GopherJS does have module support https://github.com/myitcv/gopherjs myitcv/gopherjs#50 is tracking Go 1.13 support, but things work with Go 1.12, as demonstrated by the proof of concept CUE playground: https://blog.myitcv.io/gopherjs_examples_sites/cueplayground/ |
Original reply by @rudolph9 in cuelang/cue#86 (comment)
Hey @mpvl I'm circling back to this ticket and and just want to make sure all the ducks are in a row. Regardless where you decide we should publish the cuelange npm package it would be good for you to be the owner of the npm org. |
Original reply by @rudolph9 in cuelang/cue#86 (comment) @myitcv thanks for the tip, I was able to successfully target JS using your fork of gopherjs. Still pretty rough, still need to properly bundle it as a package but here it is. I got a wasm version of it going initially using golang-wasm-async-loader but spun my wheels for far too long trying to package the wasm 😠 I could see use cases for both a pure js impl and a wasm binding version as an app that interacts with cue often pass lots of data to be evaluated or receiving lots of data after evaluation likely would be more performant using js impl where as a wasm binding would likely better in the case of less frequent but lots of state in the cuelang runtime case a likely would be a good condidate to run in a web worker. @myitcv does gopherjs have any tooling around interacting targeting and packaging a wasm or is the community mostly focused on compiling golang to js? @mpvl I probably have an npm package for you to review in the near future, the gopher approach is kinda big (8MB unminified) but works pretty seamlessly in firefox, chrome, and nodejs 11 on my x230 thinkpad. I think an initial js use-case that will really take off is the use of cue in redux where you basically define one action type and one reducer where you define a cue spec that has emit which serves as the next state and each time an action is received by the reducer it evaluated by cue along previous state. |
Original reply by @rudolph9 in cuelang/cue#86 (comment) If anyone is interested I created a draft package to check out: https://github.com/rudolph9/lang-js/packages/63456 fyi github packages is a little finicky and wound up doing to the following to get it to properly install with yarn:
|
Original reply by @myitcv in cuelang/cue#86 (comment)
No, GopherJS is focussed entirely on JS. For an example of bootstrapping WASM in a webpage see https://github.com/golang/go/tree/master/misc/wasm |
Original reply by @rudolph9 in cuelang/cue#86 (comment)
@myitcv thank you for the feedback. Since gopherjs supports |
Original reply by @buremba in cuelang/cue#86 (comment) We're thinking of building an online IDE for Cue based on Monaco Editor (https://microsoft.github.io/monaco-editor/). It would be great to have a JS compiler for Cue as it can be used as an embedded language server running via Web Workers. |
Original reply by @rudolph9 in cuelang/cue#86 (comment) @buremba It's out of date but you could give https://www.npmjs.com/package/@rudolph9/cue a try. I've been meaning to build some automation into around https://github.com/rudolph9/lang-js and open a pull request into the main project. Let me know what you think of the interface? I have some time this week, maybe I can button it up (proper doc, .github automation, etc) and request it get merged into the official cuelang org repo. |
Original reply by @buremba in cuelang/cue#86 (comment) @rudolph9 Thanks for the response, I'm trying out your port. Since the IDE will support multiple files and we now support injecting external data see here, I believe that the interface should have a signature something like this:
|
I made https://github.com/dclareio/cue-wasm for my own purposes and it works pretty well if anyone is interested. Feel free to leave any suggestions/feedback as issues on the repo! |
Originally opened by @dcsan in cuelang/cue#86
I'd like to use this as a replacement for YAML in some javascript/ts projects, is there a wrapper/package for NPM?
The text was updated successfully, but these errors were encountered: