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

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

Open
wants to merge 40 commits into
base: main
Choose a base branch
from

Conversation

JerryWu1234
Copy link
Contributor

@JerryWu1234 JerryWu1234 commented Mar 15, 2024

Fixes #5984

Copy link

netlify bot commented Mar 15, 2024

👷 Deploy request for qwik-insights pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 646ba54

@JerryWu1234 JerryWu1234 changed the title fix a bug 5984 fix: A bug fix Mar 15, 2024
@wmertens wmertens changed the title fix: A bug fix fix(qwik-city): support vite.base in dev mode Mar 15, 2024
@JerryWu1234
Copy link
Contributor Author

JerryWu1234 commented Mar 15, 2024

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

image

@JerryWu1234
Copy link
Contributor Author

@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.

@wmertens
Copy link
Member

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

@wmertens
Copy link
Member

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

@JerryWu1234
Copy link
Contributor Author

yR6clyXv70
pro

mLx3DdTwLv
dev

everything is right

@JerryWu1234 JerryWu1234 marked this pull request as ready for review March 21, 2024 03:13
@JerryWu1234
Copy link
Contributor Author

I also tested env and pro without base added

Copy link
Member

@wmertens wmertens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

packages/qwik/src/core/platform/platform.ts Outdated Show resolved Hide resolved
packages/qwik/src/optimizer/src/plugins/plugin.ts Outdated Show resolved Hide resolved
packages/qwik/src/optimizer/src/plugins/vite-server.ts Outdated Show resolved Hide resolved
packages/qwik/src/qwikloader.ts Outdated Show resolved Hide resolved
@JerryWu1234
Copy link
Contributor Author

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

I'll add test after you reviewed.

@wmertens
Copy link
Member

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

@JerryWu1234
Copy link
Contributor Author

JerryWu1234 commented Mar 30, 2024

@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

@wmertens
Copy link
Member

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

@JerryWu1234
Copy link
Contributor Author

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

#6017 (comment)

#6017 (comment)

Here

@wmertens
Copy link
Member

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

@JerryWu1234
Copy link
Contributor Author

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
Copy link
Contributor Author

JerryWu1234 commented Apr 1, 2024

@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.

@wmertens
Copy link
Member

wmertens commented Apr 1, 2024

@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

@JerryWu1234
Copy link
Contributor Author

@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.

@wmertens
Copy link
Member

wmertens commented Apr 3, 2024

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

sounds good, give it a shot!

@PatrickJS
Copy link
Member

oh maybe its erroring since the e2e tests are running the app in a browser so if the files can't load. thats the only thing i can think of

auto-merge was automatically disabled May 7, 2024 05:39

Head branch was pushed to by a user without write access

@PatrickJS
Copy link
Member

idk about this I think we need to make sure /build/ is added for scripts even if base was set

@wmertens
Copy link
Member

wmertens commented May 7, 2024

I think we need to take a step back here. q:base is the absolute path or full URL of where Qwik is supposed to get the dist files, and vite base is the prefix path to the url of the application.

  • We need to make sure we use the right thing at the right time.
  • q:base needs to be absolute or a full URL and end with /. It needs to include the vite base if it's not explicitly set.
  • vite base needs to be absolute and end with /

I see a bunch of duplication around / handling, we can't have that. It needs to be simple throughout, with a helper function if needed. We know that the bases will always end with /.

Furthermore, it's up to the dev to use the vite base in their URLs, we can't add it for them, because there might be links between microfrontends.

@JerryWu1234
Copy link
Contributor Author

JerryWu1234 commented May 7, 2024

I think we need to take a step back here. q:base is the absolute path or full URL of where Qwik is supposed to get the dist files, and vite base is the prefix path to the url of the application.

  • We need to make sure we use the right thing at the right time.
  • q:base needs to be absolute or a full URL and end with /. It needs to include the vite base if it's not explicitly set.
  • vite base needs to be absolute and end with /

I see a bunch of duplication around / handling, we can't have that. It needs to be simple throughout, with a helper function if needed. We know that the bases will always end with /.

Furthermore, it's up to the dev to use the vite base in their URLs, we can't add it for them, because there might be links between microfrontends.

just want to confirm I understand or not.
such as if user set a Vite base: '/newbase/'
so that the q:base is http://localhost:3000/newbase/ in dev
and the q:base is http://localhost:3000/newbase/build/ in pro

@PatrickJS @wmertens

I think we can try to easy way to fix this bug and waiting for built/v2.
because it's very difficult to guarantee whether it's right or not without tests, and it's also tough to test code is right ot not

@PatrickJS
Copy link
Member

q:base is for assets so it's saying this is where the /build/ files are. I think it makes sense right now to always make sure /build/ is in the url

@PatrickJS PatrickJS self-assigned this May 14, 2024
Copy link

netlify bot commented May 16, 2024

👷 Deploy request for qwik-insights pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit e5bb3f5

@wmertens
Copy link
Member

Actually I wonder if b381b22 fixed this - can you check if 1.5.5 still needs this PR @JerryWu1234 ?

@JerryWu1234
Copy link
Contributor Author

Actually I wonder if b381b22 fixed this - can you check if 1.5.5 still needs this PR @JerryWu1234 ?

Let me check tomorrow

@JerryWu1234
Copy link
Contributor Author

image
image
still has a problem

@wmertens
Copy link
Member

Thank you for checking @JerryWu1234, can you figure out exactly what is wrong? Is the q:base wrong, or is it requesting specific files wrongly etc

@JerryWu1234
Copy link
Contributor Author

Thank you for checking @JerryWu1234, can you figure out exactly what is wrong? Is the q:base wrong, or is it requesting specific files wrongly etc

Just check where wrong is? or fix it in this PR?

@wmertens
Copy link
Member

@JerryWu1234 yes just where. Is it by any chance when it's trying to load /src/something..._hashhashhash.js? Then I know where to fix it (and I'm replacing that anyway)

@PatrickJS
Copy link
Member

I'll fix the pr

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

Successfully merging this pull request may close these issues.

[🐞] qwik-city: vite base doesn't work in dev mode
4 participants