varabyte / kobweb

A modern framework for full stack web apps in Kotlin, built upon Compose HTML
https://kobweb.varabyte.com
Apache License 2.0
1.56k stars 70 forks source link

Losing original pages when generating new ones via KSP #442

Closed asapha closed 9 months ago

asapha commented 9 months ago

Description

Hey there, I tried to solve the same problem as this issue using KSP.
But when I generate @Page annotated functions, Kobweb only knows about the new ones and, I can't navigate to the pages that were declared manually.

/ leads to a 404 for example.

Repro

I've made a repro at https://github.com/asapha/kobweb on the ksp-rounds-issue branch. It adds a custom processor to the playground project. (diff)

The generated frontend.json file generated on the project:

frontend.json `XXXcopy` are the generated Pages/Composables. Notice that all the original pages are missing. ```json { "appEntry": { "fqn": "playground.AppEntry" }, "frontendData": { "pages": [ { "fqn": "playground.pages.HomePageCopy", "route": "/homepagecopy" }, { "fqn": "playground.pages.EchoPageCopy", "route": "/echopagecopy" }, { "fqn": "playground.pages.KotlinLanguagePageCopy", "route": "/kotlinlanguagepagecopy" }, { "fqn": "playground.pages.WorkerPageCopy", "route": "/workerpagecopy" }, { "fqn": "playground.pages.WidgetsPageCopy", "route": "/widgetspagecopy" }, { "fqn": "playground.pages.MarkdownPageCopy", "route": "/markdownpagecopy" }, { "fqn": "playground.pages.documents.BananasPageCopy", "route": "/documents/bananaspagecopy" }, { "fqn": "playground.pages.documents.INDEXPageCopy", "route": "/documents/indexpagecopy" } ], "kobwebInits": [], "silkInits": [], "silkStyles": [ { "fqcn": "playground.pages.WidgetSectionStyle" }, { "fqcn": "playground.pages.WidgetPaddingStyle" }, { "fqcn": "playground.pages.WidgetLabelStyle" }, { "fqcn": "playground.pages.IconContainerStyle" } ], "silkVariants": [], "keyframesList": [] } } ```
Screenshot of the generated files ![CleanShot 2024-01-21](https://github.com/varabyte/kobweb/assets/1147807/264bdcf4-2b7c-455b-9163-c3f21c4e5e98)

Seems like FrontendProcessor would need to handle multi round processing. Please let me know if there's something I'm missing.

bitspittle commented 9 months ago

Just a heads up that we received this issue and are thinking about it / looking into it. Thanks for the report!

bitspittle commented 9 months ago

Hey @asapha , we think we have it fixed, but it would be great if you could confirm on your end.

Since you've pulled down the code, you can either sync latest (make sure you're on the 0.15.5 branch), and add your processor in the playground there. Or, if you have a real project, you can try setting the Kobweb dependency in your libs.version.toml file to 0.15.5-SNAPSHOT.

Thank you!

asapha commented 9 months ago

Hi @bitspittle, it works OK on my end, nice work!

bitspittle commented 9 months ago

Don't thank me, thank @DennisTsar who is a coding wizard. 🧙

Appreciate the confirmation that you're fixed!