Skip to content

Commit 4fdb45e

Browse files
committed
Fix: move if/else outside defmodule to avoid Zig macro expansion
Elixir expands macros in both branches of a module-level if/else, causing 'use Zig' to fail when Zigler isn't installed even if the precompiled path is taken. Moving the conditional to the file top level (outside defmodule) ensures only the matching branch is evaluated.
1 parent f6a39d5 commit 4fdb45e

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

lib/tailwind_compiler/nif.ex

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
defmodule TailwindCompiler.NIF do
2-
@moduledoc false
1+
if TailwindCompiler.Native.use_precompiled?() do
2+
defmodule TailwindCompiler.NIF do
3+
@moduledoc false
34

4-
if TailwindCompiler.Native.use_precompiled?() do
55
@on_load :__load_nif__
66

77
@doc false
@@ -15,7 +15,11 @@ defmodule TailwindCompiler.NIF do
1515

1616
def validate(_tokens),
1717
do: :erlang.nif_error(:not_loaded)
18-
else
18+
end
19+
else
20+
defmodule TailwindCompiler.NIF do
21+
@moduledoc false
22+
1923
use Zig,
2024
otp_app: :tailwind_compiler,
2125
nifs: [compile: [:dirty_cpu], validate: [:dirty_cpu]],

0 commit comments

Comments
 (0)