-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Add gleam support to Mix #14262
base: main
Are you sure you want to change the base?
Add gleam support to Mix #14262
Conversation
421dc7c
to
0afa895
Compare
@josevalim when working on this I was always thinking of |
It should be possible because we use heroicons, a regular JS package, as a dependency on Phoenix applications. So we could probably support a |
Hello! You shouldn't need to do anything special target-wise as Gleam performs dead code elimination for code that is for other targets.
I would not expect Mix to become a front-end build tool by adding Gleam support. I think the workflow should be the same as it is today etc, with the desired build tool (esbuild, webpack, Adding frontend dependencies to the BEAM application dependency tree would either be wasted work compiling and managing them, or the programmer would need to go through every dependency in the lock file and add configuration to their
There is no such config. A Gleam package doesn't have an explicit target, each function in the public API is available on Erlang, JavaScript, or both, and they get either compiled or eliminated as needed. Whether a package is for Erlang or JavaScript is typically a matter of how the dependant is using them, not a matter of the configuration of the dependency. There is a |
b91ae71
to
c181ecd
Compare
@@ -269,6 +269,15 @@ Enum.each(fixtures, fn fixture -> | |||
File.cp_r!(source, dest) | |||
end) | |||
|
|||
## Set up Gleam fixtures | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And we should probably skip gleam tests if gleam is not installed, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I guess I need to add gleam to CI (although I need to wait until my gleam PR is merged and released).
a18bf89
to
26c8aff
Compare
26c8aff
to
8a7d9fa
Compare
- Add Mix.Gleam module - Add specific gleam binary version requirement - Rely on `gleam export package-info`
- shell_cmd! wasn't handling tuples - Fix documentation
This is an optional value within [erlang] in the gleam.toml file. It will be used for the `mod` value when generating a .app file
8a7d9fa
to
360db23
Compare
I am kind of copypasting this from the Gleam discord in case someone wants to try this out before merging into main: What is this?These changes add first-class support for Gleam in Elixir's Mix, thus allowing gleam path dependencies in What's missing?Probably nothing. Work on the gleam compiler is already merged and work on the Mix side is completed, but there might me rough edges, that's what we need to test. InstructionsMix integration will expect you to have gleam >= 1.10.0 installed and that hasn't been released yet. So:
If you were using UsageAfter running What needs to be tested?
ThanksJust report back with your findings and: thanks :person_bowing: Note: I hope these instructions are enough and correct. Let me know if that's not the case. |
@Papipo thanks for all the work so far! One question: I thought that |
No, gleam is a single binary written in Rust. I don't know if we can provide a hex archive maybe? I don't know how these work. How is rebar installation handled? I know that mix is able to install it locally, but I am not sure what that means exactly. It's still a binary as well, right? |
For Rebar, we have some binaries which we upload to hex.pm, and we version control them every year or so. Although I don't think this will work for Gleam, because people want to upgrade it more frequently, and Rebar is only a build tool, not really a compiler. So I guess we need to be clear we are using the system one and it is up to them to enforce the team uses the same version across the board (which is how we deal with |
In fact the binary is also the LS, so you definitely want to have full control of the version you are using, etc. |
This PR adds support for the gleam language.
gleam.toml
inpath
depsgleam
in deps loader.deps.compile
gleam
binary version (hardcoded to 1.9.0 for now, see below)gleam
binarymain
already but not yet released)Notes:
gleam
binary version requirements are handled automatically when executinggleam compile-package
.gleam export package-info
but I can't know the reason for a bad exit status (maybe the dep path was wrong and the command was run in a dir without agleam.toml
).[erlang]
options set in thegleam.toml
a.app
file is generated in theebin
folder of the dependency. Right now this generated file is very basic, having only thevsn
,applications
(ifextra_applications
was specified) andmod
(ifapplication_start_module
was specified). Not sure if there is room for improvement there (like using a .app.src file instead? I don't know the internals of this).