Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating files under assets/svelte/_build for ~V #69

Open
dev-guy opened this issue Aug 11, 2023 · 9 comments
Open

Creating files under assets/svelte/_build for ~V #69

dev-guy opened this issue Aug 11, 2023 · 9 comments
Labels
bug Something isn't working

Comments

@dev-guy
Copy link

dev-guy commented Aug 11, 2023

assets/svelte/_build contains artifacts from llive views that use the ~V sigil.

This directory seems to be created when I run (among other mix commands) mix phx.server. However, this directory is not getting created. I'm using live_svelte version 0.11.0.

This has happened to me before and it "Just Started Working." However, I seem to have broken the ~V sigil's magic permanently this time.

@dev-guy
Copy link
Author

dev-guy commented Aug 11, 2023

I'd rather not have to do this, but this is the only thing that works when my project gets into this state:

rm -rf _build
mix setup
mix phx.server

@woutdp
Copy link
Owner

woutdp commented Aug 11, 2023

This is a regression probably. Need to investigate, thanks for reporting it!

@woutdp woutdp added the bug Something isn't working label Aug 11, 2023
@vonagam
Copy link
Contributor

vonagam commented Aug 11, 2023

Don't think that this is a regression. I think it is because v sigil is a macro and gets called during compilation of a module. Copying of a script happens when module compiles. If you change module - it recompiles and macro copies new script. But if you've already compiled everything and nothing have changed in the module then it will not be recompiled and macro will not be called.

That's why deleting _build helps - it forces recompilation.

@dev-guy
Copy link
Author

dev-guy commented Aug 14, 2023

I deleted assets/svelte/_build and that was the beginning of my trouble. Here's what doesn't work after that (followed by mix setup; mix phx.server):

  • mkdir assets/svelte/_build
    And/or:
  • touch lib/my_app/live/svelte/*.ex ## these are the only files have the ~V sigil

Deleting ./_build fixes the problem, but rebuilding takes too long. Is there a shortcut?

This is not a regression. This happened before 0.11.

@dev-guy dev-guy closed this as completed Aug 14, 2023
@dev-guy dev-guy reopened this Aug 14, 2023
@vonagam
Copy link
Contributor

vonagam commented Aug 14, 2023

assets/svelte/_build is an artifact of building process. Why do you delete it?

Yeah, touching a relevant file will lead to its recompilation, I don't think there will be a better shortcut than that.

@dev-guy
Copy link
Author

dev-guy commented Aug 15, 2023

Touching / modifying .ex files with ~V sigil and running mix setup ; mix phx.server doesn’t create files in assets/svelte/_build when that directory is empty. It’s easy to reproduce. Just:

rm -rf assets/svelte/_build
  # modify or touch .ex files
mix setup 
mix phx.server 

@vonagam
Copy link
Contributor

vonagam commented Aug 15, 2023

Ok, my bad, so there is an issue, modifying definitely should rerun macro...

@dev-guy
Copy link
Author

dev-guy commented Aug 15, 2023

I added some body text to my sigil template and that worked!

Touching files or adding whitespace, comments, etc. - anything that is removed by the compiler -- does not work.

I usually run into this bug when I switch branches. When the generated files for the ~V sigil are out of date, I delete the assets/svelte/_build directory hoping that they will be rebuilt. I used to just rebuild from an empty _build directory but I decided to put some time into poking it.

I don't think there's a bug if a file's timestamp goes "backwards" (which can happen with git pull). If the file's nontrivial content changes, the macro does create a build artifact. Although I think this has happened to me, I have not tried to reproduce it intentionally.

@dev-guy
Copy link
Author

dev-guy commented Aug 15, 2023

To recap:

  1. If you delete all files in assets/svelte/_build while the app is running and modify a *.ex file that contains a ~V sigil, assets/svelte/_build files are not created.
  2. If you remove assets/svelte/_build and start the app with mix phx.server, assets/svelte/_build files are also not created. IMO, this is the worst bug.

After deleting all files in assets/svelte/_build, the only known steps that result in assets/svelte/_build files are:

  1. Perform either or both of the following:
  • Delete ./_build
  • Modify *.ex files containing ~V sigil in some significant way -- merely touching them doesn't work, and adding whitespace or comments that are "compiled out" doesn't work either
  1. Run mix phx.server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants