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: fix up PrefetchServiceWorker with multiple Qwik containers #6468

Merged
merged 25 commits into from
Jun 12, 2024

Conversation

gioboa
Copy link
Member

@gioboa gioboa commented Jun 8, 2024

Overview

What is it?

  • Feature / enhancement
  • Bug
  • Docs / tests / types / typos

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Use cases and why

    1. One use case
    1. Another use case

Checklist:

  • My code follows the developer guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • Added new tests to cover the fix / functionality

Copy link

netlify bot commented Jun 8, 2024

👷 Deploy request for qwik-insights pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 58a0826

@gioboa gioboa changed the title chore: add debug message fix: fix up PrefetchServiceWorker Jun 8, 2024
Copy link

pkg-pr-new bot commented Jun 8, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@builder.io/qwik (58a0826)

npm i https://pkg.pr.new/@builder.io/qwik@6468

@builder.io/qwik-city (58a0826)

npm i https://pkg.pr.new/@builder.io/qwik-city@6468

eslint-plugin-qwik (58a0826)

npm i https://pkg.pr.new/eslint-plugin-qwik@6468

create-qwik (58a0826)

npm i https://pkg.pr.new/create-qwik@6468

@wmertens
Copy link
Member

LGTM, why is this draft @gioboa ?

@gioboa
Copy link
Member Author

gioboa commented Jun 10, 2024

Because we are testing the fix in our POC
If it works, I will change the status

@gioboa gioboa marked this pull request as ready for review June 12, 2024 02:29
@gioboa gioboa requested a review from a team as a code owner June 12, 2024 02:29
@gioboa
Copy link
Member Author

gioboa commented Jun 12, 2024

The SW worker is fetching the remote bundles correctly
image

@gioboa gioboa changed the title fix: fix up PrefetchServiceWorker fix: fix up PrefetchServiceWorker with multiple Qwik containers Jun 12, 2024
Copy link
Member

@thejackshelton thejackshelton left a comment

Choose a reason for hiding this comment

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

Amazing work 🙌

@@ -23,9 +23,21 @@ export function prefetchUrlsEventScript(prefetchResources: PrefetchResource[]) {
const data: QPrefetchData = {
bundles: flattenPrefetchResources(prefetchResources).map((u) => u.split('/').pop()!),
};
return `document.dispatchEvent(new CustomEvent("qprefetch",{detail:${JSON.stringify(data)}}))`;
return `(${PREFETCH_BUNDLES_CODE})(
document.currentScript.closest('[q\\\\:container]'),
Copy link
Member

Choose a reason for hiding this comment

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

Why we need this? [q\\:container] is not enough?

Copy link
Member Author

Choose a reason for hiding this comment

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

we need to run this in the browser to use the right one. I used the same logic we have here

@gioboa gioboa merged commit b7c31bd into QwikDev:main Jun 12, 2024
22 checks passed
@gioboa gioboa deleted the fix/prefech-sw branch June 12, 2024 12:00
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.

[🐞] Service Worker prefetch strategy does not work with multiple Qwik containers
5 participants