Skip to content

[🐞] Cannot access $routeLoader$ const before initialization in npm run preview #3634

@limjiechao

Description

@limjiechao

Which component is affected?

Qwik Runtime

Describe the bug

I am doing…

npm run preview

What I expect is

Preview of production server to run successfully to conduct E2E testing with playwright test.

What's actually happening

Unable to load any route because of the following error:

image

Error is happening because in entry.preview.mjs, usage of routeLoader$ happened before its declaration as a const. See screenshots of prettified build file below:

Usage happened at line 3865:
image

But routeLoader$ happened at line 3607.
image

Reproduction

https://github.com/limjiechao/qwik-error-reproduction

Steps to reproduce

I'm having difficulty reproducing it. But the repo link given is a minimal reproduction of my code.

Run npm run preview and the error described would have occurred in src/routes/layout.tsx.

Please do have a look. I'd be happy to assist further to correctly reproduce the problem for triaging if anyone has any idea what else could lead to it. Thank you!

Check out the repository above. Do a npm i && npm run preview.

System Info

System:
    OS: macOS 13.0
    CPU: (8) arm64 Apple M1
    Memory: 72.53 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 19.7.0 - ~/.nvm/versions/node/v19.7.0/bin/node
    npm: 9.5.0 - ~/.nvm/versions/node/v19.7.0/bin/npm
  Browsers:
    Chrome: 111.0.5563.146
    Safari: 16.1
  npmPackages:
    @builder.io/qwik: 0.100.0 => 0.100.0 
    @builder.io/qwik-city: 0.100.0 => 0.100.0 
    undici: 5.21.0 => 5.21.0 
    vite: 4.2.1 => 4.2.1

Additional Information

This error doesn't occur when I'm not on the RC:

If I downgrade to the following, everything works fine.

        "@builder.io/qwik": "0.24.0",
        "@builder.io/qwik-city": "0.7.1",
        "eslint-plugin-qwik": "^0.24.0",

Metadata

Metadata

Assignees

No one assigned

    Labels

    COMMUNITY: PR is welcomedWe think it's a good feature to have but would love for the community to help with the PR for itCOMP: docsImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions