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

ReferenceError: can't access lexical declaration 'layouts' before initialization #93

Closed
dewelooper opened this issue Jan 15, 2023 · 2 comments

Comments

@dewelooper
Copy link

Hello,
can somebody help me with this error?

Error points on my main.ts and this line:

const routes = setupLayouts(generatedRoutes)

variable is used here:

export const router = createRouter({
  history: createWebHistory(),
  routes,
})

(I didnt customize this package and usage in any aspect - it is working by default)

Strange is that this error occurs suddenly after some change and block rendering pages. Refreshing page change nothing, but when I stop vite and run "pnpm dev" it always start working for some time (sometimes for 10min but sometimes for 10h).

System is on development stage so I dont faced with this error on builded instance.

Please advice

Thank you
K.

@zhiyuanzmj
Copy link

Setting importMode to async can temporarily solve it.
posva/unplugin-vue-router#132 (comment)

import Layouts, { defaultImportMode } from 'vite-plugin-vue-layouts'

export default defineConfig({
 // ....
 plugins:[
   Layouts({
      importMode: process.env.NODE_ENV === 'production' ? defaultImportMode : () => 'async',
   }),
 ]

@JohnCampionJr
Copy link
Owner

Send along a reproduction repo and I'll try to take a look. Not enough info here.

@JohnCampionJr JohnCampionJr closed this as not planned Won't fix, can't repro, duplicate, stale Apr 22, 2023
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

No branches or pull requests

3 participants