vendure-ecommerce / storefront-qwik-starter

An e-commerce storefront starter built with Qwik and Vendure
https://qwik-storefront.vendure.io
227 stars 86 forks source link

Preview returns "ReferenceError: Cannot access 'serverQrl' before initialization" #124

Closed ar1em-k closed 1 year ago

ar1em-k commented 1 year ago

Npm/Yarn start works fine, but when trying to run "preview" (and disabling minification so error is not gibberish) I'm getting "ReferenceError: Cannot access 'serverQrl' before initialization".

Almost every instance of serverQrl is in autogenerated js files so it's either a qwik/npm bug (Unlikely - everything worked fine when I tried running "preview" on the example qwik app), a problem with configuration, or a problem with adding qwik's lazy-loading where it doesn't fit,

P.S. This is the first qwik app I'm trying, so I'm not sure what else should I check for a better bug report (if you need more info, please say what I need to send)

gioboa commented 1 year ago

Can you describe the steps to reproduce the issue?

ar1em-k commented 1 year ago

@gioboa For me it was

  1. run npm run preview
  2. open the browser
  3. See "ReferenceError: Cannot access 'Gy' before initialization" Screenshot_2023-08-08-00-25-49_1920x1080
  4. add minify:false option to build options of vite.config.ts
  5. See the real message of "ReferenceError: Cannot access 'serverQrl' before initialization" Screenshot_2023-08-08-00-31-19_1920x1080 Terminal running the command doesn't have any additional info. Screenshot_2023-08-08-00-41-44_1920x1080 (Even defining CustomLogger in vite.config.ts (that replaces everything with console.trace), does not give more info on error Screenshot_2023-08-08-01-03-34_1920x1080 )

P.S. Now double checking git I've noticed that package-lock.json is changed compared to the state I pulled the repo yesterday. Deleting in and running npm i again doesn't revert it to a state it was in git. Possibly one of the updates could break something in server. Just in case I created a git patch from all the changes compared to the git (I doubt autogenerated graphql schemas may be the problem, but better safe than sorry) changes_compared_to_default.patch.txt

gioboa commented 1 year ago

Fixed with this commit btw I will investigate more to update the lib.

gioboa commented 1 year ago

@ar1em-k Thanks for your report 👍

gioboa commented 1 year ago

The problem seems to be there, I will investigate

gioboa commented 1 year ago

With Qwik 1.1.6 preview works, but with Qwik 1.2.0+ we have the issue. We only have one server$ function but even if we removed it the problem persists. I think could be a dependency clash with vite

gioboa commented 1 year ago

it's really odd, now preview is working 🤷‍♂️