Skip to content

Commit 7d1e332

Browse files
committed
Update documentation
1 parent 3eb7e50 commit 7d1e332

File tree

3 files changed

+29
-27
lines changed

3 files changed

+29
-27
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99
### Added
1010
- Multiple `when` clauses in guards
1111
- Kernel.defdelegate/2
12-
- `js_modules` configuration option has been added. This is a keyword list of JavaScript modules that will be used.
12+
- `js_modules` configuration option has been added. This is a list of JavaScript modules that will be used.
1313
```
1414
js_modules: [
1515
{React, "react"},

GettingStarted.md

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,24 @@ This is the help output of elixirscript
2929
<input> path to elixir files or
3030
the elixir code string if passed the -ex flag
3131
options:
32+
--js-module [<identifer>:<path>] A js module used in your code. ex: React:react
33+
Multiple can be defined
3234
-f --format [format] module format of output. options: es (default), common, umd
3335
-o --output [path] places output at the given path
3436
-ex --elixir read input as elixir code string
3537
--full-build informs the compiler to do a full build instead of an incremental one
36-
--core-path import path to the elixirscript standard lib
37-
only used with the [output] option. When used, Elixir.js is not exported
3838
-v --version the current version number
3939
-h --help this message
4040

4141
the `<input>` is the elixir code string or file path you want to convert from elixir to javascript. Below is an example of using a code string and turning it into JavaScript
4242

4343
$ elixirscript ":atom" -ex
44-
Symbol.for('atom')
45-
46-
It changed the elixir code, `:atom` into the JavaScript code `Symbol.for('atom')`. The `-ex` parameter lets the script know that the input is an Elixir code string instead of a file.
4744

4845
elixirscript also takes a path to your `.ex` files as well:
4946

5047
$ elixirscript "src" -o "dist"
5148

52-
If you look in the dist folder, you should see 2 folders. `app` contains your code and `elixir` contains the elixirscript standard library files.
49+
If you look in the dist folder you'll see a file called `Elixir.App.js`
5350

5451
### Mix dependency
5552

@@ -58,7 +55,7 @@ Adding Elixirscript to your mix project gives you the ability to add it to your
5855
Add dependency to your deps in mix.exs:
5956

6057
```elixir
61-
{:elixir_script, "~> 0.25"}
58+
{:elixir_script, "~> 0.26"}
6259
```
6360

6461
Elixirscript uses default input, output and module formats if options are not given. If you wish to change any or all options, add an `elixir_script` key to your project configuration.
@@ -69,7 +66,15 @@ Add dependency to your deps in mix.exs:
6966
version: "0.1.0",
7067
elixir: "~> 1.0",
7168
deps: deps,
72-
elixir_script: [ input: "lib/elixirscript", output: "priv/elixirscript", format: :es],
69+
elixir_script: [
70+
input: "lib/elixirscript",
71+
output: "priv/elixirscript",
72+
format: :es,
73+
js_modules: [
74+
{React, "react"},
75+
{ReactDOM, "react-dom"}
76+
]
77+
],
7378
compilers: [:elixir_script] ++ Mix.compilers
7479
]
7580
end
@@ -88,6 +93,8 @@ Available options are:
8893

8994
* `:umd` - UMD
9095

96+
* `js_modules`: A list of JavaScript imports to add. Each item must be 2-tuple or a 3-tuple. The third element is an optional keyword list of options.
97+
9198
### Macros
9299

93100
Elixirscript supports public macros. Private macros are currently unsupported.
@@ -117,27 +124,18 @@ You can call globally scoped modules you would an Elixir module
117124

118125
Only works if module begins with a captial letter
119126

120-
#### Importing Modules
121-
122-
To import modules, first you must `require` the `JS` module. Then import the module using `JS.import`
123-
124-
defmodule MyModule do
125-
require JS
126-
JS.import React, "react"
127-
128-
def func() do
129-
React.render(my_component)
130-
end
131-
end
132-
133127
#### The JS module
134128

135129
The JS module has many other functions and macros. For more information, check out the docs.
136130

137131
#### Frontend Project Boilerplate
138132

139-
There is an [elixirscript frontend boilerplate project](https://github.com/bryanjos/elixirscript-project-boilerplate). This setup uses gulp and webpack to build and bundle assets.
133+
There is an [elixirscript frontend boilerplate project](https://github.com/elixirscript/elixirscript-project-boilerplate). This setup uses gulp and webpack to build and bundle assets.
134+
135+
#### elixirscript-brunch
136+
137+
There is an Brunch plugin, [elixirscript-brunch](https://www.npmjs.com/package/elixirscript-brunch).
140138

141-
#### ElixirScript-Brunch
139+
####
142140

143-
There is an Brunch plugin, [ElixirScript-Brunch](https://www.npmjs.com/package/elixirscript-brunch). There are instructions there on how to use it with Phoenix.
141+
There is also a webpack loader, [elixirscript-loader](https://www.npmjs.com/package/elixirscript-loader).

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## ElixirScript [![Documentation](https://img.shields.io/badge/docs-hexpm-blue.svg)](http://hexdocs.pm/elixir_script/) [![Build](https://travis-ci.org/elixirscript/elixirscript.svg?branch=master)](https://travis-ci.org/elixirscript/elixirscript) [![Deps Status](https://beta.hexfaktor.org/badge/all/github/bryanjos/elixirscript.svg)](https://beta.hexfaktor.org/github/bryanjos/elixirscript) [![Join the chat at https://gitter.im/elixirscript/elixirscript](https://badges.gitter.im/elixirscript/elixirscript.svg)](https://gitter.im/elixirscript/elixirscript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
22

3-
The goal is to convert a subset (or full set) of Elixir code to JavaScript, providing the ability to write JavaScript in Elixir. This is done by taking the Elixir AST and converting it into JavaScript AST and then to JavaScript code. This is done using the [Elixir-ESTree](https://github.com/bryanjos/elixir-estree) library.
3+
The goal is to convert a subset (or full set) of Elixir code to JavaScript, providing the ability to write JavaScript in Elixir. This is done by taking the Elixir AST and converting it into JavaScript AST and then to JavaScript code. This is done using the [Elixir-ESTree](https://github.com/elixirscript/elixir-estree) library.
44

55
Requirements
66
===========
@@ -65,13 +65,17 @@ Please check the [CONTRIBUTING.md](CONTRIBUTING.md)
6565

6666
### Example projects
6767
* [hello](https://github.com/bryanjos/hello) Shows using Phoenix + Elixirscript with file watching
68-
* [Elixirscript frontend boilerplate](https://github.com/bryanjos/elixirscript-project-boilerplate) A boilerplate project for elixirscript frontends
68+
* [Elixirscript frontend boilerplate](https://github.com/elixirscript/elixirscript-project-boilerplate) A boilerplate project for elixirscript frontends
6969
* [Elixirscript React example](https://github.com/bryanjos/elixirscript_react) An example of using with React
7070
* [Elixirscript AWS Lambda example](https://github.com/bryanjos/elixirscript_lambda)
7171

7272
#### Using with Brunch
7373
There is a plugin for using ElixirScript in your Brunch project
7474
[here](https://www.npmjs.com/package/elixirscript-brunch)
7575

76+
#### Using with Webpack
77+
There is a loader for using ElixirScript in your Webpack project
78+
[here](https://www.npmjs.com/package/elixirscript-loader)
79+
7680
#### 1.0 Roadmap
7781
There is a [1.0.0 Milestone](https://github.com/bryanjos/elixirscript/milestones/1.0.0) defined which includes issues that are needed to be cleared before 1.0 can be reached.

0 commit comments

Comments
 (0)