analogjs / analog

The fullstack meta-framework for Angular. Powered by Vite and Nitro
https://analogjs.org
MIT License
2.5k stars 240 forks source link

Add error message when `xx.page.ts` does not have a default export #1129

Closed alexciesielski closed 2 months ago

alexciesielski commented 3 months ago

Which scope/s are relevant/related to the feature request?

router

Information

I pulled my hair out trying to figure out why my routing does not work. Turns out the component needs to be a default export.

There are two improvements that could be made here:

  1. Make that requirement more visible in the documentation, right now it's not immediately visible when skimming the docs. I would make it a bigger "alert" with maybe a yellow background.
  2. Add a check and error message before resolving the routes, instead of propagating the default Angular error that a component needs to be provided in the Route definition.

Describe any alternatives/workarounds you're currently using

No response

I would be willing to submit a PR to fix this issue

brandonroberts commented 2 months ago

An development-only check could be added here

https://github.com/analogjs/analog/blob/beta/packages/router/src/lib/routes.ts#L188