Skip to content

Commit 3ae89c6

Browse files
committed
Move manifest writing to top level of compiler
1 parent c2fd900 commit 3ae89c6

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

lib/elixir_script/compiler.ex

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@ defmodule ElixirScript.Compiler do
3131
Translate,
3232
FindUsedModules,
3333
FindUsedFunctions,
34-
Output
34+
Output,
35+
Manifest,
3536
}
3637
alias ElixirScript.ModuleSystems.ES
3738
alias Kernel.ParallelCompiler
3839

39-
@spec compile(atom | [atom] | binary, []) :: nil
40+
@spec compile(atom | [atom] | binary, []) :: [{atom, map}]
4041
def compile(path, opts \\ [])
4142

4243
def compile(path, opts) when is_binary(path) do
@@ -86,6 +87,9 @@ defmodule ElixirScript.Compiler do
8687

8788
State.stop(pid)
8889

90+
manifest_path = Path.join(Mix.Project.manifest_path(), ".compile.elixir_script")
91+
Manifest.write_manifest(manifest_path, modules, opts)
92+
8993
result
9094
end
9195

lib/elixir_script/manifest.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ defmodule ElixirScript.Manifest do
66

77
end
88

9-
@spec write_manifest(binary, [{atom, map}]) :: :ok
10-
def write_manifest(manifest_path, modules) do
9+
@spec write_manifest(binary, [{atom, map}], map) :: :ok
10+
def write_manifest(manifest_path, modules, _opts) do
1111
data = Enum.reduce(modules, %{}, fn {module, info}, current_data ->
1212
info = %{
1313
references: info.used_modules,

lib/elixir_script/passes/output.ex

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ defmodule ElixirScript.Output do
33

44
alias ElixirScript.State, as: ModuleState
55
alias ESTree.Tools.{Builder, Generator}
6-
alias ElixirScript.Manifest
76

87
@doc """
98
Takes outputs the JavaScript code in the specified output
@@ -29,12 +28,7 @@ defmodule ElixirScript.Output do
2928
end)
3029

3130

32-
result = create_modules(prepared_modules, opts, js_modules)
33-
34-
manifest_path = Path.join(Mix.Project.manifest_path(), ".compile.elixir_script")
35-
Manifest.write_manifest(manifest_path, modules)
36-
37-
result
31+
create_modules(prepared_modules, opts, js_modules)
3832
end
3933

4034
defp concat(code) do

lib/mix/tasks/compile.elixir_script.ex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ defmodule Mix.Tasks.Compile.ElixirScript do
22
use Mix.Task
33

44
@recursive true
5+
@manifest ".compile.elixir_script"
6+
@manifest_vsn 1
57

68
@moduledoc """
79
Mix compiler to allow mix to compile Elixirscript source files into JavaScript
@@ -48,6 +50,9 @@ defmodule Mix.Tasks.Compile.ElixirScript do
4850
:ok
4951
end
5052

53+
def manifests, do: [manifest()]
54+
defp manifest, do: Path.join(Mix.Project.manifest_path(), @manifest)
55+
5156
@doc false
5257
def get_compiler_params() do
5358
elixirscript_config = get_elixirscript_config()

0 commit comments

Comments
 (0)