100phlecs / tailwind_formatter

Sorts tailwind classes within elixir projects
https://hexdocs.pm/tailwind_formatter
MIT License
111 stars 11 forks source link

@external_resource in a dependency is not being watched #45

Open aptinio opened 12 months ago

aptinio commented 12 months ago

The Order class doesn't get recompiled when external resources are created or modified.

Relevant thread: https://elixirforum.com/t/recompile-dependency-based-on-external-resource/49030

I'm wondering if we should just read the files at runtime and ensure they're only read once for each invocation of TailwindFormatter.format/2. I'm hoping that won't take too long. I'll be happy to take a stab at this.

aptinio commented 12 months ago

Btw, I tried adding __mix_recompile__?/0 and it didn't help.

100phlecs commented 12 months ago

Did you try mix deps.compile tailwind_formatter --force? I would be curious what your current use-case is, unless it's just loading in the custom classes for the first time

Unfortunate that @external_resource don't work with libraries–I like the idea of adding a compiler to trigger. Loading in a ~100k lines file on every format sounds like it would make things a lot slower, but if it isn't too noticeable I would agree that's the least complex solution

aptinio commented 12 months ago

mix deps.compile tailwind_formatter --force does work and it's what I use. The times that I have to do it are:

Granted, this is not very often.

Another convenience that doing this at runtime might be being able call Mix.Task.run("tailwind", ["default"]) (if the task exists).

100phlecs commented 12 months ago

Would be nice for things to "just work" and not have to keep a mental checklist of when to run force recompilation for sure. I can see how just doing it at runtime is the easiest path forward

Not sure yet which is the best solution.

Sometimes I wonder how hard it'd be to recreate TailwindCSS in Eilxir so there's no more FFI 🤔