You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Things are at the point now where the standard library can be defined mostly in Elixir. Here are some steps on adding them.
Add the module to the lib/elixir_script/prelude folder.
Add an entry to the map created in the build_standard_lib_map function in ElixirScript.Translator.State.
If you need some functionality in JavaScript, create it within the src/javascript/core module and then use it within your Elixir module.
ex: I want to create the Tuple module
Step 1: Add tuple.ex to the lib/elixir_script/prelude folder
defmoduleElixirScript.Tupledo...
Step 2: Add an entry for Tuple to the map created in the build_standard_lib_map function in ElixirScript.Translator.State.
|>Map.put(Tuple,ElixirScript.Tuple)
Step 3: If you need some functionality in JavaScript, create it within the src/javascript/core module and then use it within your Elixir module.
For the Tuple.duplicate I need a make_tuple function in JavaScript so I create it in src/javascript/core/functions.js. I also make sure to add it to the export declaration at the bottom of the file.
There are still some standard library modules written in JavaScript that need to be converted over. The goal is to get them converted, leaving only the core module in JavaScript. When the compiler compiles the code, it will output all of your application code along with the standard libraries and the core javascript module. From there the starting module for an application is a good place for something like rollup or webpack 2 to bundle and tree shake, leaving only the used code.
Things are at the point now where the standard library can be defined mostly in Elixir. Here are some steps on adding them.
lib/elixir_script/prelude
folder.build_standard_lib_map
function inElixirScript.Translator.State
.src/javascript/core
module and then use it within your Elixir module.ex: I want to create the Tuple module
tuple.ex
to thelib/elixir_script/prelude
folderTuple
to the map created in thebuild_standard_lib_map
function inElixirScript.Translator.State
.src/javascript/core
module and then use it within your Elixir module.For the
Tuple.duplicate
I need amake_tuple
function in JavaScript so I create it insrc/javascript/core/functions.js
. I also make sure to add it to the export declaration at the bottom of the file.Now I use this function in my
Tuple.duplicate
function in ElixirThat's pretty much it. If anything is missing or incomplete, please report it.
The text was updated successfully, but these errors were encountered: