Skip to content

Commit

Permalink
Resolve race condition compilation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
bcardarella committed Apr 24, 2024
1 parent d17c92e commit 93a0b8b
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions lib/live_view_native/component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,19 @@ defmodule LiveViewNative.Component do
def __native_opts__, do: @native_opts
end

plugin_component_ast = case LiveViewNative.fetch_plugin(format) do
plugin_component_ast = plugin_component_ast(format, opts)

[component_ast, plugin_component_ast]
end

defp plugin_component_ast(nil, _opts) do
quote do
import LiveViewNative.Component, only: [sigil_LVN: 2]
end
end

defp plugin_component_ast(format, opts) do
case LiveViewNative.fetch_plugin(format) do
{:ok, plugin} ->
quote do
import LiveViewNative.Renderer, only: [
Expand All @@ -171,19 +183,10 @@ defmodule LiveViewNative.Component do
end

:error ->
if is_nil(format) do
quote do
import LiveViewNative.Component, only: [sigil_LVN: 2]
end
else
IO.warn("tried to load LiveViewNative plugin for format #{inspect(format)} but none was found")

[]
end
IO.warn("tried to load LiveViewNative plugin for format #{inspect(format)} but none was found")

nil
end

[component_ast, plugin_component_ast]
end

@doc false
Expand Down

0 comments on commit 93a0b8b

Please sign in to comment.