bryanjos

bryanjos

ElixirScript - converts Elixir to JavaScript

Hi, I just published version 0.23.0 of Elixirscript.

https://github.com/bryanjos/elixirscript/blob/master/CHANGELOG.md

Most of the changes are around JavaScript interop now that Elixirscript uses the Elixir compiler to compile and load files during compilation. This also means you can define macros in the same file now. Another bonus is that this release makes it a bit easier to share code between Elixir and Elixirscript.

That’s about it. Try it out and any feedback is always helpful.

First 10 of 42 Posts Switch mode

OvermindDL1

OvermindDL1

I’ve been tempted to write a little webcomponent or polymer or so integration with it to see how it works, be a nice little bite-size thing to test with. :slight_smile:

bryanjos

bryanjos OP

Nice! Let me know how it goes. I had written a small React example before for a local meetup, but never posted it online. I’m going to try to do that this week.

bryanjos

bryanjos OP

Hello I just published the latest version of Elixirscript. For a full list of the changes, take a look at the changelog The major changes in this version are:

  • Can select between ES, CommonJS, or UMD module formats for output
  • Can use and compile dependencies in mix projects (if dependency has the elixirscript compiler in its mix compilers)
  • Default input and output paths in mix projects

There is now an elixirscript organization with the projects that it uses. Also there is a newly created blog with the first post giving more details about the majors changes.

Finally, a gitter room was created for the project. The elixirscript channel on the elixir-lang slack still exists and I’ll still be there. The gitter room allows for integrations and keeps the history.

OvermindDL1

OvermindDL1

Ooo, awesome an update! :slight_smile:

bryanjos

bryanjos OP

Elixirscript 0.26.0 has been released. The biggest change is that output is reduced to a single file.

For a summary of the major changes, check out the post here

For a list of all changes, check out the changelog

Hex: elixir_script | Hex
Release on GitHub: Release 0.26.0 · elixirscript/elixirscript · GitHub

bryanjos

bryanjos OP

@OvermindDL1 I’ve been looking at BuckleScript a lot lately. I know you are a fan of it. I’m wondering how do you like its JavaScript interoperability? Redirecting to bucklescript.github.io/bucklescript

Wondering if maybe there are some things there that are worth borrowing for Elixirscript

OvermindDL1

OvermindDL1

It’s Javascript typed bindings are just done via OCaml’s normal FFI system, it just all fit very well. :slight_smile:

But yeah, I’d probably do something similar in Elixirscript. Last I saw Elixirscript you still did the JS.import bit (though now removed according to your just-now changelog ^.^), I’d probably do something like:

defjsmodule Underscore, import_name: "_" do
  deffun blah/2
end

Or whatever, although you could add typing information like I’m doing in TypedElixir so you can cause compile-errors when interfaces are mis-used. :slight_smile:

But yeah, OCaml’s FFI is just typing the interface, which the compiler then resolves to JS modules, it is very succinct and powerful and safe, as well as hard to borrow without having types in Elixir. ^.^

bryanjos

bryanjos OP

Ah that makes sense. Eventually I would like to get it to the point of requiring no JavaScript at all. It’s partially what the JS module is for right now, but could be built up to allow for more. The 2 systems that have impressed my so far are BuckleScript and Scala.js. But I guess both of those are type heavy examples. Anyways, I think there are somethings that can be done to get closer to that goal

Eiji

Eiji

@bryanjos: I saw docs at github and have some questions:

  1. Do you support converting whole Elixir project into JavaScript app?
    I mean not only specified directory, but also config, tests and others?
  2. Is it possible to prefix JavaScript calls in Elixir code? :console.log("hello") => :js.console.log("hello"). This could conflict with libraries (I mainly think about :document).
  3. I have a problem with last (4144) line: export default Elixir;, I got error message: SyntaxError: export declarations may only appear at top level of a module in Firefox Nightly and Uncaught SyntaxError: Unexpected token export in Chrome.
bryanjos

bryanjos OP

@Eiji

  1. Right now only a specific directory. I haven’t tested converting config or tests.

  2. Not possible right now, but something that could be up for discussion. I know clojurescript does something similar and it may be a good idea here. There is the “JS” modules which can be the jumping off point for that.

  3. Try using the “umd” format instead. The default is “es” which isn’t supported by browsers just yet

Edit: I probably need to do a good sweep of the docs to make sure they are up to date

Where Next?

Trending in Announcing Top

bluzky
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
387 14960 120
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
shahryarjb
The Chelekom project is a library of Phoenix and LiveView components generated via Mix tasks to fit developer needs seamlessly. One of i...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New

Other Trending Topics Top

type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
bjorng
We want to introduce a new native datatype to Erlang: native records. Although replacing all tuple records with native records is not our...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
alexslade
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog It says that Fly is going all-in on sprites, which is a worry ...
New

We're in Beta

About us Mission Statement