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

Interactive components not working since Astro updated to 2.0 #1

Closed
DrBloke opened this issue Mar 12, 2023 · 4 comments · Fixed by #2
Closed

Interactive components not working since Astro updated to 2.0 #1

DrBloke opened this issue Mar 12, 2023 · 4 comments · Fixed by #2

Comments

@DrBloke
Copy link

DrBloke commented Mar 12, 2023

Hi, thanks for making this library. I think it will be very useful.

I'm finding that the more complex interactive uses of elm (where state is updated) are not working. I think this might be due to the updating of Astro to 2.0. The simple Hello World example works fine. With the interactive ones, the Elm code seems to compile fine, but then an error is thrown claiming not to be able to find the component. I have produced as minimal example here:

Minimal example

I have simplified it to just use Browser.sandbox to make things simpler. The error was the same if using Browser.application

If there is more info I could provide or any other way I might be able to help then please let me know.

@zkrzyzanowski
Copy link

zkrzyzanowski commented Jul 23, 2023

for anyone running into this issue, I think i found the root cause, but I'm not sure the correct fix.

The dev middleware used to handle requests to elm files is interpreting elm files at the root of your file system, instead of relative to your current working directory.

adding verbose : true to the elm compiler options here will show that it's trying to run the following from @DrBloke's reproduction repo

elm make /src/components/elm/Counter.elm --output /var/folders/q5/_wzcqbts6ss2_t9j3dxfwj5h0000gn/T/2023622-66626-ks1uhc.4wvd.js

Note the / in the beginning of the elm component path (not ./)

the following code fixes their example at least by adding a . prefix to the filepath in the middleware here

  if (req.originalUrl?.endsWith(".elm")) {
        let filename = req.originalUrl.replace("/@fs", "");
        if (!filename.startsWith(".")) {
            filename = "." + filename
        };

clearly something changed with astro or vite in the way that paths are handled when astro was upgraded to v2. This is at least a workaround or starting point if anyone else wants to continue to investigate

possibly related to this vite issue

@dkowis
Copy link

dkowis commented Dec 27, 2023

Astro is on v4 now, so it's probably even more broke?

@fl0werpowers
Copy link

The hello world doesn't seem to work in v4 either.

@johnmcguin
Copy link
Contributor

johnmcguin commented Oct 15, 2024

@angusjf can you re-open this issue since it's not published to npm?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants