View Source Hologram.Compiler (hologram v0.2.0)

Summary

Functions

Builds the call graph of all modules in the project.

Builds the call graph of all modules in the given IR PLT.

Builds IR persistent lookup table (PLT) of all modules in the project.

Builds IR persistent lookup table (PLT) of all modules in the project using the given module BEAM path PLT.

Builds module BEAM path persistent lookup table (PLT) of all modules in the project.

Builds a persistent lookup table (PLT) containing the BEAM defs digests for all the modules in the project. Mutates module BEAM path PLT.

Builds page digest PLT, where the keys represent page modules, and the values are hex digests of their corresponding JavaScript bundles.

Builds JavaScript code for the given Hologram page.

Builds Hologram runtime JavaScript source code.

Bundles multiple entry files. Includes the source maps of the output files. The output files' and source maps' file names contain hex digest.

Bundles the given entry file. Includes the source map of the output file. The output file and source map file names contain hex digest.

Creates runtime bundle entry file.

Compares two module digest PLTs and returns the added, removed, and updated modules lists.

Formats the given JavaScript files with Biome.

Groups the given MFAs by module.

Installs JavaScript deps which are specified in package.json located in assets_dir. Saves the package.json digest to package_json_digest.bin file in build_dir.

Installs JavaScript deps if package.json has changed or if the deps haven't been installed yet.

Loads call graph from a dump file if the file exists or creates an empty call graph.

Loads IR PLT from a dump file if the file exists or creates an empty PLT.

Loads module BEAM path PLT from a dump file if the file exists or creates an empty PLT.

Loads module digest PLT from a dump file if the file exists or creates an empty PLT.

Given a module digests diff, updates the IR persistent lookup table (PLT) by deleting entries for modules that have been removed, rebuilding the IR of modules that have been updated, and adding the IR of new modules.

Keeps only those IR expressions that are function definitions of the given reachable MFAs.

Raises a compilation error if any page module lacks a specified route or layout.

Functions

build_call_graph()

@spec build_call_graph() :: Hologram.Compiler.CallGraph.t()

Builds the call graph of all modules in the project.

build_call_graph(ir_plt)

@spec build_call_graph(Hologram.Commons.PLT.t()) :: Hologram.Compiler.CallGraph.t()

Builds the call graph of all modules in the given IR PLT.

Benchmark: https://github.com/bartblast/hologram/blob/master/benchmarks/compiler/build_call_graph_1/README.md

build_ir_plt()

@spec build_ir_plt() :: Hologram.Commons.PLT.t()

Builds IR persistent lookup table (PLT) of all modules in the project.

build_ir_plt(module_beam_path_plt)

@spec build_ir_plt(Hologram.Commons.PLT.t()) :: Hologram.Commons.PLT.t()

Builds IR persistent lookup table (PLT) of all modules in the project using the given module BEAM path PLT.

Benchmark: https://github.com/bartblast/hologram/blob/master/benchmarks/compiler/build_ir_plt_1/README.md

build_module_beam_path_plt()

@spec build_module_beam_path_plt() :: Hologram.Commons.PLT.t()

Builds module BEAM path persistent lookup table (PLT) of all modules in the project.

build_module_digest_plt!(module_beam_path_plt)

@spec build_module_digest_plt!(Hologram.Commons.PLT.t()) :: Hologram.Commons.PLT.t()

Builds a persistent lookup table (PLT) containing the BEAM defs digests for all the modules in the project. Mutates module BEAM path PLT.

Benchmarks: https://github.com/bartblast/hologram/blob/master/benchmarks/compiler/build_module_digest_plt!_1/README.md

build_page_digest_plt(bundle_info, opts)

Builds page digest PLT, where the keys represent page modules, and the values are hex digests of their corresponding JavaScript bundles.

build_page_js(page_module, call_graph, ir_plt, js_dir)

Builds JavaScript code for the given Hologram page.

Benchmark: https://github.com/bartblast/hologram/blob/master/benchmarks/compiler/build_page_js_4/README.md

build_runtime_js(runtime_mfas, ir_plt, js_dir)

@spec build_runtime_js(
  [mfa()],
  Hologram.Commons.PLT.t(),
  Hologram.Commons.Types.file_path()
) ::
  String.t()

Builds Hologram runtime JavaScript source code.

bundle(entry_files_info, opts)

Bundles multiple entry files. Includes the source maps of the output files. The output files' and source maps' file names contain hex digest.

