surface-ui / surface

A server-side rendering component library for Phoenix
https://surface-ui.org
MIT License
2.08k stars 150 forks source link

Remove compile-time deps from components #653

Closed msaraiva closed 2 years ago

msaraiva commented 2 years ago

Removes compile deps from components and turn them into export.

The basic rules you can expect when changing a component from now on are:

dvic commented 2 years ago

Wow, amazing :D This PR reduces in our project the compile-connected deps from 800+ to just 4!! 🎉

We can say definitly it fixes #552 😉

dvic commented 2 years ago

I just tried updating to 0.8.2, but I get these weird dialyzer errors:

lib/my_web/some_file.ex:1:pattern_match
The pattern can never match the type.

Pattern:
false

Type:
true

I tried resetting the cache but it didn't help. Any idea?

dvic commented 2 years ago

Maybe it's because of the following new code?

    imports_block =
       quote do
         if true do
           unquote(imports)
         end
       end
msaraiva commented 2 years ago

The if block there is just a simple way to scope the imports so they don't leak to the rest of the module. We just want to make sure we create the export dependencies there. We don't need to actually import anything. I guess I'll have to replace that with something else that can satisfy dialyzer.

Any suggestion? I don't use dialyzer at all :)

dvic commented 2 years ago

Hmm... removing that if statement does not resolve the issue and I can't reproduce it in a new repo. Have to investigate this further... Makes me want to drop dialyzer altogether 😂

dvic commented 2 years ago

See #654, it's introduced in a commit before this PR