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

cloudflare build fails if routes/index.tsx is replaced by vinxi dev server automatically #2814

Open
jonotron opened this issue Nov 21, 2024 · 5 comments
Labels
information needed Further information is requested start Everything about TanStack Start

Comments

@jonotron
Copy link

jonotron commented Nov 21, 2024

Which project does this relate to?

Start

Describe the bug

If npm run dev is running and the vinxi is boot strapping route files for you and you delete the index.tsx file and then generate a new one (or rename another route to index.tsx), npm run build will fail with the following error:

[tsr-routes-manifest] Could not load tsr:routes-manifest (imported by node_modules/@tanstack/start/dist/esm/router-manifest/index.js): Cannot read properties of undefined (reading 'map')

This does not seem to happen if vinxi dev server is not running and you rename files and adjust the router path manually.

It's not clear how to recover from this error (at least everything I've tried). Deleting the .vinxi/, dist/, and node_modules (and reinstalling) does not seem to reset things to a workable state.

Your Example Website or App

https://stackblitz.com/~/github.com/jonotron/start-basic-example

Steps to Reproduce the Bug or Issue

  1. clone the start-counter (or start-basic) example from the tanstack/router repository
  2. npm install
  3. npm install unenv
  4. Add cloudflare settings to app.config.js from https://tanstack.com/router/latest/docs/framework/react/start/hosting#cloudflare-pages
  5. run npm run build to verify that a cloudflare build will succeed
  6. run npm run dev to get vinxi dev server running
  7. delete the app/routes/index.tsx file
  8. create a new app/routes/index.tsx file (vinxi will fill in with basic scaffolding code)
  9. quit the vinxi dev server
  10. run npm run build

Expected behavior

As a developer, I expect the build to continue to work when vinxi creates a new index.tsx route for me.

Screenshots or Videos

No response

Platform

  • OS: macOS, Linux (stackblitz)

Additional context

I'm not totally sure what exactly is scaffolding the new routes for me (it caught me off guard when I noticed it) but I'm fairly sure it's vinxi dev server. And I'm not even entirely sure if this is the cause of the bug but I can reliably reproduce the issue on my mac and on stackblitz. I can't figure out how to revert the issue for the life of me.

This doesn't seem to affect non cloudflare target build but I haven't spent much time exploring anything else yet.

Hope this is helpful as I'm quite enjoying exploring start but this has been eating at me for some days now.

@SeanCassiere
Copy link
Member

I'm not sure if this is something that's really in our control here.

@tannerlinsley @nksaraf is there a reasonable expectation for running both the build script whilst the dev one is running here?

Also, @nksaraf is this something you've seen with SolidStart?

@SeanCassiere SeanCassiere added has workaround A solution has been provided. start Everything about TanStack Start information needed Further information is requested and removed has workaround A solution has been provided. labels Nov 21, 2024
@jonotron
Copy link
Author

This error appears even after stopping the dev server before running the build. And it seems to get into a state that I can not recover from at all. I can try to record a little video later today if that helps.

@jonotron
Copy link
Author

Here's a short video showing what I did to get into this state: https://share.cleanshot.com/ssy8Wfxk

@jonotron
Copy link
Author

Sorry all. I think I've figured this out. The scaffolded route file does not return JSX, it just returns a string.

import { createFileRoute } from '@tanstack/react-router'

export const Route = createFileRoute('/')({
  component: RouteComponent,
})

function RouteComponent() {
  return 'Hello /!' // this needs to be JSX
}

If I bother to edit the scaffolded file to return JSX instead of a string the build succeeds.

@SeanCassiere
Copy link
Member

Sorry all. I think I've figured this out. The scaffolded route file does not return JSX, it just returns a string.

import { createFileRoute } from '@tanstack/react-router'

export const Route = createFileRoute('/')({
  component: RouteComponent,
})

function RouteComponent() {
  return 'Hello /!' // this needs to be JSX
}

If I bother to edit the scaffolded file to return JSX instead of a string the build succeeds.

Definitely one of the weirder bugs I've seen 🙄

Would you be comfortable making a PR fixing this in the router-generator? It'd just be changing it from returning a string to a <div> wrapping the route path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
information needed Further information is requested start Everything about TanStack Start
Projects
None yet
Development

No branches or pull requests

2 participants