vikejs / vike

🔨 Flexible, lean, community-driven, dependable, fast Vite-based frontend framework.
https://vike.dev
MIT License
4.39k stars 352 forks source link

Some sort of bug with placing pages in ./src #1941

Closed angleKH closed 3 weeks ago

angleKH commented 3 weeks ago

Description

[vike@0.4.199][Bug] You stumbled upon a Vike bug. Go to https://github.com/vikejs/vike/issues/new and copy-paste this error. A maintainer will fix the bug (usually under 24 hours).
    at getVirtualFilePageConfigValuesAll (./node_modules/vike/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js:24:5)
    at LoadPluginContext.load (./node_modules/vike/dist/esm/node/plugin/plugins/importUserCode/index.js:53:30)
    at PluginContainer.load (./node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:49063:22)
    at loadAndTransform (./node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:51869:22)

Docs state that pages can be place under ./src/pages, but this appears to be error-prone. Here is what I remember doing:

  1. With a vike-vue project, Create a page under ./src (note the mistake, the page placed in ./src, not ./src/pages)
  2. Run npm run dev, the page works
  3. Add a +onBeforeRenderClient.js and a +onAfterRenderClient.js
  4. Get errors like [vike][config][Wrong Usage] /src/[page name]/+onBeforeRenderClient.js sets an unknown config onBeforeRenderClient. Did you mean to set onBeforeRenderEnv instead?
  5. Remove +onBeforeRenderClient.js and +onAfterRenderClient.js
  6. The page no longer works although it should like it did before since the problematic hook files are gone, error given is [vike][request(4)][Wrong Usage] No onRenderHtml() hook found, see https://vike.dev/onRenderHtml despite using vike-vue.
  7. Move properly to ./src/pages
  8. Page still does not work
  9. Stop the dev server and process and run npm run dev again
  10. The page still no longer works
  11. Move page from ./src/pages to ./pages instead
  12. The page works perfectly
brillout commented 3 weeks ago

See updated docs:

[vike@0.4.199][Bug] You stumbled upon a Vike bug. Go to https://github.com/vikejs/vike/issues/new and copy-paste this error. A maintainer will fix the bug (usually under 24 hours).
    at getVirtualFilePageConfigValuesAll (./node_modules/vike/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js:24:5)
    at LoadPluginContext.load (./node_modules/vike/dist/esm/node/plugin/plugins/importUserCode/index.js:53:30)
    at PluginContainer.load (./node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:49063:22)
    at loadAndTransform (./node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:51869:22)

Can you reproduce that error or is it random? Closing as I suspect it's random, let's re-open once we get more information.