Closed leolorenzoluis closed 1 year ago
Please post some code or markup so I can see what you mean and how you are using it.
Also, have you tried the useContext
hook that we made on your Fable.Lit
thread?
You might be able to use that instead of using global Elmish.
https://github.com/fable-compiler/Fable.Lit/discussions/66#discussioncomment-3419629
I have not but will try it out soon.
The gist is your Ctrls.fs
has reference and being used by other FS files so it's including it in the bundled when vite starts. However, try removing any references and just functions that has LitComponent
attributes where the references are just inside html $"""..."""
and you'll see what I'm referring to. I had to explicitly call a dummy function in that file in order for it to include it.
Oh yeah, I think sometimes you have to put a fake register
function on a page so that it is called.
Is that true, @AngelMunoz? I think I recall seeing that on one of your blog posts.
Yes, due how dead code elimination is applied by webpack/vite and similar bundlers the actual function might get eliminated along its file, what we do in those cases is to add the
let register() = ()
function so the file is processed and not eliminated in the process
Added Ctrls.register()
to App.fs
.
I am not sure if I'm missing something but I pulled your form components. The LitComponents are rendered in HTML but it looks like it's not calling the function associated with the tags.
The only difference I see is that I am using Elmish at the root instead of Lit element. Not sure if that will make a difference?
I'm trying to use the horizontal stack component but no dice. If I explicitly call the function then it renders. I feel like something is missing?
Edit: What I notice is that the generated javascript doesn't have the Ctrls.fs? Maybe it's optimizing when it's not being used?