qwik icon indicating copy to clipboard operation
qwik copied to clipboard

fix(qwik-city): support vite.base in dev mode

Open JerryWu1234 opened this issue 1 year ago • 5 comments

Fixes #5984

JerryWu1234 avatar Mar 15 '24 10:03 JerryWu1234

Deploy request for qwik-insights pending review.

Visit the deploys page to approve it

Name Link
Latest commit 646ba54f80e56126e868a40126295f8578d70712

netlify[bot] avatar Mar 15 '24 10:03 netlify[bot]

@wmertens didn't finish yet. I create PR just for convenient sync code. lol

image

JerryWu1234 avatar Mar 15 '24 10:03 JerryWu1234

@wmertens I'm sorry to bother you, I know where problem is, but I was stuck on a crucial problem.

please take a look at this line

Why does it set a default '/build/', and what's between q:route and q:base.

JerryWu1234 avatar Mar 16 '24 05:03 JerryWu1234

/build is where the scripts are stored by default. The result of this function should then get the vite base added.

wmertens avatar Mar 16 '24 07:03 wmertens

Btw, you can set minify:false in the build to see prod as-is

wmertens avatar Mar 19 '24 20:03 wmertens

yR6clyXv70 pro

mLx3DdTwLv dev

everything is right

JerryWu1234 avatar Mar 21 '24 03:03 JerryWu1234

I also tested env and pro without base added

JerryWu1234 avatar Mar 21 '24 03:03 JerryWu1234

Great, but we need some unit tests and more consistent / handling

I'll add test after you reviewed.

JerryWu1234 avatar Mar 21 '24 07:03 JerryWu1234

@JerryWu1234 how's it going with the tests? Need help?

wmertens avatar Mar 30 '24 09:03 wmertens

@JerryWu1234 how's it going with the tests? Need help?

@wmertens I haven't tried to add tests yet because I’m waiting for your reply on the problem you mentioned

JerryWu1234 avatar Mar 30 '24 10:03 JerryWu1234

@JerryWu1234 which one specifically? I don't have any more information to add right now?

wmertens avatar Mar 30 '24 12:03 wmertens

@JerryWu1234 which one specifically? I don't have any more information to add right now?

https://github.com/BuilderIO/qwik/pull/6017#discussion_r1533292949

https://github.com/BuilderIO/qwik/pull/6017#discussion_r1533286154

Here

JerryWu1234 avatar Mar 30 '24 12:03 JerryWu1234

So I meant that we should have unit tests, and that you shouldn't have to replace the double slashes if you don't put them in.

So you need to be careful about base, don't call replace, and have unit tests that prove it doesn't add double slashes for various test cases

wmertens avatar Mar 30 '24 13:03 wmertens

So I meant that we should have unit tests, and that you shouldn't have to replace the double slashes if you don't put them in.

So you need to be careful about base, don't call replace, and have unit tests that prove it doesn't add double slashes for various test cases

So I meant that we should have unit tests, and that you shouldn't have to replace the double slashes if you don't put them in.

So you need to be careful about base, don't call replace, and have unit tests that prove it doesn't add double slashes for various test cases

Let me try to add some tests

JerryWu1234 avatar Mar 30 '24 14:03 JerryWu1234

@JerryWu1234 how's it going with the tests? Need help?

@wmertens

I really need your help.

there is a little tricks, To test the base attribute, we need to rely on both build and start. However, the current e2e only has build.

If I modify it, I'm afraid it will break the project's testing structure.

JerryWu1234 avatar Apr 01 '24 13:04 JerryWu1234

@JerryWu1234 🤔 actually the tests in v2 are a lot better. Take a look at the build/V2 branch, do you think you can incorporate your test there?

And actually, maybe that's not needed. It could be enough to make unit tests, not e2e

wmertens avatar Apr 01 '24 14:04 wmertens

@JerryWu1234 🤔 actually the tests in v2 are a lot better. Take a look at the build/V2 branch, do you think you can incorporate your test there?

And actually, maybe that's not needed. It could be enough to make unit tests, not e2e

https://github.com/BuilderIO/qwik/blob/87f0b9e5acf89f03204cc8e1cddaca8f54ad8ee9/starters/playwright.config.ts#L28 https://github.com/BuilderIO/qwik/blob/87f0b9e5acf89f03204cc8e1cddaca8f54ad8ee9/starters/dev-server.ts#L63 The build/v2 branch does not seem to have many changes compared to the master branch. It also seems that it is not possible to dynamically pass in the base parameter.

Here is my idea:

I referenced the Astro test code, and I think I can dynamically pass in the base parameter in both build and start modes. Vitest can cover most scenarios, but I don't know how to test the qwikLoader function in Vitest, , so I want to use e2e tests.

JerryWu1234 avatar Apr 03 '24 07:04 JerryWu1234

I think I can dynamically pass in the base parameter in both build and start modes

sounds good, give it a shot!

wmertens avatar Apr 03 '24 21:04 wmertens

@JerryWu1234 there's a TS error https://github.com/BuilderIO/qwik/actions/runs/8508365123/job/23414373840?pr=6017#step:7:14

wmertens avatar Apr 09 '24 06:04 wmertens

@JerryWu1234 there's a TS error https://github.com/BuilderIO/qwik/actions/runs/8508365123/job/23414373840?pr=6017#step:7:14

I got it. I'm write the test right now, and will fix it late

JerryWu1234 avatar Apr 09 '24 06:04 JerryWu1234

@wmertens https://github.com/BuilderIO/qwik/blob/646ba54f80e56126e868a40126295f8578d70712/packages/qwik/src/vite-basetest.unit.ts#L12 the function starts a qwik server and simulates passing in qwikCity() and qwikVite(). I referred to the dev-server code.

  1. Could you please evaluate the feasibility of my test plan?
  2. I can't write a complete test yet because there is an error. The error is a bit complicated. I hope you can help me take a look. image

JerryWu1234 avatar Apr 09 '24 09:04 JerryWu1234

I propose you leave the tests out, on the v2 branch it will be clearer how to test e2e

https://github.com/QwikDev/qwik/blob/build/v2/starters/dev-server.ts

No different in both branches (master and build/v2) I have checked.

Could you please help me to point out where I add my test ?

JerryWu1234 avatar Apr 10 '24 07:04 JerryWu1234

@JerryWu1234 actually the e2e tests don't test qwik-city yet in v2, so we'll have to wait for that to add a test.

In the meantime we can merge this in v1

wmertens avatar Apr 10 '24 16:04 wmertens

actually the e2e tests don't test qwik-city yet in v2, so we'll have to wait for that to add a test

ok . add tests late

JerryWu1234 avatar Apr 11 '24 06:04 JerryWu1234

last check before merge

dev has /newbase/ image

no /newbase/ image

pro has /newbase/ image

no /newbase/ image

JerryWu1234 avatar Apr 15 '24 01:04 JerryWu1234

I do need this but I do set base to a cloudfront url so the regexp may not work

PatrickJS avatar Apr 15 '24 02:04 PatrickJS

I do need this but I do set base to a cloudfront url so the regexp may not work

good idea I will cover this function

JerryWu1234 avatar Apr 15 '24 05:04 JerryWu1234

image image @PatrickJS it has already covered it

JerryWu1234 avatar Apr 15 '24 09:04 JerryWu1234

@wmertens now is ok, I will do rest of the part after build/2‘test is improved

JerryWu1234 avatar Apr 16 '24 10:04 JerryWu1234

@wmertens When will build/v2 branch finish the test enhancement ?

JerryWu1234 avatar Apr 17 '24 02:04 JerryWu1234