Benchmark: https://github.com/bartblast/hologram/blob/master/benchmarks/compiler/bundle_2/README.md

bundle(entry_name, entry_file_path, bundle_name, opts)

Bundles the given entry file. Includes the source map of the output file. The output file and source map file names contain hex digest.

create_page_entry_files(page_modules, call_graph, ir_plt, opts)

Creates page bundle entry file.

Benchmark: https://github.com/bartblast/hologram/blob/master/benchmarks/compiler/create_page_entry_files_4/README.md

create_runtime_entry_file(runtime_mfas, ir_plt, opts)

Creates runtime bundle entry file.

Benchmark: https://github.com/bartblast/hologram/blob/master/benchmarks/compiler/create_runtime_entry_file_3/README.md

diff_module_digest_plts(old_plt, new_plt)

@spec diff_module_digest_plts(Hologram.Commons.PLT.t(), Hologram.Commons.PLT.t()) ::
  %{
    added_modules: [module()],
    removed_modules: [module()],
    updated_modules: [module()]
  }

Compares two module digest PLTs and returns the added, removed, and updated modules lists.

Benchmarks: https://github.com/bartblast/hologram/blob/master/benchmarks/compiler/diff_module_digest_plts_2/README.md

format_files(file_paths, opts)

@spec format_files(
  [Hologram.Commons.Types.file_path()],
  Hologram.Commons.Types.opts()
) ::
  {Collectable.t(), exit_status :: non_neg_integer()}

Formats the given JavaScript files with Biome.

Benchmark: https://github.com/bartblast/hologram/blob/master/benchmarks/compiler/format_files_2/README.md

group_mfas_by_module(mfas)

@spec group_mfas_by_module([mfa()]) :: %{required(module()) => mfa()}

Groups the given MFAs by module.

install_js_deps(assets_dir, build_dir)

Installs JavaScript deps which are specified in package.json located in assets_dir. Saves the package.json digest to package_json_digest.bin file in build_dir.

maybe_install_js_deps(assets_dir, build_dir)

@spec maybe_install_js_deps(
  Hologram.Commons.Types.file_path(),
  Hologram.Commons.Types.file_path()
) ::
  :ok | nil

Installs JavaScript deps if package.json has changed or if the deps haven't been installed yet.

Benchmarks: https://github.com/bartblast/hologram/blob/master/benchmarks/compiler/maybe_install_js_deps_2/README.md

maybe_load_call_graph(build_dir)

Loads call graph from a dump file if the file exists or creates an empty call graph.

Benchmarks: https://github.com/bartblast/hologram/blob/master/benchmarks/compiler/maybe_load_call_graph_1/README.md

maybe_load_ir_plt(build_dir)

Loads IR PLT from a dump file if the file exists or creates an empty PLT.

Benchmarks: https://github.com/bartblast/hologram/blob/master/benchmarks/compiler/maybe_load_ir_plt_1/README.md

maybe_load_module_beam_path_plt(build_dir)

@spec maybe_load_module_beam_path_plt(Hologram.Commons.Types.file_path()) ::
  {Hologram.Commons.PLT.t(), String.t()}

Loads module BEAM path PLT from a dump file if the file exists or creates an empty PLT.

Benchmarks: https://github.com/bartblast/hologram/blob/master/benchmarks/compiler/maybe_load_module_beam_path_plt_1/README.md

maybe_load_module_digest_plt(build_dir)

@spec maybe_load_module_digest_plt(Hologram.Commons.Types.file_path()) ::
  {Hologram.Commons.PLT.t(), String.t()}

Loads module digest PLT from a dump file if the file exists or creates an empty PLT.

Benchmarks: https://github.com/bartblast/hologram/blob/master/benchmarks/compiler/maybe_load_module_digest_plt_1/README.md

patch_ir_plt!(ir_plt, module_digests_diff, module_beam_path_plt)

Given a module digests diff, updates the IR persistent lookup table (PLT) by deleting entries for modules that have been removed, rebuilding the IR of modules that have been updated, and adding the IR of new modules.

prune_module_def(module_def_ir, reachable_mfas)

Keeps only those IR expressions that are function definitions of the given reachable MFAs.

validate_page_modules(page_modules)

@spec validate_page_modules([module()]) :: :ok

Raises a compilation error if any page module lacks a specified route or layout.

Benchmark: https://github.com/bartblast/hologram/blob/master/benchmarks/compiler/validate_page_modules_1/README.md