Popcorn (Popcorn v0.2.2)

View Source

Popcorn is a tool for running Elixir in the browser.

Summary

Functions

Bundles compiled project code into an .avm file.

Generates static artifacts to run the project in the browser.

Generates artifacts needed to run any Popcorn-based project.

Functions

bundle(options \\ [])

@spec bundle(out_dir: String.t(), start_module: module(), extra_beams: [String.t()]) ::
  :ok

Bundles compiled project code into an .avm file.

Options have the same semantics as in cook/1.

cook(options \\ [])

@spec cook(
  out_dir: String.t(),
  start_module: module(),
  target: :wasm | :unix,
  extra_beams: [String.t()],
  include_vm: boolean()
) :: :ok

Generates static artifacts to run the project in the browser.

Options:

  • out_dir - The directory to write artifacts to. Required, unless provided via config.exs.
  • start_module - Optional; a module with start/0 function that will be called after applications start.
  • target - wasm (default) or unix. If unix is chosed, you need to build the runtime first with mix popcorn.build_runtime --target unix
  • extra_beams - Compiled BEAMs that should be included in the generated bundle.
  • include_vm - If true, includes the VM and supporting files in the output directory (e.g. AtomVM.wasm, AtomVM.mjs and JS glue for wasm; AtomVM binary for unix).

Instead of calling cook/1, you can call ingredients/1 and then bundle/1.

ingredients(options \\ [])

@spec ingredients(out_dir: String.t(), target: :wasm | :unix, include_vm: boolean()) ::
  :ok

Generates artifacts needed to run any Popcorn-based project.

Options have the same semantics as in cook/1.