Skip to content
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

Raw C usage (or in Go via Cgo) #147

Open
b3nten opened this issue Feb 20, 2023 · 6 comments
Open

Raw C usage (or in Go via Cgo) #147

b3nten opened this issue Feb 20, 2023 · 6 comments

Comments

@b3nten
Copy link

b3nten commented Feb 20, 2023

Hi,

I don't have experience with wasm (or C for that matter) but I'm wondering how difficult this would be to get working in C (and eventually Go)? Would it be a few small changes, or is it entirely designed for wasm as a target and would require significant work?

End goal would be to parse JS strings with this in a Go cli.

Cheers

@guybedford
Copy link
Owner

It should be possible to get this project building for native C quite easily yes. That said, since it wasn't designed for this, it likely would have vulnerabilities outside of being used in a Wasm sandbox.

There is also a Rust build at https://github.com/jspm/rust-lexer which may be easier to run in Go.

Another alternative might even be to use the component build at #143 which builds a WebAssembly component which could be used in Go while retaining strong security. These Wasm directions are very experimental though so it would only be if you're interested in exploring that.

@b3nten
Copy link
Author

b3nten commented Feb 21, 2023

Hi, thanks for the response

The Rust build looks promising, although I can't find it (perhaps it's a private repo?). I thought about using WASM but that looks like it would be fairly complex to run. I'm willing to explore different routes - it's not a high priority, I have the functionality via EsBuild but this would be preferable. What's the experimental part with Wasm?

@guybedford
Copy link
Owner

Ah, ok I've given you access to the Rust lexer. Note it's behind this main branch by quite a bit now, although in theory the upstreaming shouldn't be too tricky. Open to collaboration on that repo. Also happy to share more about Wasm workflows too.

@thepassle
Copy link

I'd be really interested in the Rust lexer as well (or other documentation on how to use the wasm module in rust). I was trying to get the lexer to run in Rust, but I was having a hard time using both wasmtime and cc, and can't seem to get things up and running.

@thepassle
Copy link

thepassle commented Nov 27, 2023

Also found this today: https://github.com/devongovett/es-module-lexer/blob/main/src/lib.rs for anybody else who's reading along

@guybedford
Copy link
Owner

The Rust version worked on previously in collaboration with @vovacodes is at https://github.com/jspm/rust-lexer. It hasn't been updated in over two years to the current es-module-lexer commits though.

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

No branches or pull requests

3 participants