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(hydration): provide compat fallback for idle callback #11935

Merged
merged 13 commits into from
Oct 11, 2024

Conversation

GalacticHypernova
Copy link
Contributor

This PR provides a compatibility polyfill for idle callback, which is not supported in Safari. The implementation is taken straight from Nuxt's.

Copy link

netlify bot commented Sep 15, 2024

Deploy Preview for vue-next-template-explorer failed.

Name Link
🔨 Latest commit b98eaa1
🔍 Latest deploy log https://app.netlify.com/sites/vue-next-template-explorer/deploys/66ea84871e6e6e0008b8a3c3

Copy link

netlify bot commented Sep 15, 2024

Deploy Preview for vue-sfc-playground failed.

Name Link
🔨 Latest commit b98eaa1
🔍 Latest deploy log https://app.netlify.com/sites/vue-sfc-playground/deploys/66ea848772b17400082cd537

@GalacticHypernova GalacticHypernova marked this pull request as draft September 15, 2024 22:23
Copy link

github-actions bot commented Sep 15, 2024

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 101 kB (+66 B) 38.1 kB (+24 B) 34.3 kB (+22 B)
vue.global.prod.js 160 kB (+66 B) 58.1 kB (+30 B) 51.6 kB (+45 B)

Usages

Name Size Gzip Brotli
createApp (CAPI only) 49.2 kB (+91 B) 19 kB (+46 B) 17.3 kB (-1 B)
createApp 55.8 kB (+91 B) 21.5 kB (+46 B) 19.6 kB (+34 B)
createSSRApp 59.8 kB (+91 B) 23.2 kB (+49 B) 21.1 kB (+27 B)
defineCustomElement 60.6 kB (+91 B) 23.1 kB (+48 B) 21 kB (+38 B)
overall 69.5 kB (+91 B) 26.6 kB (+41 B) 24.2 kB (+25 B)

Copy link

pkg-pr-new bot commented Sep 15, 2024

Open in Stackblitz

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@11935

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@11935

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@11935

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@11935

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@11935

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@11935

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@11935

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@11935

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@11935

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@11935

vue

pnpm add https://pkg.pr.new/vue@11935

commit: 3b01a2a

@GalacticHypernova GalacticHypernova marked this pull request as ready for review September 15, 2024 22:31
import { DOMNodeTypes, isComment } from './hydration'

const globalThis = getGlobalThis()
Copy link
Member

Choose a reason for hiding this comment

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

Move this into the functions where it's needed and call it inline (it's cached) so that this can be treeshaken with the functions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Typescript appears to have issues with this approach

packages/runtime-core/src/hydrationStrategies.ts Outdated Show resolved Hide resolved
// https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/app/compat/idle-callback.ts
// Polyfills for Safari support
// https://caniuse.com/requestidlecallback
const requestIdleCallback: typeof getGlobalThis().requestIdleCallback =

Choose a reason for hiding this comment

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

this should not be like this ReturnType<typeof getGlobalThis>['requestIdleCallback'] ?

@edison1105 edison1105 added ready to merge The PR is ready to be merged. 🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. labels Oct 8, 2024
@yyx990803 yyx990803 merged commit 1ae545a into vuejs:main Oct 11, 2024
13 checks passed
@GalacticHypernova GalacticHypernova deleted the patch-3 branch October 11, 2024 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. ready to merge The PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants