grain-lang / grain

The Grain compiler toolchain and CLI. Home of the modern web staple. 🌾
https://grain-lang.org/
GNU Lesser General Public License v3.0
3.25k stars 113 forks source link

Feature Request: Webpack plugin #45

Open jcguarinpenaranda opened 6 years ago

jcguarinpenaranda commented 6 years ago

The Grain Lang looks awesome! It would be awesome too to have a Webpack plugin that compiles the .gr files to .wasm, so then we can use them in Javascript using something like the wasm-loader plugin

ospencer commented 6 years ago

Totally! This is something we've talked about but haven't officially created an issue. We'll use this one to track progress.

z0w0 commented 3 years ago

I experimented with one here https://github.com/z0w0/grain-loader as I thought it would be a nice way to understand how the runtime is implemented. It's nowhere near usable though (see the Caveats readme section).

It's kind of limited by the way I chose to implement it and the fact that there's no static linking (#28), at the moment. However, it is working currently, even if it is the most rudimentary program ever :) There are some other options I mentioned in the Alternative implementations section of the readme that might play better with the current compiler implementation.

phated commented 3 years ago

Wow! Would you want to turn the Caveats into issues here in the Grain repo? If not, we can try to translate them into actionable things to work on.

z0w0 commented 3 years ago

Sure! I think with #406 resolved and #407 merged, the caveats would be sorted out. However, even though the Webpack loader tries to follow module resolution as closely to the runtime's locator implementation as possible, having it consistently match through some sort of static linking #28 would also simplify it.

Last thing might be having an easy way to install the CLI consistently - currently the loader just uses a configured location of Grain locally, but it would be cool to have the loader bundle with the CLI. Having the @grain/cli built and available on NPM might be one way to go about it, in a way similar to #406 - but not sure if that's the best route to take, so have held off on an issue for now.