-
Notifications
You must be signed in to change notification settings - Fork 171
is there an NPM wrapper? #86
Comments
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? |
i just want to start with basic read/write to replace some yaml and json files... |
@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 |
This is fine with me. Two questions:
|
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, |
@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. |
@rudolph9 that seems useful indeed, especially wider OS coverage. I added cuelang. We'll see. |
I didn't, but created |
@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. :) |
@mpvl I invited that user and will be able to make you owner once you accept the invite. |
Can we call it
👍 |
Created it and added you as collaborator. |
I'd be really interested in this aswell. |
cc @mvdan who has experience of this sort of thing in https://github.com/mvdan/sh |
As a workaround for now, I'm currently thinking about either:
|
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
|
@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/ |
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. |
@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. |
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:
|
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 |
@myitcv thank you for the feedback. Since gopherjs supports |
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. |
@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. |
@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:
|
This issue has been migrated to cue-lang/cue#86. For more details about CUE's migration to a new home, please see cue-lang/cue#1078. |
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: