Adding conditional compilation flags? #2995
JoelVerm
started this conversation in
Ideas & suggestions
Replies: 2 comments 3 replies
-
Hello! One would normally do this by having multiple packages in one repo that import each other. e.g. "frontend", "backend", and "shared". What would this proposal enable that that does not? |
Beta Was this translation helpful? Give feedback.
3 replies
-
I've made my web framework and it works! It currently has to use erlang for the backend, but it works really well. The GitHub is https://github.com/JoelVerm/meadow if you'd like to check it out! The framework isn't finished yet, but it's in a working state ;) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I just discovered Gleam and I love it! At the moment, I'm trying to create something like a full-stack web framework for Gleam. It's basically a backend to glare with some additions.
Currently I have the frontend and backend in different gleam projects. You could then copy the build output from the frontend to be served by the backend. But because these are different projects you can't have common types (for example). So if you want to send something to the client you would need to define one type twice.
The idea
My idea is to add an attribute that works the same as
@target
but that works with flags. This way, you could specify at compile time what code would get compiled, so in my case the server or client. How this would look:And then build with
gleam build --flag=server
Why not just
@target
Because most web hosting providers use a javascript runtime only, or have a much higher pricing for docker containers. By using
@flag
you can compile the server for javascript as well and still have one codebase.It's just an idea
As I said, I'm fairly new to Gleam, so there may be a way to do this already. If there isn't, I'm sure my idea can be improved a lot, so please share some ideas, and maybe I can learn something in the process 😅
Beta Was this translation helpful? Give feedback.
All reactions