Converts Elixir to JavaScript
super
defoverridable
IO.inspect\1
, IO.puts\1
, IO.puts\2
, IO.warn\1
Elixir.load
for loading generated JavaScript modules in bundled output.
Unlike Elixir.start
, this will only call __load
on the module and return the functions on itconst exports = Elixir.load(Elixir.MyApp);
exports.hello();
-ex
alias is now -e
JS
moduleJS.length # translates to 'length'
JS.alert() # translates to 'alert()'
JS.String.raw("hi") # translate to String.raw('hi')
JS.console.log("hi") # translates to console.log('hi')
Multiple when
clauses in guards
Kernel.defdelegate/2
js_modules
configuration option has been added. This is a keyword list of JavaScript modules that will be used.
js_modules: [
{React, "react"},
{ReactDOM, "react-dom"}
]
js-module
flag has been added to the CLI in order to pass js modules.
elixirscript "app/elixirscript" -o dist --js-module React:react --js-module ReactDOM:react-dom
@on_js_load
has been removed in favor of having a start/2
function defined. More info belowJS.import
has been removed in favor of defining JavaScript modules used in configurationNow bundles all output, including the boostrap code. The exported object has Elixir modules in JavaScript namespaces that are lazily loaded when called.
To start your application import the bundle according to whichever module format was selected and then call start giving it the module and the initial args
//ES module example
import Elixir from './Elixir.App'
Elixir.start(Elixir.App, [])
The start
function will look for a start/2
function there.
This is analogous to a Application module callback
Collectable
protocol implementationsfor
implementation to use Collectable
format
option. Can now specify the module format of output.
Choices are:
* :es
(default) for ES Modules
* :umd
for UMD
* :common
for CommonJSlib/elixirscript
and input and place output in priv/elixirscript
. The default format is :es
receive
Process
module